X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Finternal%2FInventoryServiceShim.java;h=2b26ecb749447aa3e31648c3d425f641a11a82e2;hb=d2dee665ba9bae793447fc92e2cbcea5f50565cd;hp=15bba670d2a7b9e4387317e91f12e50e18cb5e29;hpb=534f0620272df6bfb9f7d26960f2cd0db895cfc9;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java index 15bba670d2..2b26ecb749 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.protocol_plugin.openflow.internal; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -26,8 +27,9 @@ import org.opendaylight.controller.protocol_plugin.openflow.core.IController; import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener; import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch; import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitchStateListener; +import org.opendaylight.controller.sal.action.SupportedFlowActions; +import org.opendaylight.controller.sal.connection.ConnectionLocality; import org.opendaylight.controller.sal.connection.IPluginOutConnectionService; -import org.opendaylight.controller.sal.core.Actions; import org.opendaylight.controller.sal.core.Buffers; import org.opendaylight.controller.sal.core.Capabilities; import org.opendaylight.controller.sal.core.ContainerFlow; @@ -237,6 +239,7 @@ public class InventoryServiceShim implements IContainerListener, @Override public void switchAdded(ISwitch sw) { if (sw == null) { + logger.debug("Ignore null switch addition"); return; } Node node = NodeCreator.createOFNode(sw.getId()); @@ -245,22 +248,32 @@ public class InventoryServiceShim implements IContainerListener, return; } - // Add all the nodeConnectors of this switch - Map> ncProps = InventoryServiceHelper - .OFSwitchToProps(sw); - for (Map.Entry> entry : ncProps.entrySet()) { - Set props = new HashSet(); - Set prop = entry.getValue(); - if (prop != null) { - props.addAll(prop); + // Add all the nodeConnectors of this switch if any + Map> ncProps = InventoryServiceHelper.OFSwitchToProps(sw); + if (!ncProps.isEmpty()) { + for (Map.Entry> entry : ncProps.entrySet()) { + Set props = new HashSet(); + Set prop = entry.getValue(); + if (prop != null) { + props.addAll(prop); + } + nodeConnectorProps.put(entry.getKey(), props); + notifyInventoryShimListener(entry.getKey(), UpdateType.ADDED, entry.getValue()); } - nodeConnectorProps.put(entry.getKey(), props); - notifyInventoryShimListener(entry.getKey(), UpdateType.ADDED, - entry.getValue()); + } else { + /* + * If no node connector is present, publish the node addition itself + * in order to let Connection Manager properly set the node locality + */ + this.notifyInventoryShimListener(node, UpdateType.ADDED, Collections.emptySet()); } // Add this node - addNode(sw); + if (connectionOutService.getLocalityStatus(node) != ConnectionLocality.NOT_CONNECTED) { + addNode(sw); + } else { + logger.debug("Skipping node addition due to Connectivity Status : {}", connectionOutService.getLocalityStatus(node).name()); + } } @Override @@ -357,15 +370,13 @@ public class InventoryServiceShim implements IContainerListener, } } - private void notifyInventoryShimExternalListener(Node node, - UpdateType type, Set props) { + private void notifyInventoryShimExternalListener(Node node, UpdateType type, Set props) { for (IInventoryShimExternalListener s : this.inventoryShimExternalListeners) { s.updateNode(node, type, props); } } - private void notifyInventoryShimExternalListener( - NodeConnector nodeConnector, UpdateType type, Set props) { + private void notifyInventoryShimExternalListener(NodeConnector nodeConnector, UpdateType type, Set props) { for (IInventoryShimExternalListener s : this.inventoryShimExternalListeners) { s.updateNodeConnector(nodeConnector, type, props); } @@ -373,14 +384,11 @@ public class InventoryServiceShim implements IContainerListener, private void notifyInventoryShimInternalListener(String container, NodeConnector nodeConnector, UpdateType type, Set props) { - IInventoryShimInternalListener inventoryShimInternalListener = inventoryShimInternalListeners - .get(container); + IInventoryShimInternalListener inventoryShimInternalListener = inventoryShimInternalListeners.get(container); if (inventoryShimInternalListener != null) { - inventoryShimInternalListener.updateNodeConnector(nodeConnector, - type, props); - logger.trace( - "notifyInventoryShimInternalListener {} type {} for container {}", - new Object[] { nodeConnector, type, container }); + inventoryShimInternalListener.updateNodeConnector(nodeConnector, type, props); + logger.trace("notifyInventoryShimInternalListener {} type {} for container {}", new Object[] { + nodeConnector, type, container }); } } @@ -409,7 +417,7 @@ public class InventoryServiceShim implements IContainerListener, notifyInventoryShimInternalListener(container, nodeConnector, type, props); } - // Notify DiscoveryService + // Notify plugin listeners (Discovery, DataPacket, OFstats etc.) notifyInventoryShimExternalListener(nodeConnector, type, props); logger.debug("Connection service accepted the inventory notification for {} {}", nodeConnector, type); @@ -436,13 +444,14 @@ public class InventoryServiceShim implements IContainerListener, if (isNodeLocal) { // Now notify other containers - Set containers = (nodeContainerMap.get(node) == null) ? new HashSet() : new HashSet( - nodeContainerMap.get(node)); + Set containers = (nodeContainerMap.get(node) == null) ? new HashSet() + : new HashSet(nodeContainerMap.get(node)); containers.add(GlobalConstants.DEFAULT.toString()); for (String container : containers) { notifyInventoryShimInternalListener(container, node, type, props); } - // Notify external listener + + // Notify plugin listeners (Discovery, DataPacket, OFstats etc.) notifyInventoryShimExternalListener(node, type, props); logger.debug("Connection service accepted the inventory notification for {} {}", node, type); @@ -454,9 +463,7 @@ public class InventoryServiceShim implements IContainerListener, private void notifyGlobalInventoryShimInternalListener(Node node, UpdateType type, Set props) { for (IInventoryShimInternalListener globalListener : globalInventoryShimInternalListeners) { globalListener.updateNode(node, type, props); - logger.trace( - "notifyGlobalInventoryShimInternalListener {} type {}", - new Object[] { node, type }); + logger.trace("notifyGlobalInventoryShimInternalListener {} type {}", new Object[] { node, type }); } } @@ -505,7 +512,7 @@ public class InventoryServiceShim implements IContainerListener, props.add(c); } int act = sw.getActions(); - Actions a = new Actions(act); + SupportedFlowActions a = new SupportedFlowActions(FlowConverter.getFlowActions(act)); if (a != null) { props.add(a); }