+ /**
+ * This method cross checks the determination of nodeConnector type by Discovery Service
+ * against the information in SwitchManager and updates it accordingly.
+ * @param e
+ * The edge
+ */
+ private void crossCheckNodeConnectors(Edge e) {
+ NodeConnector nc;
+ if (e.getHeadNodeConnector().getType().equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
+ nc = updateNCTypeFromSwitchMgr(e.getHeadNodeConnector());
+ if (nc != null) {
+ e.setHeadNodeConnector(nc);
+ }
+ }
+ if (e.getTailNodeConnector().getType().equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
+ nc = updateNCTypeFromSwitchMgr(e.getTailNodeConnector());
+ if (nc != null) {
+ e.setTailNodeConnector(nc);
+ }
+ }
+ }
+
+ /**
+ * A NodeConnector may have been categorized as of type Production by Discovery Service.
+ * But at the time when this determination was made, only OF nodes were known to Discovery
+ * Service. This method checks if the node of nodeConnector is known to SwitchManager. If
+ * so, then it returns a new NodeConnector with correct type.
+ *
+ * @param nc
+ * NodeConnector as passed on in the edge
+ * @return
+ * If Node of the NodeConnector is in SwitchManager, then return a new NodeConnector
+ * with correct type, null otherwise
+ */
+
+ private NodeConnector updateNCTypeFromSwitchMgr(NodeConnector nc) {
+
+ for (Node node : switchManager.getNodes()) {
+ String nodeName = node.getNodeIDString();
+ log.trace("Switch Manager Node Name: {}, NodeConnector Node Name: {}", nodeName,
+ nc.getNode().getNodeIDString());
+ if (nodeName.equals(nc.getNode().getNodeIDString())) {
+ NodeConnector nodeConnector = NodeConnectorCreator
+ .createNodeConnector(node.getType(), nc.getID(), node);
+ return nodeConnector;
+ }
+ }
+ return null;
+ }
+