Merge "MD-SAL model for group feature in OF 1.3."
[controller.git] / opendaylight / sal / implementation / src / main / java / org / opendaylight / controller / sal / implementation / internal / FlowProgrammerService.java
index 0abebf83522efb29cd898416e26b268720fd71fc..854125b3567a196b940556363ed56c82e99d50c0 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerSe
 import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.utils.EtherTypes;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.Status;
@@ -75,7 +76,7 @@ public class FlowProgrammerService implements IFlowProgrammerService,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     * 
+     *
      */
     void init() {
         logger.debug("INIT called!");
@@ -85,7 +86,7 @@ public class FlowProgrammerService implements IFlowProgrammerService,
      * Function called by the dependency manager when at least one dependency
      * become unsatisfied or when the component is shutting down because for
      * example bundle is being stopped.
-     * 
+     *
      */
     void destroy() {
         // Clear previous registration to avoid they are left hanging
@@ -96,7 +97,7 @@ public class FlowProgrammerService implements IFlowProgrammerService,
     /**
      * Function called by dependency manager after "init ()" is called and after
      * the services provided by the class are registered in the service registry
-     * 
+     *
      */
     void start() {
         logger.debug("START called!");
@@ -108,28 +109,28 @@ public class FlowProgrammerService implements IFlowProgrammerService,
      * Function called by the dependency manager before the services exported by
      * the component are unregistered, this will be followed by a "destroy ()"
      * calls
-     * 
+     *
      */
     void stop() {
         logger.debug("STOP called!");
     }
 
     // Set the reference to the plugin flow programmer
-    public void setService(Map props, IPluginInFlowProgrammerService s) {
+    public void setService(Map<String, Object> 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());
+        if (logger.isTraceEnabled()) {
+            logger.trace("Got a service set request {}", s);
+            for (Map.Entry<String, Object> entry : props.entrySet()) {
+                logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue());
+            }
         }
 
-        Object value = props.get("protocolPluginType");
+        String type = null;
+        Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
         if (value instanceof String) {
             type = (String) value;
         }
@@ -142,21 +143,22 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         }
     }
 
-    public void unsetService(Map props, IPluginInFlowProgrammerService s) {
+    public void unsetService(Map<String, Object> 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());
+        if (logger.isTraceEnabled()) {
+            logger.trace("Got a service set request {}", s);
+            for (Map.Entry<String, Object> entry : props.entrySet()) {
+                logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue());
+            }
         }
 
-        Object value = props.get("protocoloPluginType");
+        String type = null;
+        Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
         if (value instanceof String) {
             type = (String) value;
         }
@@ -305,7 +307,7 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         }
         ci.println(this.addFlow(node, getSampleFlow(node)));
     }
-    
+
     public void _modifyflow(CommandInterpreter ci) throws UnknownHostException {
         Node node = null;
         String nodeId = ci.nextArgument();
@@ -430,6 +432,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 +490,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;
     }
@@ -494,7 +498,7 @@ public class FlowProgrammerService implements IFlowProgrammerService,
     /**
      * This Request ID generator starts with 1. Each aysnc message is
      * associated with an unique Request ID (!= 0).
-     * 
+     *
      * @return Request ID
      */
     private long getNextRid() {
@@ -502,11 +506,22 @@ public class FlowProgrammerService implements IFlowProgrammerService,
     }
 
     @Override
-    public Status sendBarrierMessage(Node node) {
+    public Status syncSendBarrierMessage(Node node) {
+        if (this.pluginFlowProgrammer != null) {
+            if (this.pluginFlowProgrammer.get(node.getType()) != null) {
+                return this.pluginFlowProgrammer.get(node.getType())
+                        .syncSendBarrierMessage(node);
+            }
+        }
+        return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");
+    }
+
+    @Override
+    public Status asyncSendBarrierMessage(Node node) {
         if (this.pluginFlowProgrammer != null) {
             if (this.pluginFlowProgrammer.get(node.getType()) != null) {
                 return this.pluginFlowProgrammer.get(node.getType())
-                        .sendBarrierMessage(node);
+                        .asyncSendBarrierMessage(node);
             }
         }
         return new Status(StatusCode.NOSERVICE, "Plugin unuvailable");