Search in sources :

Example 1 with EDGE_PORT_REMOVED

use of org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_REMOVED in project onos by opennetworkinglab.

the class EdgeManager method processDeviceEvent.

// Processes a device event by adding or removing its end-points in our cache.
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()));
    }
}
Also used : PACKET_WRITE(org.onosproject.security.AppPermission.Type.PACKET_WRITE) EdgePortEvent(org.onosproject.net.edge.EdgePortEvent) LinkEvent(org.onosproject.net.link.LinkEvent) DEVICE_ADDED(org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED) DeviceService(org.onosproject.net.device.DeviceService) AppGuard.checkPermission(org.onosproject.security.AppGuard.checkPermission) DEVICE_REMOVED(org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Component(org.osgi.service.component.annotations.Component) OutboundPacket(org.onosproject.net.packet.OutboundPacket) Map(java.util.Map) Activate(org.osgi.service.component.annotations.Activate) EdgePortService(org.onosproject.net.edge.EdgePortService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PORT_STATS_UPDATED(org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED) EDGE_PORT_ADDED(org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_ADDED) EDGE_PORT_REMOVED(org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_REMOVED) DeviceListener(org.onosproject.net.device.DeviceListener) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) LinkListener(org.onosproject.net.link.LinkListener) EdgePortListener(org.onosproject.net.edge.EdgePortListener) DeviceEvent(org.onosproject.net.device.DeviceEvent) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) LinkService(org.onosproject.net.link.LinkService) Optional(java.util.Optional) DeviceId(org.onosproject.net.DeviceId) Reference(org.osgi.service.component.annotations.Reference) PORT_UPDATED(org.onosproject.net.device.DeviceEvent.Type.PORT_UPDATED) TOPOLOGY_READ(org.onosproject.security.AppPermission.Type.TOPOLOGY_READ) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DEVICE_AVAILABILITY_CHANGED(org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED) Type(org.onosproject.net.Link.Type) DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceId(org.onosproject.net.DeviceId) EdgePortEvent(org.onosproject.net.edge.EdgePortEvent) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 ByteBuffer (java.nio.ByteBuffer)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 AbstractListenerManager (org.onosproject.event.AbstractListenerManager)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DeviceId (org.onosproject.net.DeviceId)1 Type (org.onosproject.net.Link.Type)1 DeviceEvent (org.onosproject.net.device.DeviceEvent)1 DEVICE_ADDED (org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED)1 DEVICE_AVAILABILITY_CHANGED (org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED)1 DEVICE_REMOVED (org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED)1 PORT_STATS_UPDATED (org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED)1 PORT_UPDATED (org.onosproject.net.device.DeviceEvent.Type.PORT_UPDATED)1 DeviceListener (org.onosproject.net.device.DeviceListener)1 DeviceService (org.onosproject.net.device.DeviceService)1 EdgePortEvent (org.onosproject.net.edge.EdgePortEvent)1