本文整理汇总了Java中org.onosproject.net.edge.EdgePortEvent类的典型用法代码示例。如果您正苦于以下问题:Java EdgePortEvent类的具体用法?Java EdgePortEvent怎么用?Java EdgePortEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EdgePortEvent类属于org.onosproject.net.edge包,在下文中一共展示了EdgePortEvent类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processDeviceEvent
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
private void processDeviceEvent(DeviceEvent event) {
//FIXME handle the case where a device is suspended, this may or may not come up
DeviceEvent.Type type = event.type();
DeviceId id = event.subject().id();
if (type == DEVICE_ADDED ||
type == DEVICE_AVAILABILITY_CHANGED && deviceService.isAvailable(id)) {
// When device is added or becomes available, add all its ports
deviceService.getPorts(event.subject().id())
.forEach(p -> addEdgePort(new ConnectPoint(id, p.number())));
} else if (type == DEVICE_REMOVED ||
type == DEVICE_AVAILABILITY_CHANGED && !deviceService.isAvailable(id)) {
// When device is removed or becomes unavailable, remove all its ports.
// Note: cannot rely on Device subsystem, ports may be gone.
Optional.ofNullable(connectionPoints.remove(id))
.orElse(ImmutableSet.of())
.forEach(point -> post(new EdgePortEvent(EDGE_PORT_REMOVED, point)));
} else if (type == DeviceEvent.Type.PORT_ADDED ||
type == PORT_UPDATED && event.port().isEnabled()) {
addEdgePort(new ConnectPoint(id, event.port().number()));
} else if (type == DeviceEvent.Type.PORT_REMOVED ||
type == PORT_UPDATED && !event.port().isEnabled()) {
removeEdgePort(new ConnectPoint(id, event.port().number()));
}
}
示例2: removeEdgePort
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
private void removeEdgePort(ConnectPoint point) {
// trying to remove edge ports, so we shouldn't check if it's EdgePoint
if (!point.port().isLogical()) {
Set<ConnectPoint> set = connectionPoints.get(point.deviceId());
if (set == null) {
return;
}
if (set.remove(point)) {
post(new EdgePortEvent(EDGE_PORT_REMOVED, point));
}
if (set.isEmpty()) {
connectionPoints.computeIfPresent(point.deviceId(), (k, v) -> {
if (v.isEmpty()) {
return null;
} else {
return v;
}
});
}
}
}
示例3: activate
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
@Activate
public void activate() {
eventDispatcher.addSink(EdgePortEvent.class, listenerRegistry);
deviceService.addListener(deviceListener);
linkService.addListener(linkListener);
loadAllEdgePorts();
log.info("Started");
}
示例4: deactivate
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
@Deactivate
public void deactivate() {
eventDispatcher.removeSink(EdgePortEvent.class);
deviceService.removeListener(deviceListener);
linkService.removeListener(linkListener);
log.info("Stopped");
}
示例5: addEdgePort
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
private void addEdgePort(ConnectPoint point) {
if (!topologyService.isInfrastructure(topology, point) && !point.port().isLogical()) {
Set<ConnectPoint> set = connectionPoints.get(point.deviceId());
if (set == null) {
set = Sets.newConcurrentHashSet();
connectionPoints.put(point.deviceId(), set);
}
if (set.add(point)) {
post(new EdgePortEvent(EDGE_PORT_ADDED, point));
}
}
}
示例6: removeEdgePort
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
private void removeEdgePort(ConnectPoint point) {
if (!point.port().isLogical()) {
Set<ConnectPoint> set = connectionPoints.get(point.deviceId());
if (set == null) {
return;
}
if (set.remove(point)) {
post(new EdgePortEvent(EDGE_PORT_REMOVED, point));
}
if (set.isEmpty()) {
connectionPoints.remove(point.deviceId());
}
}
}
示例7: deactivate
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
@Deactivate
public void deactivate() {
deviceService.removeListener(deviceListener);
linkService.removeListener(linkListener);
eventDispatcher.removeSink(EdgePortEvent.class);
log.info("Stopped");
}
示例8: addEdgePort
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
private void addEdgePort(ConnectPoint point) {
if (isEdgePort(point)) {
Set<ConnectPoint> set = connectionPoints.computeIfAbsent(point.deviceId(),
(k) -> Sets.newConcurrentHashSet());
if (set.add(point)) {
post(new EdgePortEvent(EDGE_PORT_ADDED, point));
}
}
}
示例9: TestListener
import org.onosproject.net.edge.EdgePortEvent; //导入依赖的package包/类
public TestListener(List<EdgePortEvent> events) {
this.events = events;
}