From: Jozef Gloncak Date: Thu, 30 Apr 2015 10:55:38 +0000 (+0200) Subject: Replace Table with TableFeatures in FRM. X-Git-Tag: release/lithium~256 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=a53697b8469b0599175d7229f270fca6ecdeee4b;p=openflowplugin.git Replace Table with TableFeatures in FRM. 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 --- diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java index 1de3a1b37d..75c8c82204 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java @@ -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<Table> */ - public ForwardingRulesCommiter getTableCommiter(); + public ForwardingRulesCommiter getTableFeaturesCommiter(); /** * Content definition method diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java index b47af791c6..e7422a4a6d 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java @@ -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
tableList = flowNode.get().getTable() != null - ? flowNode.get().getTable() : Collections.
emptyList() ; - for (Table table : tableList) { - final KeyedInstanceIdentifier 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
tableList = flowNode.get().getTable() != null + ? flowNode.get().getTable() : Collections.
emptyList() ; + for (Table table : tableList) { + TableKey tableKey = table.getKey(); + KeyedInstanceIdentifier 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 groups = flowNode.get().getGroup() != null ? flowNode.get().getGroup() : Collections. emptyList(); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java index fa4c24009a..3a24971b96 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java @@ -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 flowListener; private ForwardingRulesCommiter groupListener; private ForwardingRulesCommiter meterListener; - private ForwardingRulesCommiter
tableListener; + private ForwardingRulesCommiter 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
getTableCommiter() { + public ForwardingRulesCommiter getTableFeaturesCommiter() { return tableListener; } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java index 813e0e9e99..55f4d53d6d 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java @@ -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
{ +public class TableForwarder extends AbstractListeningCommiter { private static final Logger LOG = LoggerFactory.getLogger(TableForwarder.class); private ListenerRegistration 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
treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath()); + final DataTreeIdentifier treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath()); try { SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK, @@ -63,41 +65,45 @@ public class TableForwarder extends AbstractListeningCommiter
{ } @Override - protected InstanceIdentifier
getWildCardPath() { + protected InstanceIdentifier 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
identifier, final Table removeDataObj, + public void remove(final InstanceIdentifier identifier, final TableFeatures removeDataObj, final InstanceIdentifier nodeIdent) { // DO Nothing } @Override - public void update(final InstanceIdentifier
identifier, - final Table original, final Table update, + public void update(final InstanceIdentifier identifier, + final TableFeatures original, final TableFeatures update, final InstanceIdentifier 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
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
{ } @Override - public void add(final InstanceIdentifier
identifier, final Table addDataObj, + public void add(final InstanceIdentifier identifier, final TableFeatures addDataObj, final InstanceIdentifier nodeIdent) { //DO NOthing }