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%2FFlowProgrammerService.java;h=c55a88cd3f0224cc587bc01e632e742405cc34f1;hb=dfa4383b0b5c9c6de340526a62aef731922fa29f;hp=f58acf62edb0962703b9e4971e582bc412314c47;hpb=8398f3adb544427642694be13abe9c3bc1a4e192;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowProgrammerService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowProgrammerService.java index f58acf62ed..c55a88cd3f 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowProgrammerService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowProgrammerService.java @@ -23,6 +23,7 @@ import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExtern 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.sal.connection.IPluginOutConnectionService; import org.opendaylight.controller.sal.core.ContainerFlow; import org.opendaylight.controller.sal.core.IContainerListener; import org.opendaylight.controller.sal.core.Node; @@ -65,6 +66,7 @@ public class FlowProgrammerService implements IPluginInFlowProgrammerService, private Map> containerToNc; private ConcurrentMap> xid2rid; private int barrierMessagePriorCount = getBarrierMessagePriorCount(); + private IPluginOutConnectionService connectionOutService; public FlowProgrammerService() { controller = null; @@ -83,6 +85,16 @@ public class FlowProgrammerService implements IPluginInFlowProgrammerService, } } + void setIPluginOutConnectionService(IPluginOutConnectionService s) { + connectionOutService = s; + } + + void unsetIPluginOutConnectionService(IPluginOutConnectionService s) { + if (connectionOutService == s) { + connectionOutService = null; + } + } + public void setFlowProgrammerNotifier(Map props, IFlowProgrammerNotifier s) { if (props == null || props.get("containerName") == null) { @@ -146,32 +158,62 @@ public class FlowProgrammerService implements IPluginInFlowProgrammerService, @Override public Status addFlow(Node node, Flow flow) { + if (!connectionOutService.isLocal(node)) { + log.debug("Add flow will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + return addFlowInternal(node, flow, 0); } @Override public Status modifyFlow(Node node, Flow oldFlow, Flow newFlow) { + if (!connectionOutService.isLocal(node)) { + log.debug("Modify flow will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + return modifyFlowInternal(node, oldFlow, newFlow, 0); } @Override public Status removeFlow(Node node, Flow flow) { + if (!connectionOutService.isLocal(node)) { + log.debug("Remove flow will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + return removeFlowInternal(node, flow, 0); } @Override public Status addFlowAsync(Node node, Flow flow, long rid) { + if (!connectionOutService.isLocal(node)) { + log.debug("Add flow Async will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + return addFlowInternal(node, flow, rid); } @Override public Status modifyFlowAsync(Node node, Flow oldFlow, Flow newFlow, long rid) { + if (!connectionOutService.isLocal(node)) { + log.debug("Modify flow async will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + return modifyFlowInternal(node, oldFlow, newFlow, rid); } @Override public Status removeFlowAsync(Node node, Flow flow, long rid) { + if (!connectionOutService.isLocal(node)) { + log.debug("Remove flow async will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + return removeFlowInternal(node, flow, rid); } @@ -324,6 +366,11 @@ public class FlowProgrammerService implements IPluginInFlowProgrammerService, @Override public Status removeAllFlows(Node node) { + if (!connectionOutService.isLocal(node)) { + log.debug("Remove all flows will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + return new Status(StatusCode.SUCCESS); } @@ -446,6 +493,11 @@ public class FlowProgrammerService implements IPluginInFlowProgrammerService, @Override public Status syncSendBarrierMessage(Node node) { + if (!connectionOutService.isLocal(node)) { + log.debug("Sync Send Barrier will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + if (!node.getType().equals(NodeIDType.OPENFLOW)) { return new Status(StatusCode.NOTACCEPTABLE, "The node does not support Barrier message."); @@ -469,6 +521,11 @@ public class FlowProgrammerService implements IPluginInFlowProgrammerService, @Override public Status asyncSendBarrierMessage(Node node) { + if (!connectionOutService.isLocal(node)) { + log.debug("ASync Send Barrier will not be processed in a non-master controller for node " + node); + return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node); + } + if (!node.getType().equals(NodeIDType.OPENFLOW)) { return new Status(StatusCode.NOTACCEPTABLE, "The node does not support Barrier message.");