X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fhosttracker_new%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fhosttracker%2Finternal%2FDeviceManagerImpl.java;h=0a70b72575dca0ca05bb0b599ed1ce88679e64e4;hb=refs%2Fchanges%2F84%2F484%2F2;hp=bda13723113aac7ade179a6804a7b1f655b7d59d;hpb=c90c2ca43006e023005a5dddbbb477f80329e45c;p=controller.git diff --git a/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java b/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java index bda1372311..0a70b72575 100755 --- a/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java +++ b/opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java @@ -67,6 +67,7 @@ import org.opendaylight.controller.hosttracker.IEntityClass; import org.opendaylight.controller.hosttracker.IEntityClassListener; import org.opendaylight.controller.hosttracker.IEntityClassifierService; import org.opendaylight.controller.hosttracker.IfIptoHost; +import org.opendaylight.controller.hosttracker.IfNewHostNotify; import org.opendaylight.controller.hosttracker.SwitchPort; import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; import org.opendaylight.controller.sal.core.Edge; @@ -290,6 +291,10 @@ public class DeviceManagerImpl implements IDeviceService, IEntityClassListener, */ protected ListenerDispatcher deviceListeners; + /** + * Using the IfNewHostNotify to notify listeners of host changes. + */ + private Set newHostNotify = Collections.synchronizedSet(new HashSet()); /** * A device update event to be dispatched */ @@ -429,6 +434,14 @@ public class DeviceManagerImpl implements IDeviceService, IEntityClassListener, // Dependency injection // ******************** + void setNewHostNotify(IfNewHostNotify obj){ + this.newHostNotify.add(obj); + } + + void unsetNewHostNotify(IfNewHostNotify obj){ + this.newHostNotify.remove(obj); + } + void setDataPacketService(IDataPacketService s) { this.dataPacketService = s; } @@ -780,11 +793,11 @@ public class DeviceManagerImpl implements IDeviceService, IEntityClassListener, if (inPkt == null) { return PacketResult.IGNORED; } - try { - throw new Exception("Sample"); - } catch (Exception e) { - logger.error("Sample stack trace", e); - } +// try { +// throw new Exception("Sample"); +// } catch (Exception e) { +// logger.error("Sample stack trace", e); +// } Packet formattedPak = this.dataPacketService.decodeDataPacket(inPkt); Ethernet eth; @@ -1444,9 +1457,28 @@ public class DeviceManagerImpl implements IDeviceService, IEntityClassListener, protected void notifyListeners(List listeners, DeviceUpdate update) { - if (listeners == null) { + if (listeners == null && newHostNotify.isEmpty()) { return; } + /** + * TODO: IfNewHostNotify is needed for current controller API. + * Adding logic so that existing apps (like SimpleForwardingManager) + * work. IDeviceListener adds additional methods and uses IListener's + * callback ordering. The two interfaces need to be merged. + */ + + for (IfNewHostNotify notify : newHostNotify){ + switch (update.change) { + case ADD: + notify.notifyHTClient(update.device.toHostNodeConnector()); + break; + } + } + + /** + * TODO: Remove this section as IDeviceListener functionality gets + * merged with IfNewHostNotify + */ for (IDeviceListener listener : listeners) { switch (update.change) { case ADD: