Replace Table with TableFeatures in FRM. 75/19375/1
authorJozef Gloncak <jgloncak@cisco.com>
Thu, 30 Apr 2015 10:55:38 +0000 (12:55 +0200)
committerJozef Gloncak <jgloncak@cisco.com>
Thu, 30 Apr 2015 11:11:38 +0000 (13:11 +0200)
Changes in flows caused also calling TableForwader (and SalTableService)
because listener was registered on Table which contains Flow.

This change changed listener directly to TableFeatures node.

Change-Id: I8ab25d0cb7f671599622870b40d5182583d937f2
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java
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/ForwardingRulesManagerImpl.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java

index 1de3a1b37d8b9a17a804f1550bd1f47d0ecce723..75c8c82204b9e2d3acbdc4f0a1573e9893982879 100644 (file)
@@ -8,10 +8,11 @@
 
 package org.opendaylight.openflowplugin.applications.frm;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
-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.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
@@ -129,7 +130,7 @@ public interface ForwardingRulesManager extends AutoCloseable {
      * Content definition method and prevent code duplicity
      * @return ForwardingRulesCommiter&lt;Table&gt;
      */
-    public ForwardingRulesCommiter<Table> getTableCommiter();
+    public ForwardingRulesCommiter<TableFeatures> getTableFeaturesCommiter();
 
     /**
      * Content definition method
index b47af791c6078c69572269aa24699d1a38401136..e7422a4a6d54df45b2426921943998e2c320b81b 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frm.impl;
 
+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 com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.Collections;
@@ -148,16 +151,19 @@ 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) {
-                       final KeyedInstanceIdentifier<Table, TableKey> tableIdent = 
-                                       nodeIdent.child(Table.class, table.getKey());
-                       this.provider.getTableCommiter().update(tableIdent, table, null ,nodeIdent) ;
-               }
-               
+            /* 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();
+                KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII
+                    = nodeIdent.child(Table.class, tableKey).child(TableFeatures.class, new TableFeaturesKey(tableKey.getId()));
+                for (TableFeatures tableFeatures : table.getTableFeatures()) {
+                    provider.getTableFeaturesCommiter().update(tableFeaturesII, tableFeatures, null, nodeIdent);
+                }
+            }
+
             /* Groups - have to be first */
             List<Group> groups = flowNode.get().getGroup() != null
                     ? flowNode.get().getGroup() : Collections.<Group> emptyList();
index fa4c24009aeb43e42b05c22a4b22fdae139c0e06..3a24971b96cdaa8d669dbfc7e4156ef6ca0a002b 100644 (file)
@@ -26,7 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalF
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+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.SalTableService;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -62,7 +62,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
     private ForwardingRulesCommiter<Flow> flowListener;
     private ForwardingRulesCommiter<Group> groupListener;
     private ForwardingRulesCommiter<Meter> meterListener;
-    private ForwardingRulesCommiter<Table> tableListener;
+    private ForwardingRulesCommiter<TableFeatures> tableListener;
     private FlowNodeReconciliation nodeListener;
 
     public ForwardingRulesManagerImpl(final DataBroker dataBroker,
@@ -85,10 +85,10 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
     public void start() {
 
         this.flowListener = new FlowForwarder(this, dataService);
-        
+
         this.groupListener = new GroupForwarder(this, dataService);
         this.meterListener = new MeterForwarder(this, dataService);
-        
+
         this.tableListener = new TableForwarder(this, dataService);
         this.nodeListener = new FlowNodeReconciliationImpl(this, dataService);
         LOG.info("ForwardingRulesManager has started successfully.");
@@ -198,7 +198,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
     }
 
     @Override
-    public ForwardingRulesCommiter<Table> getTableCommiter() {
+    public ForwardingRulesCommiter<TableFeatures> getTableFeaturesCommiter() {
         return tableListener;
     }
 
index 813e0e9e9934488e7aaaeb657d5b1bc51cfc85a0..55f4d53d6d23277aa2a4ddfaf60ead22e083ba08 100644 (file)
@@ -1,38 +1,40 @@
 package org.opendaylight.openflowplugin.applications.frm.impl;
 
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
+import java.util.Collections;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.OriginalTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
+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.table.types.rev131026.TableRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 import java.util.concurrent.Callable;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager;
-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;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.OriginalTableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableRef;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import com.google.common.base.Preconditions;
 
-public class TableForwarder extends AbstractListeningCommiter<Table> {
+public class TableForwarder extends AbstractListeningCommiter<TableFeatures> {
 
     private static final Logger LOG = LoggerFactory.getLogger(TableForwarder.class);
 
     private ListenerRegistration<TableForwarder> listenerRegistration;
 
     public TableForwarder (final ForwardingRulesManager manager, final DataBroker db) {
-        super(manager, Table.class);
+        super(manager, TableFeatures.class);
         Preconditions.checkNotNull(db, "DataBroker can not be null!");
-        final DataTreeIdentifier<Table> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath());
+        final DataTreeIdentifier<TableFeatures> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath());
 
         try {
             SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
@@ -63,41 +65,45 @@ public class TableForwarder extends AbstractListeningCommiter<Table> {
     }
 
     @Override
-    protected InstanceIdentifier<Table> getWildCardPath() {
+    protected InstanceIdentifier<TableFeatures> getWildCardPath() {
         return InstanceIdentifier.create(Nodes.class).child(Node.class)
-                .augmentation(FlowCapableNode.class).child(Table.class);
+                .augmentation(FlowCapableNode.class).child(Table.class).child(TableFeatures.class);
     }
 
     @Override
-    public void remove(final InstanceIdentifier<Table> identifier, final Table removeDataObj,
+    public void remove(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures removeDataObj,
                        final InstanceIdentifier<FlowCapableNode> nodeIdent) {
       // DO Nothing
     }
 
     @Override
-    public void update(final InstanceIdentifier<Table> identifier,
-                       final Table original, final Table update,
+    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 );
 
-        final Table originalTable = (original);
-        Table updatedTable ;
+        final TableFeatures originalTableFeatures = original;
+        TableFeatures updatedTableFeatures ;
         if( null == update)
-          updatedTable = (original);
+          updatedTableFeatures = original;
         else
-          updatedTable = (update);
+          updatedTableFeatures = update;
 
         final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
 
         builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
-        builder.setTableRef(new TableRef(identifier));
+
+        InstanceIdentifier<Table> iiToTable = identifier.firstIdentifierOf(Table.class);
+        builder.setTableRef(new TableRef(iiToTable));
 
         builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
 
-        builder.setUpdatedTable((new UpdatedTableBuilder(updatedTable)).build());
+        builder.setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(
+                Collections.singletonList(updatedTableFeatures)).build());
 
-        builder.setOriginalTable((new OriginalTableBuilder(originalTable)).build());
+        builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(
+                Collections.singletonList(originalTableFeatures)).build());
         LOG.debug( "Invoking SalTableService " ) ;
 
         if( this.provider.getSalTableService() != null )
@@ -107,7 +113,7 @@ public class TableForwarder extends AbstractListeningCommiter<Table> {
     }
 
     @Override
-    public void add(final InstanceIdentifier<Table> identifier, final Table addDataObj,
+    public void add(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures addDataObj,
                     final InstanceIdentifier<FlowCapableNode> nodeIdent) {
        //DO NOthing
     }