WIP: BUG-5464: scaling issue 59/36559/5
authorJozef Bacigal <jbacigal@cisco.com>
Wed, 23 Mar 2016 14:04:35 +0000 (15:04 +0100)
committerTomas Slusny <tomas.slusny@pantheon.sk>
Tue, 26 Apr 2016 07:28:45 +0000 (09:28 +0200)
    - pull up table-features to flow-cabable-node
    - fix adjanced logic
    - remove augmentation of flow-capable-node (redundant table-features)
    - fixed unit test

Change-Id: I798f87420330cfd71045eac3de61291a10abdafa
Signed-off-by: Michal Rehak <mirehak@cisco.com>
Signed-off-by: Jozef Bacigal <jbacigal@cisco.com>
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java
applications/forwardingrules-manager/src/test/java/test/mock/TableFeaturesListenerTest.java
applications/inventory-manager/src/main/java/org/opendaylight/openflowplugin/applications/inventory/manager/NodeTablesFeatureCommitter.java
model/model-flow-service/src/main/yang/flow-node-inventory.yang
model/model-flow-statistics/src/main/yang/opendaylight-flow-table-statistics.yang
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalTableServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtils.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java

index cfd73406c37ea6fd4ab94f2f2f59569ed8d857f5..6b5112a8db0a033c0dd802aa99f2695b5888b6ce 100644 (file)
@@ -222,18 +222,13 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
         if (flowNode.isPresent()) {
             /* Tables - have to be pushed before groups */
             // CHECK if while pusing the update, updateTableInput can be null to emulate a table add
-            List<Table> tableList = flowNode.get().getTable() != null
-                    ? flowNode.get().getTable() : Collections.<Table> emptyList() ;
-            for (Table table : tableList) {
-                TableKey tableKey = table.getKey();
+            List<TableFeatures> tableList = flowNode.get().getTableFeatures() != null
+                    ? flowNode.get().getTableFeatures() : Collections.<TableFeatures> emptyList() ;
+            for (TableFeatures tableFeaturesItem : tableList) {
+                TableFeaturesKey tableKey = tableFeaturesItem.getKey();
                 KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII
-                    = nodeIdent.child(Table.class, tableKey).child(TableFeatures.class, new TableFeaturesKey(tableKey.getId()));
-                List<TableFeatures> tableFeatures = table.getTableFeatures();
-                if (tableFeatures != null) {
-                    for (TableFeatures tableFeaturesItem : tableFeatures) {
+                    = nodeIdent.child(TableFeatures.class, new TableFeaturesKey(tableKey.getTableId()));
                         provider.getTableFeaturesCommiter().update(tableFeaturesII, tableFeaturesItem, null, nodeIdent);
-                    }
-                }
             }
 
             /* Groups - have to be first */
index 27fb50eaf4c6ea5aad07bf0058f7ff50f006a1ef..f7bfc7e2591f47307b326a04087c6a451c13d7a5 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.base.Preconditions;
 import java.util.Collections;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -20,7 +19,6 @@ import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager;
 import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
 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;
@@ -41,7 +39,7 @@ public class TableForwarder extends AbstractListeningCommiter<TableFeatures> {
 
     private ListenerRegistration<TableForwarder> listenerRegistration;
 
-    public TableForwarder (final ForwardingRulesManager manager, final DataBroker db) {
+    public TableForwarder(final ForwardingRulesManager manager, final DataBroker db) {
         super(manager, TableFeatures.class);
         Preconditions.checkNotNull(db, "DataBroker can not be null!");
         final DataTreeIdentifier<TableFeatures> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath());
@@ -78,35 +76,35 @@ public class TableForwarder extends AbstractListeningCommiter<TableFeatures> {
     @Override
     protected InstanceIdentifier<TableFeatures> getWildCardPath() {
         return InstanceIdentifier.create(Nodes.class).child(Node.class)
-                .augmentation(FlowCapableNode.class).child(Table.class).child(TableFeatures.class);
+                .augmentation(FlowCapableNode.class).child(TableFeatures.class);
     }
 
     @Override
     public void remove(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures removeDataObj,
                        final InstanceIdentifier<FlowCapableNode> nodeIdent) {
-      // DO Nothing
+        // DO Nothing
     }
 
     @Override
     public void update(final InstanceIdentifier<TableFeatures> identifier,
                        final TableFeatures original, final TableFeatures update,
                        final InstanceIdentifier<FlowCapableNode> nodeIdent) {
-        LOG.debug( "Received the Table Update request [Tbl id, node Id, original, upd" +
-                       " " + identifier + " " + nodeIdent + " " + original + " " + update );
+        LOG.debug("Received the Table Update request [Tbl id, node Id, original, upd" +
+                " " + identifier + " " + nodeIdent + " " + original + " " + update);
 
         final TableFeatures originalTableFeatures = original;
-        TableFeatures updatedTableFeatures ;
-        ifnull == update)
-          updatedTableFeatures = original;
+        TableFeatures updatedTableFeatures;
+        if (null == update)
+            updatedTableFeatures = original;
         else
-          updatedTableFeatures = update;
+            updatedTableFeatures = update;
 
         final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
 
         builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
 
-        InstanceIdentifier<Table> iiToTable = identifier.firstIdentifierOf(Table.class);
-        builder.setTableRef(new TableRef(iiToTable));
+        // TODO: reconsider model - this particular field is not used in service implementation
+        builder.setTableRef(new TableRef(identifier));
 
         builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
 
@@ -115,10 +113,10 @@ public class TableForwarder extends AbstractListeningCommiter<TableFeatures> {
 
         builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(
                 Collections.singletonList(originalTableFeatures)).build());
-        LOG.debug( "Invoking SalTableService " ) ;
+        LOG.debug("Invoking SalTableService ");
 
-        if( this.provider.getSalTableService() != null )
-               LOG.debug( " Handle to SalTableServices" + this.provider.getSalTableService()) ;
+        if (this.provider.getSalTableService() != null)
+            LOG.debug(" Handle to SalTableServices" + this.provider.getSalTableService());
         this.provider.getSalTableService().updateTable(builder.build());
 
     }
@@ -126,7 +124,7 @@ public class TableForwarder extends AbstractListeningCommiter<TableFeatures> {
     @Override
     public void add(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures addDataObj,
                     final InstanceIdentifier<FlowCapableNode> nodeIdent) {
-       //DO NOthing
+        //DO NOthing
     }
 
     @Override
index c90d3507bde6a7f0c9453325f3848248d54275ef..26160a737f559264de05e2d1f813f921fb078315 100644 (file)
@@ -7,31 +7,30 @@
  */
 package test.mock;
 
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
+import static org.junit.Assert.assertEquals;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
-import test.mock.util.EntityOwnershipServiceMock;
-import test.mock.util.SalTableServiceMock;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import java.util.List;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-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.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 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.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import test.mock.util.EntityOwnershipServiceMock;
 import test.mock.util.FRMTest;
 import test.mock.util.RpcProviderRegistryMock;
-import java.util.List;
-import static org.junit.Assert.assertEquals;
+import test.mock.util.SalTableServiceMock;
 
 public class TableFeaturesListenerTest extends FRMTest {
     RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
@@ -54,7 +53,7 @@ public class TableFeaturesListenerTest extends FRMTest {
 
         TableFeatures tableFeaturesData = new TableFeaturesBuilder().setKey(tableFeaturesKey).build();
         InstanceIdentifier<TableFeatures> tableFeaturesII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key)
-              .augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(TableFeatures.class, tableFeaturesKey);
+                .augmentation(FlowCapableNode.class).child(TableFeatures.class, tableFeaturesKey);
         WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
         writeTx.put(LogicalDatastoreType.CONFIGURATION, tableFeaturesII, tableFeaturesData);
         assertCommit(writeTx.submit());
index 7784b8e477564ef741fa2cee39107dd399f48de5..19e4752eedeb25230ea1eea327a50b208394bc9c 100644 (file)
@@ -9,26 +9,23 @@
 package org.opendaylight.openflowplugin.applications.inventory.manager;
 
 import com.google.common.base.Preconditions;
+import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-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.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 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.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.TableUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-
 /**
  * Class receives and processes table feature updates. It augment table feature on table node
  * in the inventory tree (node/table/{table-id}).
@@ -61,7 +58,6 @@ public class NodeTablesFeatureCommitter implements SalTableListener {
                 for (final TableFeatures tableFeatureData : swTablesFeatures) {
                     final Short tableId = tableFeatureData.getTableId();
                     final KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII = flowCapableNodeII
-                            .child(Table.class, new TableKey(tableId))
                             .child(TableFeatures.class,new TableFeaturesKey(tableId));
 
                     LOG.trace("Updating table feature for table {} of node {}", tableId, nodeId.getValue());
index 27b3b8f4562d10cf021c04a3b25889341ab4f317..b306a01bb71eb77aa0d1265ecd904134fadc2fa8 100644 (file)
@@ -108,8 +108,6 @@ module flow-node-inventory {
                     type uint8;
             }
 
-            uses table:table-features;
-
             list flow {
                 key "id";
 
@@ -179,6 +177,7 @@ module flow-node-inventory {
         }
 
         uses tables;
+        uses table:table-features;
         uses group:groups;
         uses meters;
         uses ip-address-grouping;
index 292b09e52d08b10bd871ea4bf8eee6962a9f6a9a..bb653f8d7892095e96c87161107d5a07f8c5b293 100644 (file)
@@ -18,28 +18,20 @@ module opendaylight-flow-table-statistics {
     revision "2013-12-15" {
         description "Initial revision of flow table statistics model";
     }
-    
+
     augment "/inv:nodes/inv:node/flow-node:table" {
         description "Openflow flow table statistics data into the table node.";
         ext:augment-identifier "flow-table-statistics-data";
         uses flow-table-statistics;
     }
-    
-    augment "/inv:nodes/inv:node/flow-node:table" {
-        description "Openflow flow table features data into the table node.";
-        ext:augment-identifier "node-table-features";
-        container table-feature-container {
-            uses table-types:table-features;
-        }
-    }
-    
+
     grouping flow-table-statistics {
         description "TODO:: simplify.";
         container flow-table-statistics {
             uses stat-types:generic-table-statistics;
         }
-    }    
-    
+    }
+
     grouping flow-table-and-statistics-map {
         status deprecated;
         description "RPC calls to fetch flow table statistics.";
@@ -52,7 +44,7 @@ module opendaylight-flow-table-statistics {
             uses stat-types:generic-table-statistics;
         }
     }
-    
+
     rpc get-flow-tables-statistics {
         status deprecated;
         description "Fetch statistics of all the flow tables present on the tarnet node";
@@ -65,13 +57,13 @@ module opendaylight-flow-table-statistics {
             uses tr:transaction-aware;
         }
     }
-    
+
     //Notification to receive table statistics update
-    
+
     notification flow-table-statistics-update {
         status deprecated;
         description "Receive flow table statistics update";
-        
+
         uses inv:node;
         uses flow-table-and-statistics-map;
         uses tr:multipart-transaction-aware;
index f208c3726d5fd9f2460bc6130d9dd7b7287ef83f..1a3c104b39079b2d55406839b479c8e3e20603f5 100644 (file)
@@ -22,8 +22,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-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.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
@@ -118,7 +116,6 @@ public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTa
         for (final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures tableFeatureData : salTableFeatures) {
             final Short tableId = tableFeatureData.getTableId();
             final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures, TableFeaturesKey> tableFeaturesII = flowCapableNodeII
-                    .child(Table.class, new TableKey(tableId))
                     .child(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures.class,
                             new TableFeaturesKey(tableId));
             deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableFeaturesII,
index 8c178cce7f716ad41e2461b33785b15944dba708..4311882833638e3e373d06f6d7965e6bf7f4b454 100644 (file)
@@ -8,6 +8,12 @@
 
 package org.opendaylight.openflowplugin.impl.util;
 
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.AsyncFunction;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
@@ -18,14 +24,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.concurrent.Future;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.ConnectionException;
@@ -78,7 +76,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -103,7 +103,7 @@ public class DeviceInitializationUtils {
         final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
         final short version = deviceState.getVersion();
         LOG.trace("initalizeNodeInformation for node {}", deviceState.getNodeId());
-        final SettableFuture<Void> returnFuture = SettableFuture.<Void> create();
+        final SettableFuture<Void> returnFuture = SettableFuture.<Void>create();
         addNodeToOperDS(deviceContext, returnFuture);
         final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture;
         if (OFConstants.OFP_VERSION_1_0 == version) {
@@ -174,7 +174,7 @@ public class DeviceInitializationUtils {
         Preconditions.checkArgument(deviceContext != null);
         final DeviceState deviceState = deviceContext.getDeviceState();
         final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(
-                Collections.<NodeConnector> emptyList());
+                Collections.<NodeConnector>emptyList());
         try {
             deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier(),
                     nodeBuilder.build());
@@ -245,94 +245,101 @@ public class DeviceInitializationUtils {
     }
 
     static void translateAndWriteReply(final MultipartType type, final DeviceContext dContext,
-            final InstanceIdentifier<Node> nodeII, final Collection<MultipartReply> result) {
+                                       final InstanceIdentifier<Node> nodeII, final Collection<MultipartReply> result) {
         try {
             for (final MultipartReply reply : result) {
                 final MultipartReplyBody body = reply.getMultipartReplyBody();
                 switch (type) {
-                case OFPMPDESC:
-                    Preconditions.checkArgument(body instanceof MultipartReplyDescCase);
-                    final MultipartReplyDesc replyDesc = ((MultipartReplyDescCase) body).getMultipartReplyDesc();
-                    final FlowCapableNode fcNode = NodeStaticReplyTranslatorUtil.nodeDescTranslator(replyDesc,
-                            getIpAddressOf(dContext));
-                    final InstanceIdentifier<FlowCapableNode> fNodeII = nodeII.augmentation(FlowCapableNode.class);
-                    dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, fNodeII, fcNode);
-                    break;
-
-                case OFPMPTABLEFEATURES:
-                    Preconditions.checkArgument(body instanceof MultipartReplyTableFeaturesCase);
-                    final MultipartReplyTableFeatures tableFeatures = ((MultipartReplyTableFeaturesCase) body)
-                            .getMultipartReplyTableFeatures();
-                    final List<TableFeatures> tables = NodeStaticReplyTranslatorUtil
-                            .nodeTableFeatureTranslator(tableFeatures);
-                    for (final TableFeatures table : tables) {
-                        final Short tableId = table.getTableId();
-                        final InstanceIdentifier<Table> tableII = nodeII.augmentation(FlowCapableNode.class).child(
-                                Table.class, new TableKey(tableId));
-                        final TableBuilder tableBuilder = new TableBuilder().setId(tableId).setTableFeatures(
-                                Collections.singletonList(table));
-                        tableBuilder.addAugmentation(FlowTableStatisticsData.class,
-                                new FlowTableStatisticsDataBuilder().build());
-                        dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableII, tableBuilder.build());
-                    }
-                    break;
-
-                case OFPMPMETERFEATURES:
-                    Preconditions.checkArgument(body instanceof MultipartReplyMeterFeaturesCase);
-                    final MultipartReplyMeterFeatures meterFeatures = ((MultipartReplyMeterFeaturesCase) body)
-                            .getMultipartReplyMeterFeatures();
-                    final NodeMeterFeatures mFeature = NodeStaticReplyTranslatorUtil
-                            .nodeMeterFeatureTranslator(meterFeatures);
-                    final InstanceIdentifier<NodeMeterFeatures> mFeatureII = nodeII
-                            .augmentation(NodeMeterFeatures.class);
-                    dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, mFeatureII, mFeature);
-                    if (0L < mFeature.getMeterFeatures().getMaxMeter().getValue()) {
-                        dContext.getDeviceState().setMeterAvailable(true);
-                    }
-                    break;
-
-                case OFPMPGROUPFEATURES:
-                    Preconditions.checkArgument(body instanceof MultipartReplyGroupFeaturesCase);
-                    final MultipartReplyGroupFeatures groupFeatures = ((MultipartReplyGroupFeaturesCase) body)
-                            .getMultipartReplyGroupFeatures();
-                    final NodeGroupFeatures gFeature = NodeStaticReplyTranslatorUtil
-                            .nodeGroupFeatureTranslator(groupFeatures);
-                    final InstanceIdentifier<NodeGroupFeatures> gFeatureII = nodeII
-                            .augmentation(NodeGroupFeatures.class);
-                    dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gFeatureII, gFeature);
-                    break;
-
-                case OFPMPPORTDESC:
-                    Preconditions.checkArgument(body instanceof MultipartReplyPortDescCase);
-                    final MultipartReplyPortDesc portDesc = ((MultipartReplyPortDescCase) body)
-                            .getMultipartReplyPortDesc();
-                    for (final PortGrouping port : portDesc.getPorts()) {
-                        final short ofVersion = dContext.getDeviceState().getVersion();
-                        final TranslatorKey translatorKey = new TranslatorKey(ofVersion, PortGrouping.class.getName());
-                        final MessageTranslator<PortGrouping, FlowCapableNodeConnector> translator = dContext.oook()
-                                .lookupTranslator(translatorKey);
-                        final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, dContext, null);
-
-                        final BigInteger dataPathId = dContext.getPrimaryConnectionContext().getFeatures()
-                                .getDatapathId();
-                        final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(
-                                dataPathId.toString(), port.getPortNo(), ofVersion);
-                        final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder().setId(nodeConnectorId);
-                        ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcNodeConnector);
-
-                        ncBuilder.addAugmentation(FlowCapableNodeConnectorStatisticsData.class,
-                                new FlowCapableNodeConnectorStatisticsDataBuilder().build());
-                        final NodeConnector connector = ncBuilder.build();
-
-                        final InstanceIdentifier<NodeConnector> connectorII = nodeII.child(NodeConnector.class,
-                                connector.getKey());
-                        dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, connectorII, connector);
-                    }
+                    case OFPMPDESC:
+                        Preconditions.checkArgument(body instanceof MultipartReplyDescCase);
+                        final MultipartReplyDesc replyDesc = ((MultipartReplyDescCase) body).getMultipartReplyDesc();
+                        final FlowCapableNode fcNode = NodeStaticReplyTranslatorUtil.nodeDescTranslator(replyDesc,
+                                getIpAddressOf(dContext));
+                        final InstanceIdentifier<FlowCapableNode> fNodeII = nodeII.augmentation(FlowCapableNode.class);
+                        dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, fNodeII, fcNode);
+                        break;
+
+                    case OFPMPTABLEFEATURES:
+                        Preconditions.checkArgument(body instanceof MultipartReplyTableFeaturesCase);
+                        final MultipartReplyTableFeatures tableFeaturesMP = ((MultipartReplyTableFeaturesCase) body)
+                                .getMultipartReplyTableFeatures();
+                        final List<TableFeatures> tableFeatures = NodeStaticReplyTranslatorUtil
+                                .nodeTableFeatureTranslator(tableFeaturesMP);
+                        for (final TableFeatures tableFeature : tableFeatures) {
+                            final Short tableId = tableFeature.getTableId();
+                            final KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII =
+                                    nodeII.augmentation(FlowCapableNode.class)
+                                            .child(TableFeatures.class, new TableFeaturesKey(tableId));
+                            dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableFeaturesII, tableFeature);
+
+                            // write parent for table statistics
+                            final KeyedInstanceIdentifier<Table, TableKey> tableII =
+                                    nodeII.augmentation(FlowCapableNode.class)
+                                            .child(Table.class, new TableKey(tableId));
+                            final TableBuilder tableBld = new TableBuilder().setId(tableId)
+                                    .addAugmentation(FlowTableStatisticsData.class,
+                                            new FlowTableStatisticsDataBuilder().build());
+
+                            dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableII, tableBld.build());
+                        }
+                        break;
+
+                    case OFPMPMETERFEATURES:
+                        Preconditions.checkArgument(body instanceof MultipartReplyMeterFeaturesCase);
+                        final MultipartReplyMeterFeatures meterFeatures = ((MultipartReplyMeterFeaturesCase) body)
+                                .getMultipartReplyMeterFeatures();
+                        final NodeMeterFeatures mFeature = NodeStaticReplyTranslatorUtil
+                                .nodeMeterFeatureTranslator(meterFeatures);
+                        final InstanceIdentifier<NodeMeterFeatures> mFeatureII = nodeII
+                                .augmentation(NodeMeterFeatures.class);
+                        dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, mFeatureII, mFeature);
+                        if (0L < mFeature.getMeterFeatures().getMaxMeter().getValue()) {
+                            dContext.getDeviceState().setMeterAvailable(true);
+                        }
+                        break;
+
+                    case OFPMPGROUPFEATURES:
+                        Preconditions.checkArgument(body instanceof MultipartReplyGroupFeaturesCase);
+                        final MultipartReplyGroupFeatures groupFeatures = ((MultipartReplyGroupFeaturesCase) body)
+                                .getMultipartReplyGroupFeatures();
+                        final NodeGroupFeatures gFeature = NodeStaticReplyTranslatorUtil
+                                .nodeGroupFeatureTranslator(groupFeatures);
+                        final InstanceIdentifier<NodeGroupFeatures> gFeatureII = nodeII
+                                .augmentation(NodeGroupFeatures.class);
+                        dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gFeatureII, gFeature);
+                        break;
+
+                    case OFPMPPORTDESC:
+                        Preconditions.checkArgument(body instanceof MultipartReplyPortDescCase);
+                        final MultipartReplyPortDesc portDesc = ((MultipartReplyPortDescCase) body)
+                                .getMultipartReplyPortDesc();
+                        for (final PortGrouping port : portDesc.getPorts()) {
+                            final short ofVersion = dContext.getDeviceState().getVersion();
+                            final TranslatorKey translatorKey = new TranslatorKey(ofVersion, PortGrouping.class.getName());
+                            final MessageTranslator<PortGrouping, FlowCapableNodeConnector> translator = dContext.oook()
+                                    .lookupTranslator(translatorKey);
+                            final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, dContext, null);
+
+                            final BigInteger dataPathId = dContext.getPrimaryConnectionContext().getFeatures()
+                                    .getDatapathId();
+                            final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(
+                                    dataPathId.toString(), port.getPortNo(), ofVersion);
+                            final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder().setId(nodeConnectorId);
+                            ncBuilder.addAugmentation(FlowCapableNodeConnector.class, fcNodeConnector);
+
+                            ncBuilder.addAugmentation(FlowCapableNodeConnectorStatisticsData.class,
+                                    new FlowCapableNodeConnectorStatisticsDataBuilder().build());
+                            final NodeConnector connector = ncBuilder.build();
+
+                            final InstanceIdentifier<NodeConnector> connectorII = nodeII.child(NodeConnector.class,
+                                    connector.getKey());
+                            dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, connectorII, connector);
+                        }
 
-                    break;
+                        break;
 
-                default:
-                    throw new IllegalArgumentException("Unnexpected MultipartType " + type);
+                    default:
+                        throw new IllegalArgumentException("Unnexpected MultipartType " + type);
                 }
             }
         } catch (final Exception e) {
@@ -368,7 +375,7 @@ public class DeviceInitializationUtils {
 
     // FIXME : remove after ovs tableFeatures fix
     private static void makeEmptyTables(final DeviceContext dContext, final InstanceIdentifier<Node> nodeII,
-            final Short nrOfTables) {
+                                        final Short nrOfTables) {
         LOG.debug("About to create {} empty tables.", nrOfTables);
         for (int i = 0; i < nrOfTables; i++) {
             final short tId = (short) i;
@@ -387,8 +394,8 @@ public class DeviceInitializationUtils {
     }
 
     static void createSuccessProcessingCallback(final MultipartType type, final DeviceContext deviceContext,
-            final InstanceIdentifier<Node> nodeII,
-            final ListenableFuture<RpcResult<List<MultipartReply>>> requestContextFuture) {
+                                                final InstanceIdentifier<Node> nodeII,
+                                                final ListenableFuture<RpcResult<List<MultipartReply>>> requestContextFuture) {
         Futures.addCallback(requestContextFuture, new FutureCallback<RpcResult<List<MultipartReply>>>() {
             @Override
             public void onSuccess(final RpcResult<List<MultipartReply>> rpcResult) {
@@ -420,7 +427,7 @@ public class DeviceInitializationUtils {
     }
 
     private static ListenableFuture<RpcResult<List<MultipartReply>>> getNodeStaticInfo(final MultipartType type,
-            final DeviceContext deviceContext, final InstanceIdentifier<Node> nodeII, final short version) {
+                                                                                       final DeviceContext deviceContext, final InstanceIdentifier<Node> nodeII, final short version) {
 
         final OutboundQueue queue = deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider();
 
@@ -458,7 +465,7 @@ public class DeviceInitializationUtils {
                     public void onFailure(final Throwable t) {
                         LOG.info("Fail response from OutboundQueue for multipart type {}.", type);
                         final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
-                                .<List<MultipartReply>> failed().build();
+                                .<List<MultipartReply>>failed().build();
                         requestContext.setResult(rpcResult);
                         if (MultipartType.OFPMPTABLEFEATURES.equals(type)) {
                             makeEmptyTables(deviceContext, nodeII, deviceContext.getPrimaryConnectionContext()
@@ -472,7 +479,7 @@ public class DeviceInitializationUtils {
     }
 
     static void chainTableTrunkWriteOF10(final DeviceContext deviceContext,
-            final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture) {
+                                         final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture) {
         Futures.addCallback(deviceFeaturesFuture, new FutureCallback<List<RpcResult<List<MultipartReply>>>>() {
             @Override
             public void onSuccess(final List<RpcResult<List<MultipartReply>>> results) {
index d0ce6eddb7f948f130ddad3ff750bfc5b2c982ef..e485d1307965683055da8843f40a347e047c77b5 100644 (file)
@@ -29,9 +29,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-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.TableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
@@ -66,11 +63,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.osgi.framework.BundleContext;
 
 
@@ -79,7 +78,7 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
     private DataBroker dataBroker;
     private ProviderContext pc;
     private final BundleContext ctx;
-    private Table testTable;
+    private TableFeatures testTable;
     private Node testNode;
     private final String originalTableName = "Foo";
     private final String updatedTableName = "Bar";
@@ -93,7 +92,7 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
         dataBroker = session.getSALService(DataBroker.class);
         ctx.registerService(CommandProvider.class.getName(), this, null);
         // createTestNode();
-        // createTestTable();
+        // createTestTableFeatures();
     }
 
     private void createUserNode(String nodeRef) {
@@ -114,38 +113,27 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
         return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
     }
 
-    private TableBuilder createTestTable(String tableFeatureTypeArg) {
+    private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
 
         String tableFeatureType = tableFeatureTypeArg;
         if (tableFeatureType == null) {
             tableFeatureType = "t1";
         }
-        // Sample data , committing to DataStore
-        short id = 12;
-        TableKey key = new TableKey(id);
-
-        TableBuilder table = new TableBuilder();
-        table.setId((short) 12);
-        table.setId(id);
-        table.setKey(key);
-
 
-        List<TableFeatures> ofTablefeatures = new ArrayList<TableFeatures>();
-
-        // Skip this to send empty table features
+        final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
+        // Sample data , committing to DataStore
         if (!tableFeatureType.equals("t1")) {
 
 
-            TableFeaturesBuilder tableFeature1 = new TableFeaturesBuilder();
-            tableFeature1.setTableId((short) 0);
-            tableFeature1.setName("Table 0");
+            tableFeature.setTableId((short) 0);
+            tableFeature.setName("Table 0");
 
 
-            tableFeature1.setMetadataMatch(BigInteger.valueOf(10));
-            tableFeature1.setMetadataWrite(BigInteger.valueOf(10));
-            tableFeature1.setMaxEntries(10000L);
+            tableFeature.setMetadataMatch(BigInteger.valueOf(10));
+            tableFeature.setMetadataWrite(BigInteger.valueOf(10));
+            tableFeature.setMaxEntries(10000L);
 
-            tableFeature1.setConfig(new TableConfig(false));
+            tableFeature.setConfig(new TableConfig(false));
 
             List<TableFeatureProperties> properties = new ArrayList<TableFeatureProperties>();
 
@@ -212,16 +200,10 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
 
             TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
             propertyBld.setTableFeatureProperties(properties);
-            tableFeature1.setTableProperties(propertyBld.build());
-
-
-            ofTablefeatures.add(tableFeature1.build());
-
+            tableFeature.setTableProperties(propertyBld.build());
         }
-        table.setTableFeatures(ofTablefeatures);
-
-        testTable = table.build();
-        return table;
+        testTable = tableFeature.build();
+        return tableFeature;
     }
 
     private TableFeaturePropertiesBuilder createApplyActionsMissTblFeatureProp() {
@@ -593,18 +575,18 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
     }
 
 
-    private void writeTable(final CommandInterpreter ci, Table table) {
+    private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
         ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
 
-        InstanceIdentifier<Table> path1 = InstanceIdentifier.create(Nodes.class)
+        KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
-                        child(Table.class, new TableKey(table.getId()));
+                        child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
 
 
         modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
-        modification.merge(LogicalDatastoreType.OPERATIONAL, path1, table, true);
+        modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
         modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
-        modification.merge(LogicalDatastoreType.CONFIGURATION, path1, table, true);
+        modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
         CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
         Futures.addCallback(commitFuture, new FutureCallback<Void>() {
             @Override
@@ -631,9 +613,9 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr
             createUserNode(nref);
         }
         String tableFeatureType = ci.nextArgument();
-        TableBuilder table = createTestTable(tableFeatureType);
+        TableFeaturesBuilder tableFeaturesBld = createTestTableFeatures(tableFeatureType);
 
-        writeTable(ci, table.build());
+        writeTableFeatures(ci, tableFeaturesBld.build());
     }
 
     @Override