alshabib
Committed by Gerrit Code Review

NullHostProvider does not report hosts for device the local instance is not master for

Change-Id: I41fbeb1d9fa9be48792a7f223481e42c27e02d72
...@@ -26,6 +26,7 @@ import org.onosproject.net.Device; ...@@ -26,6 +26,7 @@ import org.onosproject.net.Device;
26 import org.onosproject.net.Host; 26 import org.onosproject.net.Host;
27 import org.onosproject.net.HostId; 27 import org.onosproject.net.HostId;
28 import org.onosproject.net.HostLocation; 28 import org.onosproject.net.HostLocation;
29 +import org.onosproject.net.MastershipRole;
29 import org.onosproject.net.PortNumber; 30 import org.onosproject.net.PortNumber;
30 import org.onosproject.net.device.DeviceEvent; 31 import org.onosproject.net.device.DeviceEvent;
31 import org.onosproject.net.device.DeviceListener; 32 import org.onosproject.net.device.DeviceListener;
...@@ -129,6 +130,11 @@ public class NullHostProvider extends AbstractProvider implements HostProvider { ...@@ -129,6 +130,11 @@ public class NullHostProvider extends AbstractProvider implements HostProvider {
129 private class InternalHostProvider implements DeviceListener { 130 private class InternalHostProvider implements DeviceListener {
130 @Override 131 @Override
131 public void event(DeviceEvent event) { 132 public void event(DeviceEvent event) {
133 + if (!deviceService.getRole(event.subject().id())
134 + .equals(MastershipRole.MASTER)) {
135 + log.info("Local node is not master for device", event.subject().id());
136 + return;
137 + }
132 switch (event.type()) { 138 switch (event.type()) {
133 139
134 case DEVICE_ADDED: 140 case DEVICE_ADDED:
......