Table update rpc added as provider 91/3791/1
authorPrasanna Huddar <prasanna.huddar@ericsson.com>
Tue, 17 Dec 2013 14:00:32 +0000 (19:30 +0530)
committerPrasanna Huddar <prasanna.huddar@ericsson.com>
Tue, 17 Dec 2013 14:00:32 +0000 (19:30 +0530)
Signed-off-by: Prasanna Huddar <prasanna.huddar@ericsson.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java

index 9aaed001efd093e1eb5d4cfbb0664c5cdd2315d9..c8b620eae94223ad2ca34c8cb83a0da0ea2291e8 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -37,6 +38,8 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
     private RoutedRpcRegistration<SalFlowService> flowRegistration;
 
     private RoutedRpcRegistration<SalGroupService> groupRegistration;
+    
+    private RoutedRpcRegistration<SalTableService> tableRegistration;
 
     private RoutedRpcRegistration<SalMeterService> meterRegistration;
 
@@ -82,6 +85,10 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
         groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this);
         groupRegistration.registerPath(NodeContext.class, getIdentifier());
         builder.add(groupRegistration);
+        
+        tableRegistration = ctx.addRoutedRpcImplementation(SalTableService.class, this);
+        tableRegistration.registerPath(NodeContext.class, getIdentifier());
+        builder.add(tableRegistration);
 
         packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
         packetRegistration.registerPath(NodeContext.class, getIdentifier());
index fc377eedfcad62014e01055972cf217f090e3a39..d35fca02656c910627d5bf1102340744a81d8fc6 100644 (file)
@@ -202,6 +202,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         version = context.getPrimaryConductor().getVersion();
     }
 
+    
     @Override
     public Future<RpcResult<AddFlowOutput>> addFlow(AddFlowInput input) {
        // Convert the AddFlowInput to FlowModInput
@@ -1022,7 +1023,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
     
     @Override
     public Future<RpcResult<UpdateTableOutput>> updateTable(
-                       UpdateTableInput input) {
+                        UpdateTableInput input) {
 
         // Get the Xid. The same Xid has to be sent in all the Multipart requests
         Long xid = this.getSessionContext().getNextXid();
@@ -1037,45 +1038,26 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
 
         //Convert the list of all MD-SAL table feature object into OF library object
         List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input.getUpdatedTable()) ;
-        int totalNoOfTableFeatureEntry = ofTableFeatureList.size();
+        
 
         MultipartRequestTableFeaturesCaseBuilder caseRequest = new MultipartRequestTableFeaturesCaseBuilder();
         MultipartRequestTableFeaturesBuilder tableFeaturesRequest = new MultipartRequestTableFeaturesBuilder();
 
-        // Slice the multipart request based on the configuration parameter, which is the no. of TableFeatureList element
-        // to be put in one multipart message. Default is 5
-        // This parameter must be set based on switch's Buffer capacity
-
-        List<TableFeatures> tmpOfTableFeatureList = null ;
-        String tableFeatureListCount = System.getProperty( "of.tableFeaturesCountPerMultipart", "5") ;
-        int noOfEntriesInMPR = Integer.parseInt(tableFeatureListCount) ;
-
-        int index = 0 ;
-        while(totalNoOfTableFeatureEntry-index > 0 ) {
-               if( (totalNoOfTableFeatureEntry-index) > noOfEntriesInMPR ) {
-                       mprInput.setFlags(new MultipartRequestFlags(true));
-                       tmpOfTableFeatureList = ofTableFeatureList.subList(index, index + noOfEntriesInMPR);
-               }
-               else {
-                       // Last multipart request
-                       mprInput.setFlags(new MultipartRequestFlags(false));
-                       tmpOfTableFeatureList = ofTableFeatureList.subList(index, totalNoOfTableFeatureEntry );
-               }
-
-        tableFeaturesRequest.setTableFeatures(tmpOfTableFeatureList) ;
+        mprInput.setFlags(new MultipartRequestFlags(true));
+        
+        tableFeaturesRequest.setTableFeatures(ofTableFeatureList) ;
+        
         //Set request body to main multipart request
         caseRequest.setMultipartRequestTableFeatures(tableFeaturesRequest.build());
         mprInput.setMultipartRequestBody(caseRequest.build());
 
         //Send the request, no cookies associated, use any connection
-        LOG.debug("Send Table Feature request :{}",tmpOfTableFeatureList);
+        LOG.debug("Send Table Feature request :{}",ofTableFeatureList);
         this.messageService.multipartRequest(mprInput.build(), null);
-        index += noOfEntriesInMPR ;
-               tmpOfTableFeatureList = null ; // To avoid any corrupt data
-        }
+        
         
         //Extract the Xid only from the Future for the last RPC and
-       // send it back to the NSF
+        // send it back to the NSF
         LOG.debug("Returning the result and transaction id to NSF");
         LOG.debug("Return results and transaction id back to caller");
         UpdateTableOutputBuilder output = new UpdateTableOutputBuilder();
index 72733a98cbd1b50c0ee63c45623a233bdf07317a..6fee3622e994ad2ba7f0992530a6fe346b7cadce 100644 (file)
@@ -13,7 +13,6 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderCo
 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
@@ -24,7 +23,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
 
-import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.osgi.framework.BundleContext;
@@ -48,8 +46,8 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
         pc = session;
         dataBrokerService = session.getSALService(DataBrokerService.class);
         ctx.registerService(CommandProvider.class.getName(), this, null);
-        createTestNode();
-        createTestTable();
+       // createTestNode();
+       // createTestTable();
     }
 
     private void createUserNode(String nodeRef) {        
@@ -95,7 +93,8 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
         DataModification modification = dataBrokerService.beginTransaction();
                
         InstanceIdentifier<Table> path1 = InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(table.getId())).build() ;
+                .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
+                child(Table.class, new TableKey(table.getId())).build() ;
                 
                         
         modification.putOperationalData(nodeToInstanceId(testNode), testNode);