X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fimplementation%2Finternal%2FFlowProgrammerService.java;h=60a7882bda552b5e2fa5fddfb7ebafad6d51ccbb;hb=a2a56c27c18eeedff28796034be220ac049d6a26;hp=d6feebd4a3067a057af0a7991dcf82613f2f5995;hpb=39e1d43dc8f41f682fb818469a3aeb542e76ea8e;p=controller.git diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java index d6feebd4a3..60a7882bda 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -57,12 +57,12 @@ public class FlowProgrammerService implements IFlowProgrammerService, protected static final Logger logger = LoggerFactory .getLogger(FlowProgrammerService.class); - private ConcurrentHashMap pluginFlowProgrammer; + private ConcurrentHashMap> pluginFlowProgrammer; private Set listener; private AtomicLong seq; public FlowProgrammerService() { - pluginFlowProgrammer = new ConcurrentHashMap(); + pluginFlowProgrammer = new ConcurrentHashMap>(); listener = new HashSet(); seq = new AtomicLong(); /* @@ -115,58 +115,12 @@ public class FlowProgrammerService implements IFlowProgrammerService, } // Set the reference to the plugin flow programmer - public void setService(Map props, IPluginInFlowProgrammerService s) { - if (this.pluginFlowProgrammer == null) { - logger.error("pluginFlowProgrammer store null"); - return; - } - - logger.trace("Got a service set request {}", s); - String type = null; - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})", entry.getKey(), - entry.getValue()); - } - - Object value = props.get("protocolPluginType"); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a pluginFlowProgrammer without any " - + "protocolPluginType provided"); - } else { - this.pluginFlowProgrammer.put(type, s); - logger.debug("Stored the pluginFlowProgrammer for type: {}", type); - } + public void setService(Map props, IPluginInFlowProgrammerService s) { + ProtocolService.set(this.pluginFlowProgrammer, props, s, logger); } - public void unsetService(Map props, IPluginInFlowProgrammerService s) { - if (this.pluginFlowProgrammer == null) { - logger.error("pluginFlowProgrammer store null"); - return; - } - - String type = null; - logger.debug("Received unsetpluginFlowProgrammer request"); - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})", entry.getKey(), - entry.getValue()); - } - - Object value = props.get("protocoloPluginType"); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a pluginFlowProgrammer without any " - + "protocolPluginType provided"); - } else if (this.pluginFlowProgrammer.get(type).equals(s)) { - this.pluginFlowProgrammer.remove(type); - logger.debug("Removed the pluginFlowProgrammer for type: {}", type); - } + public void unsetService(Map props, IPluginInFlowProgrammerService s) { + ProtocolService.unset(this.pluginFlowProgrammer, props, s, logger); } public void setListener(IFlowProgrammerListener s) { @@ -180,9 +134,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status addFlow(Node node, Flow flow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()).addFlow( - node, flow); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().addFlow(node, flow); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -191,9 +146,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status removeFlow(Node node, Flow flow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .removeFlow(node, flow); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().removeFlow(node, flow); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -202,9 +158,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status removeAllFlows(Node node) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .removeAllFlows(node); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().removeAllFlows(node); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -213,9 +170,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status modifyFlow(Node node, Flow oldFlow, Flow newFlow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .modifyFlow(node, oldFlow, newFlow); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().modifyFlow(node, oldFlow, newFlow); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -224,9 +182,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status addFlowAsync(Node node, Flow flow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()).addFlowAsync( - node, flow, getNextRid()); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().addFlowAsync(node, flow, getNextRid()); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -235,9 +194,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status removeFlowAsync(Node node, Flow flow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .removeFlowAsync(node, flow, getNextRid()); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().removeFlowAsync(node, flow, getNextRid()); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -246,9 +206,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status modifyFlowAsync(Node node, Flow oldFlow, Flow newFlow) { if (pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .modifyFlowAsync(node, oldFlow, newFlow, getNextRid()); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().modifyFlowAsync(node, oldFlow, newFlow, getNextRid()); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -430,6 +391,7 @@ public class FlowProgrammerService implements IFlowProgrammerService, Flow flow = new Flow(match, actions); flow.setPriority((short) 100); flow.setHardTimeout((short) 360); + flow.setId(1234L); return flow; } @@ -487,6 +449,7 @@ public class FlowProgrammerService implements IFlowProgrammerService, Flow flow = new Flow(match, actions); flow.setPriority((short) 300); flow.setHardTimeout((short) 240); + flow.setId(65536L); return flow; } @@ -504,9 +467,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status syncSendBarrierMessage(Node node) { if (this.pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .syncSendBarrierMessage(node); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().syncSendBarrierMessage(node); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable"); @@ -515,9 +479,10 @@ public class FlowProgrammerService implements IFlowProgrammerService, @Override public Status asyncSendBarrierMessage(Node node) { if (this.pluginFlowProgrammer != null) { - if (this.pluginFlowProgrammer.get(node.getType()) != null) { - return this.pluginFlowProgrammer.get(node.getType()) - .asyncSendBarrierMessage(node); + ProtocolService service = + this.pluginFlowProgrammer.get(node.getType()); + if (service != null) { + return service.getService().asyncSendBarrierMessage(node); } } return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");