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=4fa4da318a2f67f645bad1d92255899fd8875937;hp=aa1c8592d9225f997d7906e7dbb3e679b5f0f270;hb=cafd50eb82c5bb862d16b8f25a0a6bea983732f4;hpb=aa1542461e6a76e5ad8171fa993a5d65522b0491 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 aa1c8592d9..4fa4da318a 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; @@ -147,7 +150,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw * * We can't recover from condition 3 above */ - private final ArrayList failedARPReqList = new ArrayList(); + private final List failedARPReqList = new ArrayList(); public HostTracker() { } @@ -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); } } @@ -781,10 +784,8 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw private void updateCurrentHierarchy(Node node, ArrayList currHierarchy, List> fullHierarchy) { // currHierarchy.add(String.format("%x", currSw.getId())); currHierarchy.add(dpidToHostNameHack((Long) node.getID())); - ArrayList currHierarchyClone = (ArrayList) currHierarchy.clone(); // Shallow - // copy - // as - // required + // Shallow copy as required + ArrayList currHierarchyClone = (ArrayList) currHierarchy.clone(); Map> ndlinks = topologyManager.getNodeEdges(); if (ndlinks == null) { @@ -806,14 +807,27 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw Node dstNode = lt.getHeadNodeConnector().getNode(); Tier nodeTier = (Tier) switchManager.getNodeProp(node, Tier.TierPropName); + /* + * If the host is directly attached to the src node, then the node + * should have been assigned the "Access" tier in + * notifyHostLearnedOrRemoved. If not, it would be assigned + * "Unknown" tier. Thus the tier of host attached node cannot be + * null. If the src node here, is the next node in the hierarchy of + * the nodes, then its tier cannot be null + */ + Tier dstNodeTier = (Tier) switchManager.getNodeProp(dstNode, Tier.TierPropName); + /* + * Skip if the tier of the destination node is null + */ + if (dstNodeTier == null) { + continue; + } if (dstNodeTier.getValue() > nodeTier.getValue()) { ArrayList buildHierarchy = currHierarchy; if (currHierarchy.size() > currHierarchyClone.size()) { - buildHierarchy = (ArrayList) currHierarchyClone.clone(); // Shallow - // copy - // as - // required + // Shallow copy as required + buildHierarchy = (ArrayList) currHierarchyClone.clone(); fullHierarchy.add(buildHierarchy); } updateCurrentHierarchy(dstNode, buildHierarchy, fullHierarchy); @@ -821,7 +835,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } } - private void edgeUpdate(Edge e, UpdateType type, Set props) { + private void debugEdgeUpdate(Edge e, UpdateType type, Set props) { Long srcNid = null; Short srcPort = null; Long dstNid = null; @@ -843,7 +857,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } if (!srcType.equals(NodeConnector.NodeConnectorIDType.OPENFLOW)) { - logger.error("For now we cannot handle updates for " + "non-openflow nodes"); + logger.debug("For now we cannot handle updates for non-openflow nodes"); return; } @@ -853,7 +867,7 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw } if (!dstType.equals(NodeConnector.NodeConnectorIDType.OPENFLOW)) { - logger.error("For now we cannot handle updates for " + "non-openflow nodes"); + logger.debug("For now we cannot handle updates for non-openflow nodes"); return; } @@ -881,11 +895,14 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw @Override public void edgeUpdate(List topoedgeupdateList) { - for (int i = 0; i < topoedgeupdateList.size(); i++) { - Edge e = topoedgeupdateList.get(i).getEdge(); - Set p = topoedgeupdateList.get(i).getProperty(); - UpdateType type = topoedgeupdateList.get(i).getUpdateType(); - edgeUpdate(e, type, p); + if (logger.isDebugEnabled()) { + for (TopoEdgeUpdate topoEdgeUpdate : topoedgeupdateList) { + Edge e = topoEdgeUpdate.getEdge(); + Set p = topoEdgeUpdate.getProperty(); + UpdateType type = topoEdgeUpdate.getUpdateType(); + + debugEdgeUpdate(e, type, p); + } } } @@ -1406,4 +1423,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) { + } + }