X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fhosttracker%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fhosttracker%2Finternal%2FHostTracker.java;h=f728b35bbfa7f492c3937b87616e4b655ba3f16f;hp=734a392bc121f7b33a20408908a3281193aec2aa;hb=475d28f717bae92b2cc10b0589131771fcc62242;hpb=94d0d20b41d64bb6696c2a573ec367fcfddc44e9 diff --git a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java index 734a392bc1..f728b35bbf 100644 --- a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java @@ -39,6 +39,7 @@ import org.opendaylight.controller.clustering.services.IClusterContainerServices import org.opendaylight.controller.clustering.services.IClusterServices; import org.opendaylight.controller.hosttracker.HostIdFactory; import org.opendaylight.controller.hosttracker.IHostId; +import org.opendaylight.controller.hosttracker.IHostTrackerShell; import org.opendaylight.controller.hosttracker.IPHostId; import org.opendaylight.controller.hosttracker.IPMacHostId; import org.opendaylight.controller.hosttracker.IfHostListener; @@ -100,12 +101,12 @@ import org.slf4j.LoggerFactory; * */ -public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAware, IInventoryListener, +public class HostTracker implements IfIptoHost, IfHostListener, IHostTrackerShell, ISwitchManagerAware, IInventoryListener, ITopologyManagerAware, ICacheUpdateAware, CommandProvider { static final String ACTIVE_HOST_CACHE = "hosttracker.ActiveHosts"; static final String INACTIVE_HOST_CACHE = "hosttracker.InactiveHosts"; private static final Logger logger = LoggerFactory.getLogger(HostTracker.class); - protected final Set hostFinder = new CopyOnWriteArraySet();; + protected final Set hostFinders = new CopyOnWriteArraySet(); protected ConcurrentMap hostsDB; /* * Following is a list of hosts which have been requested by NB APIs to be @@ -256,16 +257,12 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } public void setArpHandler(IHostFinder hostFinder) { - if (this.hostFinder != null) { - this.hostFinder.add(hostFinder); - } + this.hostFinders.add(hostFinder); } public void unsetArpHandler(IHostFinder hostFinder) { - if (this.hostFinder != null) { - logger.debug("Arp Handler Service removed!"); - this.hostFinder.remove(hostFinder); - } + logger.debug("Arp Handler Service removed!"); + this.hostFinders.remove(hostFinder); } public void setTopologyManager(ITopologyManager s) { @@ -352,8 +349,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw * already handles the null return */ - if (hostFinder == null) { - logger.debug("Exiting hostFind, null hostFinder"); + if (hostFinders.isEmpty()) { + logger.debug("No available host finders, exiting hostFind()"); return null; } @@ -369,7 +366,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw logger.debug("hostFind(): Host Not Found for IP: {}, Inititated Host Discovery ...", id); /* host is not found, initiate a discovery */ - for (IHostFinder hf : hostFinder) { + for (IHostFinder hf : hostFinders) { InetAddress addr = decodeIPFromId(id); hf.find(addr); } @@ -936,12 +933,12 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw for (Entry entry : failedARPReqList.entrySet()) { ARPPending arphost; arphost = entry.getValue(); - if (hostFinder == null) { - logger.warn("ARPHandler Services are not available on subnet addition"); + if (hostFinders.isEmpty()) { + logger.debug("ARPHandler Services are not available on subnet addition"); continue; } logger.debug("Sending the ARP from FailedARPReqList fors IP: {}", decodeIPFromId(arphost.getHostId())); - for (IHostFinder hf : hostFinder) { + for (IHostFinder hf : hostFinders) { hf.find(decodeIPFromId(arphost.getHostId())); } } @@ -977,11 +974,11 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw * next one. Before sending the ARP, check if ARPHandler * is available or not */ - if (hostFinder == null) { + if (hostFinders.isEmpty()) { logger.warn("ARPHandler Services are not available for Outstanding ARPs"); continue; } - for (IHostFinder hf : hostFinder) { + for (IHostFinder hf : hostFinders) { hf.find(decodeIPFromId(arphost.getHostId())); } arphost.sent_count++; @@ -1063,7 +1060,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw HexEncode.bytesToHexString(host.getDataLayerAddressBytes()) }); } host.setArpSendCountDown(arp_cntdown); - if (hostFinder == null) { + if (hostFinders.isEmpty()) { /* * If hostfinder is not available, then can't send * the probe. However, continue the age out the @@ -1073,7 +1070,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw logger.trace("ARPHandler is not avaialable, can't send the probe"); continue; } - for (IHostFinder hf : hostFinder) { + for (IHostFinder hf : hostFinders) { hf.probe(host); } } @@ -1417,7 +1414,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw for (Entry entry : failedARPReqList.entrySet()) { arphost = entry.getValue(); logger.trace("Sending the ARP from FailedARPReqList fors IP: {}", arphost.getHostId()); - if (hostFinder == null) { + if (hostFinders.isEmpty()) { logger.warn("ARPHandler is not available at interface up"); logger.warn("Since this event is missed, host(s) connected to interface {} may not be discovered", nodeConnector); @@ -1430,7 +1427,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw byte[] dataLayerAddress = NetUtils.getBroadcastMACAddr(); host = new HostNodeConnector(dataLayerAddress, decodeIPFromId(arphost.getHostId()), nodeConnector, (short) 0); - for (IHostFinder hf : hostFinder) { + for (IHostFinder hf : hostFinders) { hf.probe(host); } } catch (ConstructionException e) { @@ -1622,4 +1619,24 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw IHostId id = HostIdFactory.create(addr, null); return getHostNetworkHierarchy(id); } + + @Override + public List dumpPendingArpReqList() { + ARPPending arphost; + List arpReq = new ArrayList(); + for (Entry entry : ARPPendingList.entrySet()) { + arpReq.add(entry.getValue().getHostId().toString()); + } + return arpReq; + } + + @Override + public List dumpFailedArpReqList() { + ARPPending arphost; + List arpReq = new ArrayList(); + for (Entry entry : failedARPReqList.entrySet()) { + arpReq.add(entry.getValue().getHostId().toString()); + } + return arpReq; + } }