barrier message added for addflow 25/3825/5
authorPrasanna Huddar <prasanna.huddar@ericsson.com>
Wed, 18 Dec 2013 15:54:08 +0000 (21:24 +0530)
committerPrasanna Huddar <prasanna.huddar@ericsson.com>
Wed, 18 Dec 2013 17:54:21 +0000 (23:24 +0530)
Signed-off-by: Prasanna Huddar <prasanna.huddar@ericsson.com>
Change-Id: I8ddc822e86a084b4f9b61b55c6233dfabf203b61

openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/MessageDispatchServiceImpl.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/session/MessageDispatchServiceImplTest.java

index fc377eedfcad62014e01055972cf217f090e3a39..a1c7018004748ff965a9fac768966dda22c7f814 100644 (file)
@@ -121,6 +121,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
@@ -206,11 +209,16 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
     public Future<RpcResult<AddFlowOutput>> addFlow(AddFlowInput input) {
        // Convert the AddFlowInput to FlowModInput
         FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input, version);
+        BarrierInputBuilder barrierInput = new BarrierInputBuilder();
+        barrierInput.setVersion(version);
 
        // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
        // the request can be routed through any connection to the switch
 
        SwitchConnectionDistinguisher cookie = null ;
+       if (input.isBarrier()) {
+           Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
+       }       
 
        LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
                Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
@@ -310,13 +318,17 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
     public Future<RpcResult<RemoveFlowOutput>> removeFlow(RemoveFlowInput input) {
        // Convert the RemoveFlowInput to FlowModInput
         FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input, version);
-
+        BarrierInputBuilder barrierInput = new BarrierInputBuilder();
+        barrierInput.setVersion(version);
 
        // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
        // the request can be routed through any connection to the switch
 
        SwitchConnectionDistinguisher cookie = null ;
-
+        if (input.isBarrier()) {
+           Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
+       }
+        
        LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
                Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
 
@@ -449,14 +461,18 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
     public Future<RpcResult<UpdateFlowOutput>> updateFlow(UpdateFlowInput input) {
        // Convert the UpdateFlowInput to FlowModInput
         FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input.getUpdatedFlow(), version);
-
+        BarrierInputBuilder barrierInput = new BarrierInputBuilder();
+        barrierInput.setVersion(version);
        // Call the RPC method on MessageDispatchService
 
        // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
        // the request can be routed through any connection to the switch
 
        SwitchConnectionDistinguisher cookie = null ;
-
+        if (input.getUpdatedFlow().isBarrier()) {
+           Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
+       }
+        
        LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
                Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
 
index 0b927f00a7b405f9a746483443ef69dd7f8f3500..ec6681b359f7ac5f125f64a940ddd055795e9e46 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.Upd
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
@@ -105,7 +106,10 @@ public class MessageDispatchServiceImpl implements IMessageDispatchService {
 
     @Override
     public Future<RpcResult<BarrierOutput>> barrier(BarrierInput input, SwitchConnectionDistinguisher cookie) {
-        return getConnectionAdapter(cookie).barrier(input);
+        Long Xid = session.getNextXid();
+        BarrierInputBuilder inputBuilder = new BarrierInputBuilder(input);        
+        inputBuilder.setXid(Xid);
+        return getConnectionAdapter(cookie).barrier(inputBuilder.build());
     }
 
     @Override
index fe5c625549b5d0e9167a480501fd3415de560332..7c533763a16720108e3604edeb4d19f192f7ec43 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.ErrorHandler;
 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.openflow.md.queue.QueueKeeper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
@@ -82,7 +83,10 @@ public class MessageDispatchServiceImplTest {
      */
     @Test
     public void testBarrierMessageForPrimary() throws Exception {
-        session.getMessageDispatchService().barrier(null, null);
+        MockConnectionConductor conductor = new MockConnectionConductor(1);
+        SwitchConnectionDistinguisher cookie = conductor.getAuxiliaryKey();       
+        BarrierInputBuilder barrierMsg = new BarrierInputBuilder();
+        session.getMessageDispatchService().barrier(barrierMsg.build(), cookie);
         Assert.assertEquals(MessageType.BARRIER, session.getPrimaryConductor().getMessageType());
     }