本文整理汇总了Java中org.onosproject.net.host.HostEvent.type方法的典型用法代码示例。如果您正苦于以下问题:Java HostEvent.type方法的具体用法?Java HostEvent.type怎么用?Java HostEvent.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.host.HostEvent
的用法示例。
在下文中一共展示了HostEvent.type方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hostMessage
import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
protected ObjectNode hostMessage(HostEvent event) {
Host host = event.subject();
String hostType = host.annotations().value(AnnotationKeys.TYPE);
ObjectNode payload = mapper.createObjectNode()
.put("id", host.id().toString())
.put("type", isNullOrEmpty(hostType) ? "endstation" : hostType)
.put("ingress", compactLinkString(edgeLink(host, true)))
.put("egress", compactLinkString(edgeLink(host, false)));
payload.set("cp", hostConnect(mapper, host.location()));
payload.set("labels", labels(mapper, ip(host.ipAddresses()),
host.mac().toString()));
payload.set("props", props(host.annotations()));
addGeoLocation(host, payload);
addMetaUi(host.id().toString(), payload);
String type = (event.type() == HOST_ADDED) ? "addHost" :
((event.type() == HOST_REMOVED) ? "removeHost" : "updateHost");
return envelope(type, 0, payload);
}
示例2: handle
import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
private void handle(HostEvent event) {
Host host = event.subject();
if (!mastershipService.isLocalMaster(host.location().deviceId())) {
// do not allow to proceed without mastership
return;
}
Instance instance = Instance.of(host);
if (!netTypes.isEmpty() && !netTypes.contains(instance.netType())) {
// not my service network instance, do nothing
return;
}
switch (event.type()) {
case HOST_UPDATED:
instanceUpdated(instance);
break;
case HOST_ADDED:
instanceDetected(instance);
break;
case HOST_REMOVED:
instanceRemoved(instance);
break;
default:
break;
}
}
示例3: event
import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
@Override
public void event(HostEvent hostEvent) {
if (hostEvent.type() == HostEvent.Type.HOST_ADDED) {
Host host = hostEvent.subject();
ObjectNode hostMessage = objectNode();
hostMessage.put("mac", host.mac().toString());
hostMessage.put("vlan", host.vlan().toShort());
hostMessage.put("ip", host.ipAddresses().toString());
connection().sendMessage("hostEvent", 0, hostMessage);
}
}
示例4: event
import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
/**
*
* @param hostEvent Host event that we use to detect adding new hosts to the network
*/
@Override
public void event(HostEvent hostEvent) {
if (hostEvent.type() == HostEvent.Type.HOST_ADDED) {
Host host = hostEvent.subject();
ObjectNode hostMessage = objectNode();
hostMessage.put("mac", host.mac().toString());
hostMessage.put("vlan", host.vlan().toShort());
hostMessage.put("ip", host.ipAddresses().toString());
connection().sendMessage("hostEvent", 0, hostMessage);
}
}
示例5: isRelevant
import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
@Override
public boolean isRelevant(HostEvent event) {
return !appFreezed && event.type() == HOST_ADDED;
}
示例6: run
import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
@Override
public void run() {
if (event instanceof DeviceEvent) {
DeviceEvent deviceEvent = (DeviceEvent) event;
switch (deviceEvent.type()) {
case DEVICE_ADDED:
log.debug("device {} is added", deviceEvent.subject().id());
break;
case DEVICE_AVAILABILITY_CHANGED:
Device device = deviceEvent.subject();
if (deviceService.isAvailable(device.id())) {
log.debug("device {} is added", device.id());
}
break;
case PORT_ADDED:
processPortUpdated(deviceEvent.subject(), deviceEvent.port());
break;
case PORT_UPDATED:
processPortUpdated(deviceEvent.subject(), deviceEvent.port());
break;
case PORT_REMOVED:
processPortRemoved(deviceEvent.port());
break;
default:
log.debug("Unsupported deviceEvent type {}", deviceEvent.type().toString());
break;
}
} else if (event instanceof HostEvent) {
HostEvent hostEvent = (HostEvent) event;
switch (hostEvent.type()) {
case HOST_REMOVED:
log.debug("host {} was removed", hostEvent.subject().toString());
break;
default:
log.debug("Unsupported hostEvent type {}", hostEvent.type().toString());
break;
}
}
}