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%2FReadService.java;h=f1f5944f379cdd96bf49e2293a52cb1e1d111277;hb=18e1184615fd939644d3660e5edcfbb676c187fa;hp=585e4f32c46d83b1edbe758ad2b635655639dcc8;hpb=eed57e2b0afd50823bc882123b6cbac04bcc48d9;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadService.java index 585e4f32c4..f1f5944f37 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadService.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.protocol_plugin.openflow.internal; +import java.util.Collections; import java.util.Dictionary; import java.util.List; import java.util.Set; @@ -17,6 +18,7 @@ import java.util.concurrent.CopyOnWriteArraySet; import org.apache.felix.dm.Component; import org.opendaylight.controller.protocol_plugin.openflow.IReadFilterInternalListener; import org.opendaylight.controller.protocol_plugin.openflow.IReadServiceFilter; +import org.opendaylight.controller.sal.connection.IPluginOutConnectionService; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.Node.NodeIDType; import org.opendaylight.controller.sal.core.NodeConnector; @@ -38,8 +40,9 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis private static final Logger logger = LoggerFactory .getLogger(ReadService.class); private IReadServiceFilter filter; - private Set pluginOutReadServices; + private Set pluginOutReadServices = new CopyOnWriteArraySet(); private String containerName; + private IPluginOutConnectionService connectionOutService; /** * Function called by the dependency manager when all the required @@ -49,9 +52,7 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis @SuppressWarnings("unchecked") void init(Component c) { Dictionary props = c.getServiceProperties(); - containerName = (props != null) ? (String) props.get("containerName") - : null; - pluginOutReadServices = new CopyOnWriteArraySet(); + containerName = (props != null) ? (String) props.get("containerName") : null; } /** @@ -61,6 +62,7 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis * */ void destroy() { + pluginOutReadServices.clear(); } /** @@ -110,6 +112,10 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis return null; } + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for the node : " + node); + return null; + } return filter.readFlow(containerName, node, flow, cached); } @@ -117,7 +123,12 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis public List readAllFlow(Node node, boolean cached) { if (!node.getType().equals(NodeIDType.OPENFLOW)) { logger.error("Invalid node type"); - return null; + return Collections.emptyList(); + } + + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for the node : " + node); + return Collections.emptyList(); } return filter.readAllFlow(containerName, node, cached); @@ -130,6 +141,11 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis return null; } + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for the node : " + node); + return null; + } + return filter.readDescription(node, cached); } @@ -141,6 +157,12 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis logger.error("Invalid node type"); return null; } + + if (!connectionOutService.isLocal(connector.getNode())) { + logger.debug("This Controller is not the master for connector : "+connector); + return null; + } + return filter.readNodeConnector(containerName, connector, cached); } @@ -149,7 +171,12 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis boolean cached) { if (!node.getType().equals(NodeIDType.OPENFLOW)) { logger.error("Invalid node type"); - return null; + return Collections.emptyList(); + } + + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for node : " + node); + return Collections.emptyList(); } return filter.readAllNodeConnector(containerName, node, cached); @@ -162,6 +189,12 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis logger.error("Invalid node type"); return 0; } + + if (!connectionOutService.isLocal(connector.getNode())) { + logger.debug("This Controller is not the master for connector : "+connector); + return 0; + } + return filter.getTransmitRate(containerName, connector); } @@ -172,6 +205,12 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis logger.error("Invalid node type"); return null; } + + if (!connectionOutService.isLocal(table.getNode())) { + logger.debug("This Controller is not the master for connector : "+table); + return null; + } + return filter.readNodeTable(containerName, table, cached); } @@ -179,7 +218,12 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis public List readAllNodeTable(Node node, boolean cached) { if (!node.getType().equals(NodeIDType.OPENFLOW)) { logger.error("Invalid node type"); - return null; + return Collections.emptyList(); + } + + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for node : " + node); + return Collections.emptyList(); } return filter.readAllNodeTable(containerName, node, cached); @@ -187,6 +231,10 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis @Override public void nodeFlowStatisticsUpdated(Node node, List flowStatsList) { + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for node : " + node); + return; + } for (IPluginOutReadService service : pluginOutReadServices) { service.nodeFlowStatisticsUpdated(node, flowStatsList); } @@ -194,6 +242,10 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis @Override public void nodeConnectorStatisticsUpdated(Node node, List ncStatsList) { + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for node : " + node); + return; + } for (IPluginOutReadService service : pluginOutReadServices) { service.nodeConnectorStatisticsUpdated(node, ncStatsList); } @@ -201,6 +253,10 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis @Override public void nodeTableStatisticsUpdated(Node node, List tableStatsList) { + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for node : " + node); + return; + } for (IPluginOutReadService service : pluginOutReadServices) { service.nodeTableStatisticsUpdated(node, tableStatsList); } @@ -208,8 +264,22 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis @Override public void nodeDescriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) { + if (!connectionOutService.isLocal(node)) { + logger.debug("This Controller is not the master for node : " + node); + return; + } for (IPluginOutReadService service : pluginOutReadServices) { service.descriptionStatisticsUpdated(node, nodeDescription); } } + + void setIPluginOutConnectionService(IPluginOutConnectionService s) { + connectionOutService = s; + } + + void unsetIPluginOutConnectionService(IPluginOutConnectionService s) { + if (connectionOutService == s) { + connectionOutService = null; + } + } }