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=b905a8982e83113e10b23261ab2d3045f1142c54;hb=6fda9993ad4fb9e0ac911543bbd87b7cd0eb1b0f;hp=004d1b98db3eff61292937888a6fa34b1f9a4ee6;hpb=9411770e514bb0c5a65f96dc9deb7a87a9ea86ad;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 004d1b98db..b905a8982e 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 @@ -53,6 +53,7 @@ import org.opendaylight.controller.sal.utils.ObjectReader; import org.opendaylight.controller.sal.utils.ObjectWriter; import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; +import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.topologymanager.ITopologyManager; import org.opendaylight.controller.topologymanager.ITopologyManagerAware; import org.opendaylight.controller.topologymanager.ITopologyManagerClusterWideAware; @@ -79,9 +80,9 @@ public class TopologyManagerImpl implements static final String TOPONODECONNECTORDB = "topologymanager.nodeConnectorDB"; static final String TOPOUSERLINKSDB = "topologymanager.userLinksDB"; private static final Logger log = LoggerFactory.getLogger(TopologyManagerImpl.class); - private static final String SAVE = "Save"; private ITopologyService topoService; private IClusterContainerServices clusterContainerService; + private ISwitchManager switchManager; // DB of all the Edges with properties which constitute our topology private ConcurrentMap> edgesDB; // DB of all NodeConnector which are part of ISL Edges, meaning they @@ -162,6 +163,18 @@ public class TopologyManagerImpl implements } } + void setSwitchManager(ISwitchManager s) { + log.debug("Adding ISwitchManager: {}", s); + this.switchManager = s; + } + + void unsetSwitchManager(ISwitchManager s) { + if (this.switchManager == s) { + log.debug("Removing ISwitchManager: {}", s); + this.switchManager = null; + } + } + /** * Function called by the dependency manager when all the required * dependencies are satisfied @@ -508,9 +521,22 @@ public class TopologyManagerImpl implements } } + private boolean nodeConnectorsExist(Edge e) { + NodeConnector head = e.getHeadNodeConnector(); + NodeConnector tail = e.getTailNodeConnector(); + return (switchManager.doesNodeConnectorExist(head) && + switchManager.doesNodeConnectorExist(tail)); + } + 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)) { + log.warn("Ignore edge that contains invalid node connector: {}", e); + return null; + } + // Make sure the props are non-null if (props == null) { props = new HashSet(); @@ -632,18 +658,21 @@ public class TopologyManagerImpl implements Set p = topoedgeupdateList.get(i).getProperty(); UpdateType type = topoedgeupdateList.get(i).getUpdateType(); TopoEdgeUpdate teu = edgeUpdate(e, type, p); - teuList.add(teu); + if (teu != null) { + teuList.add(teu); + } } - // Now update the listeners - for (ITopologyManagerAware s : this.topologyManagerAware) { - try { - s.edgeUpdate(teuList); - } catch (Exception exc) { - log.error("Exception on edge update:", exc); + if (!teuList.isEmpty()) { + // Now update the listeners + for (ITopologyManagerAware s : this.topologyManagerAware) { + try { + s.edgeUpdate(teuList); + } catch (Exception exc) { + log.error("Exception on edge update:", exc); + } } } - } private Edge getReverseLinkTuple(TopologyUserLinkConfig link) { @@ -693,7 +722,14 @@ public class TopologyManagerImpl implements Edge linkTuple = getLinkTuple(userLink); if (linkTuple != null) { if (!isProductionLink(linkTuple)) { - edgeUpdate(linkTuple, UpdateType.ADDED, new HashSet()); + TopoEdgeUpdate teu = edgeUpdate(linkTuple, UpdateType.ADDED, + new HashSet()); + if (teu == null) { + userLinksDB.remove(userLink.getName()); + return new Status(StatusCode.NOTFOUND, + "Link configuration contains invalid node connector: " + + userLink); + } } linkTuple = getReverseLinkTuple(userLink); @@ -918,10 +954,10 @@ public class TopologyManagerImpl implements // Lets sleep for sometime to allow aggregation of event Thread.sleep(100); } catch (InterruptedException e1) { - log.warn("TopologyNotify interrupted {}", e1.getMessage()); if (shuttingDown) { return; } + log.warn("TopologyNotify interrupted {}", e1.getMessage()); } catch (Exception e2) { log.error("", e2); }