From: michal rehak Date: Thu, 19 Dec 2013 10:02:22 +0000 (+0000) Subject: Merge "Table update rpc added as provider" X-Git-Tag: jenkins-openflowplugin-bulk-release-prepare-only-4~74 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=0364d5ca320c66b29ee6dd9df9ac1f44b664c37d;hp=42ced541976153113d9fac7b1c9a7a2a97df711e;p=openflowplugin.git Merge "Table update rpc added as provider" --- diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java index 9aaed001ef..c8b620eae9 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java @@ -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 flowRegistration; private RoutedRpcRegistration groupRegistration; + + private RoutedRpcRegistration tableRegistration; private RoutedRpcRegistration 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()); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java index a1c7018004..876c8f2dd3 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java @@ -205,6 +205,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch { version = context.getPrimaryConductor().getVersion(); } + @Override public Future> addFlow(AddFlowInput input) { // Convert the AddFlowInput to FlowModInput @@ -1038,7 +1039,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch { @Override public Future> 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(); @@ -1053,45 +1054,26 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch { //Convert the list of all MD-SAL table feature object into OF library object List 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 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(); diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java index 72733a98cb..6fee3622e9 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java @@ -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 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);