From: Madhu Venugopal Date: Wed, 7 Aug 2013 05:27:20 +0000 (-0700) Subject: Process host pending list on a Cache sync update. X-Git-Tag: releasepom-0.1.0~222 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=6841bbe558146312e1568fc897a054e007a3ba45 Process host pending list on a Cache sync update. In a Clustered Controller environment, with switches connected to different controllers, ARP messages originated from a Controller may not see the ARP reply on the same controller. The ARP response from the Host might end up in another controller. Hence it is not appropriate to expect responses from host to terminate in the originating controller. discoverHost is one such method that has this wrong assumption. This fix is to listen to Active Cache update and trigger a Pending list processing (In addition to existing code that just waits on a Future object for ARP response on the local controller). Change-Id: I4223db66ff75bbf4d60011c9581e4dff594c0a9c Signed-off-by: Madhu Venugopal --- diff --git a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java index 65cb8225c8..e60b02d83b 100644 --- a/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java @@ -8,7 +8,13 @@ package org.opendaylight.controller.hosttracker.internal; +import java.util.Dictionary; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Set; + import org.apache.felix.dm.Component; +import org.opendaylight.controller.clustering.services.ICacheUpdateAware; import org.opendaylight.controller.clustering.services.IClusterContainerServices; import org.opendaylight.controller.hosttracker.IfHostListener; import org.opendaylight.controller.hosttracker.IfIptoHost; @@ -74,13 +80,19 @@ public class Activator extends ComponentActivatorAbstractBase { */ public void configureInstance(Component c, Object imp, String containerName) { if (imp.equals(HostTracker.class)) { + Dictionary props = new Hashtable(); + Set propSet = new HashSet(); + propSet.add(HostTracker.ACTIVE_HOST_CACHE); + props.put("cachenames", propSet); + // export the service c.setInterface( new String[] { ISwitchManagerAware.class.getName(), IInventoryListener.class.getName(), IfIptoHost.class.getName(), IfHostListener.class.getName(), - ITopologyManagerAware.class.getName() }, null); + ITopologyManagerAware.class.getName(), + ICacheUpdateAware.class.getName() }, props); c.add(createContainerServiceDependency(containerName) .setService(ISwitchManager.class) 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 0f07ff60af..3ff474732f 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 @@ -31,6 +31,7 @@ import java.util.concurrent.Future; import org.apache.felix.dm.Component; import org.opendaylight.controller.clustering.services.CacheConfigException; import org.opendaylight.controller.clustering.services.CacheExistException; +import org.opendaylight.controller.clustering.services.ICacheUpdateAware; import org.opendaylight.controller.clustering.services.IClusterContainerServices; import org.opendaylight.controller.clustering.services.IClusterServices; import org.opendaylight.controller.hosttracker.IfHostListener; @@ -79,7 +80,9 @@ import org.slf4j.LoggerFactory; */ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAware, IInventoryListener, - ITopologyManagerAware { + ITopologyManagerAware, ICacheUpdateAware { + static final String ACTIVE_HOST_CACHE = "hostTrackerAH"; + static final String INACTIVE_HOST_CACHE = "hostTrackerIH"; private static final Logger logger = LoggerFactory.getLogger(HostTracker.class); private IHostFinder hostFinder; private ConcurrentMap hostsDB; @@ -173,9 +176,9 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } logger.debug("Creating Cache for HostTracker"); try { - this.clusterContainerService.createCache("hostTrackerAH", + this.clusterContainerService.createCache(ACTIVE_HOST_CACHE, EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL)); - this.clusterContainerService.createCache("hostTrackerIH", + this.clusterContainerService.createCache(INACTIVE_HOST_CACHE, EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL)); } catch (CacheConfigException cce) { logger.error("Cache couldn't be created for HostTracker - check cache mode"); @@ -193,14 +196,14 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } logger.debug("Retrieving cache for HostTrackerAH"); hostsDB = (ConcurrentMap) this.clusterContainerService - .getCache("hostTrackerAH"); + .getCache(ACTIVE_HOST_CACHE); if (hostsDB == null) { logger.error("Cache couldn't be retrieved for HostTracker"); } logger.debug("Cache was successfully retrieved for HostTracker"); logger.debug("Retrieving cache for HostTrackerIH"); inactiveStaticHosts = (ConcurrentMap) this.clusterContainerService - .getCache("hostTrackerIH"); + .getCache(INACTIVE_HOST_CACHE); if (inactiveStaticHosts == null) { logger.error("Cache couldn't be retrieved for HostTrackerIH"); } @@ -401,7 +404,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } } - private void ProcPendingARPReqs(InetAddress networkAddr) { + private void processPendingARPReqs(InetAddress networkAddr) { ARPPending arphost; for (int i = 0; i < ARPPendingList.size(); i++) { @@ -469,7 +472,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw notifyHostLearnedOrRemoved(removedHost, false); notifyHostLearnedOrRemoved(newHost, true); if (!newHost.isStaticHost()) { - ProcPendingARPReqs(networkAddr); + processPendingARPReqs(networkAddr); } } @@ -520,7 +523,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } /* check if there is an outstanding request for this host */ - ProcPendingARPReqs(networkAddr); + processPendingARPReqs(networkAddr); notifyHostLearnedOrRemoved(host, true); } } @@ -1409,4 +1412,21 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } + @Override + public void entryCreated(InetAddress key, String cacheName, + boolean originLocal) { + if (originLocal) return; + processPendingARPReqs(key); + } + + @Override + public void entryUpdated(InetAddress key, HostNodeConnector new_value, + String cacheName, boolean originLocal) { + } + + @Override + public void entryDeleted(InetAddress key, String cacheName, + boolean originLocal) { + } + }