X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Ftopologymanager%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Ftopologymanager%2Finternal%2FTopologyManagerImpl.java;h=7452abbbb4af7952ae7b569b36d1498bb51f0dfe;hb=refs%2Fchanges%2F56%2F1656%2F4;hp=5a38ecd4a61db131623b1e56efef7849bbba2800;hpb=72fae1984afe741a93435269545f0346671cf305;p=controller.git diff --git a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java index 5a38ecd4a6..7452abbbb4 100644 --- a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java +++ b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java @@ -20,7 +20,6 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ConcurrentHashMap; @@ -70,7 +69,7 @@ import org.slf4j.LoggerFactory; * topology database and notifies all the listeners of topology changes. */ public class TopologyManagerImpl implements - ICacheUpdateAware, + ICacheUpdateAware, ITopologyManager, IConfigurationContainerAware, IListenTopoUpdates, @@ -116,14 +115,6 @@ public class TopologyManagerImpl implements if (this.topologyManagerAware != null) { log.debug("Adding ITopologyManagerAware: {}", s); this.topologyManagerAware.add(s); - // Reply all the known edges - if (this.edgesDB != null) { - List existingEdges = new ArrayList(); - for (Entry> entry : this.edgesDB.entrySet()) { - existingEdges.add(new TopoEdgeUpdate(entry.getKey(), entry.getValue(), UpdateType.ADDED)); - } - s.edgeUpdate(existingEdges); - } } } @@ -138,14 +129,6 @@ public class TopologyManagerImpl implements if (this.topologyManagerClusterWideAware != null) { log.debug("Adding ITopologyManagerClusterWideAware: {}", s); this.topologyManagerClusterWideAware.add(s); - // Reply all the known edges - if (this.edgesDB != null) { - List existingEdges = new ArrayList(); - for (Entry> entry : this.edgesDB.entrySet()) { - existingEdges.add(new TopoEdgeUpdate(entry.getKey(), entry.getValue(), UpdateType.ADDED)); - } - s.edgeUpdate(existingEdges); - } } } @@ -217,7 +200,7 @@ public class TopologyManagerImpl implements notifyThread = new Thread(new TopologyNotify(notifyQ)); } - @SuppressWarnings({ "unchecked", "deprecation" }) + @SuppressWarnings({ "unchecked" }) private void allocateCaches() { try { this.edgesDB = @@ -260,7 +243,7 @@ public class TopologyManagerImpl implements } } - @SuppressWarnings({ "unchecked", "deprecation" }) + @SuppressWarnings({ "unchecked" }) private void retrieveCaches() { if (this.clusterContainerService == null) { log.error("Cluster Services is null, can't retrieve caches."); @@ -538,18 +521,29 @@ public class TopologyManagerImpl implements } } - private boolean nodeConnectorsExist(Edge e) { + private boolean headNodeConnectorExist(Edge e) { + /* + * Only check the head end point which is supposed to be part of a + * network node we control (present in our inventory). If we checked the + * tail end point as well, we would not store the edges that connect to + * a non sdn enable port on a non sdn capable production switch. We want + * to be able to see these switches on the topology. + */ NodeConnector head = e.getHeadNodeConnector(); - NodeConnector tail = e.getTailNodeConnector(); - return (switchManager.doesNodeConnectorExist(head) && - switchManager.doesNodeConnectorExist(tail)); + return (switchManager.doesNodeConnectorExist(head)); } private TopoEdgeUpdate edgeUpdate(Edge e, UpdateType type, Set props) { switch (type) { case ADDED: - // Ensure that both tail and head node connectors exist. - if (!nodeConnectorsExist(e)) { + // Avoid redundant update as notifications trigger expensive tasks + if (edgesDB.containsKey(e)) { + log.trace("Skipping redundant edge addition: {}", e); + return null; + } + + // Ensure that head node connector exists + if (!headNodeConnectorExist(e)) { log.warn("Ignore edge that contains invalid node connector: {}", e); return null; } @@ -913,7 +907,7 @@ public class TopologyManagerImpl implements public void entryUpdated(final Object key, final Object new_value, final String cacheName, final boolean originLocal) { if (cacheName.equals(TOPOEDGESDB)) { final Edge e = (Edge) key; - log.trace("Edge {} CHANGED isLocal:{}", e, originLocal); + log.trace("Edge {} UPDATED isLocal:{}", e, originLocal); final Set props = (Set) new_value; edgeUpdateClusterWide(e, UpdateType.CHANGED, props, originLocal); }