link provider cleanup
Change-Id: Ifeedfbfc20e3d75b140ee73f7479cd18bcb84adf
Showing
2 changed files
with
19 additions
and
22 deletions
| ... | @@ -8,6 +8,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -8,6 +8,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 8 | import org.onlab.onos.net.ConnectPoint; | 8 | import org.onlab.onos.net.ConnectPoint; |
| 9 | import org.onlab.onos.net.Device; | 9 | import org.onlab.onos.net.Device; |
| 10 | import org.onlab.onos.net.DeviceId; | 10 | import org.onlab.onos.net.DeviceId; |
| 11 | +import org.onlab.onos.net.Port; | ||
| 11 | import org.onlab.onos.net.device.DeviceEvent; | 12 | import org.onlab.onos.net.device.DeviceEvent; |
| 12 | import org.onlab.onos.net.device.DeviceListener; | 13 | import org.onlab.onos.net.device.DeviceListener; |
| 13 | import org.onlab.onos.net.device.DeviceService; | 14 | import org.onlab.onos.net.device.DeviceService; |
| ... | @@ -90,53 +91,50 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -90,53 +91,50 @@ public class LLDPLinkProvider extends AbstractProvider implements LinkProvider { |
| 90 | public void event(DeviceEvent event) { | 91 | public void event(DeviceEvent event) { |
| 91 | LinkDiscovery ld = null; | 92 | LinkDiscovery ld = null; |
| 92 | Device device = event.subject(); | 93 | Device device = event.subject(); |
| 93 | - // it's not a switch so leave. | 94 | + Port port = event.port(); |
| 94 | - if (device.type() != Device.Type.SWITCH) { | ||
| 95 | - return; | ||
| 96 | - } | ||
| 97 | switch (event.type()) { | 95 | switch (event.type()) { |
| 98 | case DEVICE_ADDED: | 96 | case DEVICE_ADDED: |
| 99 | - discoverers.put(event.subject().id(), | 97 | + discoverers.put(device.id(), |
| 100 | - new LinkDiscovery(event.subject(), packetSevice, | 98 | + new LinkDiscovery(device, packetSevice, |
| 101 | providerService, useBDDP)); | 99 | providerService, useBDDP)); |
| 102 | break; | 100 | break; |
| 103 | case PORT_ADDED: | 101 | case PORT_ADDED: |
| 104 | case PORT_UPDATED: | 102 | case PORT_UPDATED: |
| 105 | if (event.port().isEnabled()) { | 103 | if (event.port().isEnabled()) { |
| 106 | - ld = discoverers.get(event.subject().id()); | 104 | + ld = discoverers.get(device.id()); |
| 107 | if (ld == null) { | 105 | if (ld == null) { |
| 108 | return; | 106 | return; |
| 109 | } | 107 | } |
| 110 | - ld.addPort(event.port()); | 108 | + ld.addPort(port); |
| 111 | } else { | 109 | } else { |
| 112 | - ConnectPoint point = new ConnectPoint(event.subject().id(), | 110 | + ConnectPoint point = new ConnectPoint(device.id(), |
| 113 | - event.port().number()); | 111 | + port.number()); |
| 114 | providerService.linksVanished(point); | 112 | providerService.linksVanished(point); |
| 115 | } | 113 | } |
| 116 | break; | 114 | break; |
| 117 | case PORT_REMOVED: | 115 | case PORT_REMOVED: |
| 118 | - ConnectPoint point = new ConnectPoint(event.subject().id(), | 116 | + ConnectPoint point = new ConnectPoint(device.id(), |
| 119 | - event.port().number()); | 117 | + port.number()); |
| 120 | providerService.linksVanished(point); | 118 | providerService.linksVanished(point); |
| 121 | break; | 119 | break; |
| 122 | case DEVICE_REMOVED: | 120 | case DEVICE_REMOVED: |
| 123 | case DEVICE_SUSPENDED: | 121 | case DEVICE_SUSPENDED: |
| 124 | - ld = discoverers.get(event.subject().id()); | 122 | + ld = discoverers.get(device.id()); |
| 125 | if (ld == null) { | 123 | if (ld == null) { |
| 126 | return; | 124 | return; |
| 127 | } | 125 | } |
| 128 | ld.stop(); | 126 | ld.stop(); |
| 129 | - providerService.linksVanished(event.subject().id()); | 127 | + providerService.linksVanished(device.id()); |
| 130 | break; | 128 | break; |
| 131 | case DEVICE_AVAILABILITY_CHANGED: | 129 | case DEVICE_AVAILABILITY_CHANGED: |
| 132 | - ld = discoverers.get(event.subject().id()); | 130 | + ld = discoverers.get(device.id()); |
| 133 | if (ld == null) { | 131 | if (ld == null) { |
| 134 | return; | 132 | return; |
| 135 | } | 133 | } |
| 136 | - if (deviceService.isAvailable(event.subject().id())) { | 134 | + if (deviceService.isAvailable(device.id())) { |
| 137 | ld.start(); | 135 | ld.start(); |
| 138 | } else { | 136 | } else { |
| 139 | - providerService.linksVanished(event.subject().id()); | 137 | + providerService.linksVanished(device.id()); |
| 140 | ld.stop(); | 138 | ld.stop(); |
| 141 | } | 139 | } |
| 142 | break; | 140 | break; | ... | ... |
| ... | @@ -184,14 +184,13 @@ public class LinkDiscovery implements TimerTask { | ... | @@ -184,14 +184,13 @@ public class LinkDiscovery implements TimerTask { |
| 184 | this.slowPorts.remove(portNumber); | 184 | this.slowPorts.remove(portNumber); |
| 185 | this.fastPorts.add(portNumber); | 185 | this.fastPorts.add(portNumber); |
| 186 | this.portProbeCount.put(portNumber, new AtomicInteger(0)); | 186 | this.portProbeCount.put(portNumber, new AtomicInteger(0)); |
| 187 | - } else { | 187 | + } else if (this.fastPorts.contains(portNumber)) { |
| 188 | - if (this.fastPorts.contains(portNumber)) { | ||
| 189 | this.portProbeCount.get(portNumber).set(0); | 188 | this.portProbeCount.get(portNumber).set(0); |
| 190 | - } else { | 189 | + } else { |
| 191 | this.log.debug( | 190 | this.log.debug( |
| 192 | "Got ackProbe for non-existing port: {}", | 191 | "Got ackProbe for non-existing port: {}", |
| 193 | portNumber); | 192 | portNumber); |
| 194 | - } | 193 | + |
| 195 | } | 194 | } |
| 196 | } | 195 | } |
| 197 | } | 196 | } |
| ... | @@ -256,7 +255,7 @@ public class LinkDiscovery implements TimerTask { | ... | @@ -256,7 +255,7 @@ public class LinkDiscovery implements TimerTask { |
| 256 | //fastIterator.remove(); | 255 | //fastIterator.remove(); |
| 257 | //this.slowPorts.add(portNumber); | 256 | //this.slowPorts.add(portNumber); |
| 258 | //this.portProbeCount.remove(portNumber); | 257 | //this.portProbeCount.remove(portNumber); |
| 259 | - | 258 | + this.portProbeCount.get(portNumber).set(0); |
| 260 | 259 | ||
| 261 | ConnectPoint cp = new ConnectPoint( | 260 | ConnectPoint cp = new ConnectPoint( |
| 262 | device.id(), | 261 | device.id(), | ... | ... |
-
Please register or login to post a comment