Changing PacketManager topology event processing logic to avoid
processing irrelevant events.
Change-Id: I82fdd5d492dfd1e04cd05564053c3ab05f0d10fb
diff --git a/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java b/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java
index ec783f0..bace763 100644
--- a/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java
+++ b/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java
@@ -117,7 +117,7 @@
private final List<ProcessorEntry> processors = Lists.newCopyOnWriteArrayList();
- private final PacketDriverProvider defaultProvider = new PacketDriverProvider();
+ private final PacketDriverProvider defaultProvider = new PacketDriverProvider();
private ApplicationId appId;
private NodeId localNodeId;
@@ -441,6 +441,13 @@
* Internal listener for device service events.
*/
private class InternalDeviceListener implements DeviceListener {
+
+ @Override
+ public boolean isRelevant(DeviceEvent event) {
+ return event.type() == DeviceEvent.Type.DEVICE_ADDED ||
+ event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED;
+ }
+
@Override
public void event(DeviceEvent event) {
eventHandlingExecutor.execute(() -> {
@@ -456,14 +463,7 @@
if (!deviceService.isAvailable(event.subject().id())) {
return;
}
- switch (event.type()) {
- case DEVICE_ADDED:
- case DEVICE_AVAILABILITY_CHANGED:
- pushRulesToDevice(device);
- break;
- default:
- break;
- }
+ pushRulesToDevice(device);
} catch (Exception e) {
log.warn("Failed to process {}", event, e);
}