Code refractor and logging improvements 86/83386/6
authorShweta Chaturvedi <shweta.chaturvedi@ericsson.com>
Mon, 5 Aug 2019 10:07:09 +0000 (15:37 +0530)
committerShweta Chaturvedi <shweta.chaturvedi@ericsson.com>
Tue, 4 Feb 2020 09:12:17 +0000 (14:42 +0530)
Signed-off-by: Shweta Chaturvedi <shweta.chaturvedi@ericsson.com>
Change-Id: I0b03ed4aae82f11c3d6dbe266120d00653b4ee1d

applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleGroupForwarder.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DevicesGroupRegistry.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.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/GroupForwarder.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java

index 65382a7b2f151051e5758a7b9fe4bcf56be7d67c..6bfcfbfda2ad8df6954c4ca5a640a53f208ee8da 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.openflowplugin.applications.frm.impl;
 
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.buildGroupInstanceIdentifier;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getFlowId;
-import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
+import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdValueFromNodeIdentifier;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getTableId;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isFlowDependentOnGroup;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isGroupExistsOnDevice;
@@ -34,12 +34,9 @@ import org.opendaylight.openflowplugin.applications.frm.NodeConfigurator;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.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.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-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.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput;
@@ -85,8 +82,8 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
                        final Flow flow,
                        final InstanceIdentifier<FlowCapableNode> nodeIdent,
                        final BundleId bundleId) {
-        final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-        nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+        final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+        nodeConfigurator.enqueueJob(nodeId, () -> {
             final List<Message> messages = new ArrayList<>(1);
             String node = nodeIdent.firstKeyOf(Node.class).getId().getValue();
             BundleInnerMessage bundleInnerMessage = new BundleRemoveFlowCaseBuilder()
@@ -127,8 +124,8 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
                                                                     final Flow flow,
                                                                     final InstanceIdentifier<FlowCapableNode> nodeIdent,
                                                                     final BundleId bundleId) {
-        final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-        return nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+        final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+        return nodeConfigurator.enqueueJob(nodeId, () -> {
             BundleInnerMessage bundleInnerMessage = new BundleAddFlowCaseBuilder()
                     .setAddFlowCaseData(new AddFlowCaseDataBuilder(flow)
                             .build())
@@ -158,10 +155,10 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
         ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture;
         if (groupId != null) {
             LOG.trace("The flow {} is dependent on group {}. Checking if the group is already present",
-                    getFlowId(new FlowRef(identifier)), groupId);
+                    getFlowId(identifier), groupId);
             if (isGroupExistsOnDevice(nodeIdent, groupId, forwardingRulesManager)) {
                 LOG.trace("The dependent group {} is already programmed. Updating the flow {}", groupId,
-                        getFlowId(new FlowRef(identifier)));
+                        getFlowId(identifier));
                 resultFuture = Futures.immediateFuture(RpcResultBuilder.<AddBundleMessagesOutput>success().build());
             } else {
                 LOG.trace("The dependent group {} isn't programmed yet. Pushing the group", groupId);
@@ -191,14 +188,14 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
                                         .setMessage(messages).build())
                                 .build();
                         LOG.trace("Pushing flow update message {} to bundle {} for device {}", addBundleMessagesInput,
-                                bundleId.getValue(), getNodeIdFromNodeIdentifier(nodeIdent));
+                                bundleId.getValue(), getNodeIdValueFromNodeIdentifier(nodeIdent));
                         resultFuture = forwardingRulesManager
                                 .getSalBundleService()
                                 .addBundleMessages(addBundleMessagesInput);
                         Futures.transformAsync(resultFuture, rpcResult -> {
                             if (rpcResult.isSuccessful()) {
                                 forwardingRulesManager.getDevicesGroupRegistry()
-                                        .storeGroup(getNodeIdFromNodeIdentifier(nodeIdent), groupId);
+                                        .storeGroup(getNodeIdValueFromNodeIdentifier(nodeIdent), groupId);
                                 LOG.trace("Group {} stored in cache", groupId);
                             }
                             return Futures.immediateFuture(null);
@@ -226,7 +223,7 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
         private final InstanceIdentifier<FlowCapableNode> nodeIdent;
         private final BundleId bundleId;
         private final Message messages;
-        private final NodeId nodeId;
+        private final String nodeId;
         private final String flowId;
         private final Uint8 tableId;
         private final SettableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture;
@@ -237,9 +234,9 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
             this.bundleId = bundleId;
             this.messages = messages;
             this.resultFuture = resultFuture;
-            this.flowId = getFlowId(new FlowRef(identifier));
-            this.tableId = getTableId(new FlowTableRef(identifier));
-            this.nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+            this.flowId = getFlowId(identifier);
+            this.tableId = getTableId(identifier);
+            nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
         }
 
         @Override
@@ -255,7 +252,7 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
                         .build();
 
                 LOG.trace("Pushing flow add message {} to bundle {} for device {}", addBundleMessagesInput,
-                        bundleId.getValue(), nodeId.getValue());
+                        bundleId.getValue(), nodeId);
 
                 final ListenableFuture<RpcResult<AddBundleMessagesOutput>> addFuture =
                         forwardingRulesManager.getSalBundleService().addBundleMessages(addBundleMessagesInput);
@@ -265,7 +262,7 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
                         resultFuture.set(result);
                         if (!result.getErrors().isEmpty()) {
                             LOG.error("Flow add with flowId {} and tableId {} failed for node {} with error: {}",
-                                    flowId, tableId, nodeId.getValue(), result.getErrors().toString());
+                                    flowId, tableId, nodeId, result.getErrors().toString());
                         }
 
                     }
@@ -277,14 +274,14 @@ public class BundleFlowForwarder implements BundleMessagesCommiter<Flow> {
                 },  MoreExecutors.directExecutor());
             } else {
                 LOG.error("Error {} while pushing flow add bundle {} for device {}", rpcResult.getErrors(), messages,
-                        nodeId.getValue());
+                        nodeId);
                 resultFuture.set(rpcResult);
             }
         }
 
         @Override
         public void onFailure(Throwable throwable) {
-            LOG.error("Error while pushing flow add bundle {} for device {}", messages, nodeId.getValue());
+            LOG.error("Error while pushing flow add bundle {} for device {}", messages, nodeId);
             resultFuture.setException(throwable);
         }
     }
index e3b741fb5f29dc6b3184929ad1859c0cec14c804..243f36030418d3f15a54a0c518496e4e72d3d401 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.applications.frm.impl;
 
-import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
+import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdValueFromNodeIdentifier;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isGroupExistsOnDevice;
 
 import com.google.common.base.Preconditions;
@@ -24,7 +24,7 @@ import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager;
 import org.opendaylight.openflowplugin.applications.frm.NodeConfigurator;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-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.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput;
@@ -66,8 +66,8 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
     @Override
     public void remove(final InstanceIdentifier<Group> identifier, final Group group,
             final InstanceIdentifier<FlowCapableNode> nodeIdent, final BundleId bundleId) {
-        final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-        nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+        final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+        nodeConfigurator.enqueueJob(nodeId, () -> {
             final List<Message> messages = new ArrayList<>(1);
             BundleInnerMessage bundleInnerMessage = new BundleRemoveGroupCaseBuilder()
                     .setRemoveGroupCaseData(new RemoveGroupCaseDataBuilder(group).build())
@@ -84,7 +84,7 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
                     .setMessages(new MessagesBuilder().setMessage(messages).build())
                     .build();
             LOG.trace("Pushing group remove message {} to bundle {} for device {}", addBundleMessagesInput,
-                    bundleId.getValue(), nodeId.getValue());
+                    bundleId.getValue(), nodeId);
             final ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager
                     .getSalBundleService().addBundleMessages(addBundleMessagesInput);
             Futures.addCallback(resultFuture,
@@ -102,8 +102,8 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
                        final Group updatedGroup,
                         final InstanceIdentifier<FlowCapableNode> nodeIdent,
                        final BundleId bundleId) {
-        final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-        nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+        final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+        nodeConfigurator.enqueueJob(nodeId, () -> {
             final List<Message> messages = new ArrayList<>(1);
             BundleInnerMessage bundleInnerMessage = new BundleUpdateGroupCaseBuilder()
                     .setUpdateGroupCaseData(new UpdateGroupCaseDataBuilder(updatedGroup).build())
@@ -120,7 +120,7 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
                     .setMessages(new MessagesBuilder().setMessage(messages).build())
                     .build();
             LOG.trace("Pushing group update message {} to bundle {} for device {}", addBundleMessagesInput,
-                    bundleId.getValue(), nodeId.getValue());
+                    bundleId.getValue(), nodeId);
             final ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager
                     .getSalBundleService()
                     .addBundleMessages(addBundleMessagesInput);
@@ -137,9 +137,9 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
                                                                     final Group group,
                                                                     final InstanceIdentifier<FlowCapableNode> nodeIdent,
                                                                     final BundleId bundleId) {
-        final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+        final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
         final Uint32 groupId = group.getGroupId().getValue();
-        return nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+        return nodeConfigurator.enqueueJob(nodeId, () -> {
             if (isGroupExistsOnDevice(nodeIdent, groupId, forwardingRulesManager)) {
                 LOG.debug("Group {} already exists in the device. Ignoring the add DTCN", groupId);
                 return Futures.immediateFuture(RpcResultBuilder.<AddBundleMessagesOutput>success().build());
@@ -161,7 +161,7 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
                             .setMessage(messages).build())
                     .build();
             LOG.trace("Pushing group add message {} to bundle {} for device {}", addBundleMessagesInput,
-                    bundleId.getValue(), nodeId.getValue());
+                    bundleId.getValue(), nodeId);
             ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager
                     .getSalBundleService()
                     .addBundleMessages(addBundleMessagesInput);
@@ -174,9 +174,9 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
 
     private final class BundleAddGroupCallBack implements FutureCallback<RpcResult<AddBundleMessagesOutput>> {
         private final Uint32 groupId;
-        private final NodeId nodeId;
+        private final String nodeId;
 
-        private BundleAddGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+        private BundleAddGroupCallBack(final Uint32 groupId, final String nodeId) {
             this.groupId = groupId;
             this.nodeId = nodeId;
         }
@@ -200,9 +200,9 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
 
     private final class BundleUpdateGroupCallBack implements FutureCallback<RpcResult<AddBundleMessagesOutput>> {
         private final Uint32 groupId;
-        private final NodeId nodeId;
+        private final String nodeId;
 
-        private BundleUpdateGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+        private BundleUpdateGroupCallBack(final Uint32 groupId, final String nodeId) {
             this.groupId = groupId;
             this.nodeId = nodeId;
         }
@@ -226,9 +226,9 @@ public class BundleGroupForwarder implements BundleMessagesCommiter<Group> {
 
     private final class BundleRemoveGroupCallBack implements FutureCallback<RpcResult<AddBundleMessagesOutput>> {
         private final Uint32 groupId;
-        private final NodeId nodeId;
+        private final String nodeId;
 
-        private BundleRemoveGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+        private BundleRemoveGroupCallBack(final Uint32 groupId, final String nodeId) {
             this.groupId = groupId;
             this.nodeId = nodeId;
         }
index c464e3c50309ab38a81c37a4a91f40ea4acac021..a658f7eee63d9f58a16f46811157b81502334389 100644 (file)
@@ -12,26 +12,24 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yangtools.yang.common.Uint32;
 
 public class DevicesGroupRegistry {
-    private final Map<NodeId, List<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
+    private final Map<String, List<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
 
-    public boolean isGroupPresent(NodeId nodeId, Uint32 groupId) {
+    public boolean isGroupPresent(String nodeId, Uint32 groupId) {
         return deviceGroupMapping.get(nodeId) != null ? deviceGroupMapping.get(nodeId).contains(groupId) : false;
     }
 
-    public void storeGroup(NodeId nodeId, Uint32 groupId) {
+    public void storeGroup(String nodeId, Uint32 groupId) {
         deviceGroupMapping.computeIfAbsent(nodeId, groupIdList -> new ArrayList<>()).add(groupId);
     }
 
-    public void removeGroup(NodeId nodeId, Uint32 groupId) {
+    public void removeGroup(String nodeId, Uint32 groupId) {
         deviceGroupMapping.computeIfPresent(nodeId, (node, groupIds) -> groupIds).remove(groupId);
     }
 
-    public void clearNodeGroups(NodeId nodeId) {
+    public void clearNodeGroups(String nodeId) {
         deviceGroupMapping.remove(nodeId);
     }
-
-}
+}
\ No newline at end of file
index 7abbaad6530e57b6829b21d12babf16423e9eeee..b8cc16736ac3d0692846e4db5735e8cba16b4aca 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.openflowplugin.applications.frm.impl;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.buildGroupInstanceIdentifier;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getActiveBundle;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getFlowId;
-import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
+import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdValueFromNodeIdentifier;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isFlowDependentOnGroup;
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isGroupExistsOnDevice;
 
@@ -57,7 +57,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.Add
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-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;
@@ -128,8 +127,8 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
             if (bundleId != null) {
                 provider.getBundleFlowListener().remove(identifier, removeDataObj, nodeIdent, bundleId);
             } else {
-                final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-                nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+                final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+                nodeConfigurator.enqueueJob(nodeId, () -> {
                     final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
                     builder.setFlowRef(new FlowRef(identifier));
                     builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
@@ -184,8 +183,8 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
             if (bundleId != null) {
                 provider.getBundleFlowListener().update(identifier, original, update, nodeIdent, bundleId);
             } else {
-                final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-                nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+                final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+                nodeConfigurator.enqueueJob(nodeId, () -> {
                     final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
                     builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
                     builder.setFlowRef(new FlowRef(identifier));
@@ -201,10 +200,10 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
                     Uint32 groupId = isFlowDependentOnGroup(update);
                     if (groupId != null) {
                         LOG.trace("The flow {} is dependent on group {}. Checking if the group is already present",
-                                getFlowId(new FlowRef(identifier)), groupId);
+                                getFlowId(identifier), groupId);
                         if (isGroupExistsOnDevice(nodeIdent, groupId, provider)) {
                             LOG.trace("The dependent group {} is already programmed. Updating the flow {}", groupId,
-                                    getFlowId(new FlowRef(identifier)));
+                                    getFlowId(identifier));
                             return provider.getSalFlowService().updateFlow(builder.build());
                         } else {
                             LOG.trace("The dependent group {} isn't programmed yet. Pushing the group", groupId);
@@ -219,7 +218,7 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
                     }
 
                     LOG.trace("The flow {} is not dependent on any group. Updating the flow",
-                            getFlowId(new FlowRef(identifier)));
+                            getFlowId(identifier));
                     return provider.getSalFlowService().updateFlow(builder.build());
                 });
             }
@@ -236,8 +235,8 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
             if (bundleId != null) {
                 return provider.getBundleFlowListener().add(identifier, addDataObj, nodeIdent, bundleId);
             } else {
-                final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-                nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+                final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+                nodeConfigurator.enqueueJob(nodeId, () -> {
                     final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
 
                     builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
@@ -370,11 +369,11 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
 
     private final class AddFlowCallBack implements FutureCallback<RpcResult<AddGroupOutput>> {
         private final AddFlowInput addFlowInput;
-        private final NodeId nodeId;
+        private final String nodeId;
         private final Uint32 groupId;
         private final SettableFuture<RpcResult<AddFlowOutput>> resultFuture;
 
-        private AddFlowCallBack(final AddFlowInput addFlowInput, final NodeId nodeId, Uint32 groupId,
+        private AddFlowCallBack(final AddFlowInput addFlowInput, final String nodeId, Uint32 groupId,
                 SettableFuture<RpcResult<AddFlowOutput>> resultFuture) {
             this.addFlowInput = addFlowInput;
             this.nodeId = nodeId;
@@ -401,10 +400,10 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
                     },  MoreExecutors.directExecutor());
 
                 LOG.debug("Flow add with id {} finished without error for node {}",
-                        getFlowId(addFlowInput.getFlowRef()), nodeId.getValue());
+                        getFlowId(addFlowInput.getFlowRef()), nodeId);
             } else {
                 LOG.error("Flow add with id {} failed for node {} with error {}", getFlowId(addFlowInput.getFlowRef()),
-                        nodeId.getValue(), rpcResult.getErrors());
+                        nodeId, rpcResult.getErrors());
                 resultFuture.set(RpcResultBuilder.<AddFlowOutput>failed()
                         .withRpcErrors(rpcResult.getErrors()).build());
             }
@@ -420,11 +419,11 @@ public class FlowForwarder extends AbstractListeningCommiter<Flow> {
 
     private final class UpdateFlowCallBack implements FutureCallback<RpcResult<AddGroupOutput>> {
         private final UpdateFlowInput updateFlowInput;
-        private final NodeId nodeId;
+        private final String nodeId;
         private final Uint32 groupId;
         private final SettableFuture<RpcResult<UpdateFlowOutput>> resultFuture;
 
-        private UpdateFlowCallBack(final UpdateFlowInput updateFlowInput, final NodeId nodeId,
+        private UpdateFlowCallBack(final UpdateFlowInput updateFlowInput, final String nodeId,
                 SettableFuture<RpcResult<UpdateFlowOutput>> resultFuture, Uint32 groupId) {
             this.updateFlowInput = updateFlowInput;
             this.nodeId = nodeId;
index 01a57b0defa8620a6566175dd05c67b3bf8c664f..6aff7710ba3e136577ef92f2b36d3fbdcd06d57f 100644 (file)
@@ -69,7 +69,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey;
-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.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
@@ -159,7 +158,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     public ListenableFuture<Boolean> reconcileConfiguration(InstanceIdentifier<FlowCapableNode> connectedNode) {
         LOG.info("Triggering reconciliation for device {}", connectedNode.firstKeyOf(Node.class));
         // Clearing the group registry cache for the connected node if exists
-        NodeId nodeId = FrmUtil.getNodeIdFromNodeIdentifier(connectedNode);
+        String nodeId = FrmUtil.getNodeIdValueFromNodeIdentifier(connectedNode);
         provider.getDevicesGroupRegistry().clearNodeGroups(nodeId);
         if (provider.isStaleMarkingEnabled()) {
             LOG.info("Stale-Marking is ENABLED and proceeding with deletion of " + "stale-marked entities on switch {}",
@@ -298,6 +297,8 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     public ListenableFuture<Boolean> startReconciliation(DeviceInfo node) {
         InstanceIdentifier<FlowCapableNode> connectedNode = node.getNodeInstanceIdentifier()
                 .augmentation(FlowCapableNode.class);
+        // Clearing the group registry cache for the connected node if exists
+        provider.getDevicesGroupRegistry().clearNodeGroups(node.toString());
         return futureMap.computeIfAbsent(node, future -> reconcileConfiguration(connectedNode));
     }
 
index a2522361f6f7d51ae327638bd643d7bbe9eb60b6..79b12067e925f9f19dcb87d09f893023cc5f44f5 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.openflowplugin.applications.frm.impl;
 
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getActiveBundle;
-import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
+import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdValueFromNodeIdentifier;
 
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
@@ -27,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
@@ -40,7 +41,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey;
-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;
@@ -98,7 +98,9 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
 
     @Override
     protected InstanceIdentifier<Group> getWildCardPath() {
-        return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+        return InstanceIdentifier.create(Nodes.class)
+                .child(Node.class)
+                .augmentation(FlowCapableNode.class)
                 .child(Group.class);
     }
 
@@ -109,16 +111,18 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
         if (bundleId != null) {
             provider.getBundleGroupListener().remove(identifier, removeDataObj, nodeIdent, bundleId);
         } else {
-            final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-            nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+            final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+            nodeConfigurator.enqueueJob(nodeId, () -> {
                 final Group group = removeDataObj;
-                final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group);
-                builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
-                builder.setGroupRef(new GroupRef(identifier));
-                builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+                final RemoveGroupInput removeGroup = new RemoveGroupInputBuilder(group)
+                        .setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)))
+                        .setGroupRef(new GroupRef(identifier))
+                        .setTransactionUri(new Uri(provider.getNewTransactionId()))
+                        .build();
 
                 final ListenableFuture<RpcResult<RemoveGroupOutput>> resultFuture =
-                    this.provider.getSalGroupService().removeGroup(builder.build());
+                    this.provider.getSalGroupService()
+                            .removeGroup(removeGroup);
                 Futures.addCallback(resultFuture,
                     new RemoveGroupCallBack(removeDataObj.getGroupId().getValue(), nodeId),
                     MoreExecutors.directExecutor());
@@ -149,8 +153,8 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
         if (bundleId != null) {
             provider.getBundleGroupListener().update(identifier, original, update, nodeIdent, bundleId);
         } else {
-            final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
-            nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+            final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+            nodeConfigurator.enqueueJob(nodeId, () -> {
                 final Group originalGroup = original;
                 final Group updatedGroup = update;
                 final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder();
@@ -160,8 +164,8 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
                 builder.setUpdatedGroup(new UpdatedGroupBuilder(updatedGroup).build());
                 builder.setOriginalGroup(new OriginalGroupBuilder(originalGroup).build());
                 UpdateGroupInput updateGroupInput = builder.build();
-                final ListenableFuture<RpcResult<UpdateGroupOutput>> resultFuture;
-                resultFuture = this.provider.getSalGroupService().updateGroup(updateGroupInput);
+                final ListenableFuture<RpcResult<UpdateGroupOutput>> resultFuture = this.provider.getSalGroupService()
+                        .updateGroup(updateGroupInput);
                 LoggingFutures.addErrorLogging(resultFuture, LOG, "updateGroup");
                 Futures.addCallback(resultFuture,
                         new UpdateGroupCallBack(updateGroupInput.getOriginalGroup().getGroupId().getValue(), nodeId),
@@ -178,9 +182,9 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
         if (bundleId != null) {
             return provider.getBundleGroupListener().add(identifier, addDataObj, nodeIdent, bundleId);
         } else {
-            final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+            final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
             return nodeConfigurator
-                    .enqueueJob(nodeId.getValue(), () -> {
+                    .enqueueJob(nodeId, () -> {
                         final Group group = addDataObj;
                         final AddGroupInputBuilder builder = new AddGroupInputBuilder(group);
                         builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
@@ -244,9 +248,9 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
 
     private final class AddGroupCallBack implements FutureCallback<RpcResult<AddGroupOutput>> {
         private final Uint32 groupId;
-        private final NodeId nodeId;
+        private final String nodeId;
 
-        private AddGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+        private AddGroupCallBack(final Uint32 groupId, final String nodeId) {
             this.groupId = groupId;
             this.nodeId = nodeId;
         }
@@ -270,9 +274,9 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
 
     private final class UpdateGroupCallBack implements FutureCallback<RpcResult<UpdateGroupOutput>> {
         private final Uint32 groupId;
-        private final NodeId nodeId;
+        private final String nodeId;
 
-        private UpdateGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+        private UpdateGroupCallBack(final Uint32 groupId, final String nodeId) {
             this.groupId = groupId;
             this.nodeId = nodeId;
         }
@@ -297,9 +301,9 @@ public class GroupForwarder extends AbstractListeningCommiter<Group> {
 
     private final class RemoveGroupCallBack implements FutureCallback<RpcResult<RemoveGroupOutput>> {
         private final Uint32 groupId;
-        private final NodeId nodeId;
+        private final String nodeId;
 
-        private RemoveGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+        private RemoveGroupCallBack(final Uint32 groupId, final String nodeId) {
             this.groupId = groupId;
             this.nodeId = nodeId;
         }
index d7123b1e4e5c1edcecb479d57a566148b4d9b3e3..6cd40cab71572d100ba3da2893f440709810b75a 100644 (file)
@@ -57,14 +57,26 @@ public final class FrmUtil {
         return nodeIdent.firstKeyOf(Node.class).getId();
     }
 
+    public static String getNodeIdValueFromNodeIdentifier(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+        return getNodeIdFromNodeIdentifier(nodeIdent).getValue();
+    }
+
     public static String getFlowId(final FlowRef flowRef) {
         return flowRef.getValue().firstKeyOf(Flow.class).getId().getValue();
     }
 
+    public static String getFlowId(final InstanceIdentifier<Flow> identifier) {
+        return getFlowId(new FlowRef(identifier));
+    }
+
     public static Uint8 getTableId(final FlowTableRef flowTableRef) {
         return flowTableRef.getValue().firstKeyOf(Table.class).getId();
     }
 
+    public static Uint8 getTableId(final InstanceIdentifier<Flow> identifier) {
+        return getTableId(new FlowTableRef(identifier));
+    }
+
     public static BigInteger getDpnIdFromNodeName(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
         String nodeId = nodeIdent.firstKeyOf(Node.class).getId().getValue();
         String dpId = nodeId.substring(nodeId.lastIndexOf(SEPARATOR) + 1);
@@ -102,13 +114,15 @@ public final class FrmUtil {
             final InstanceIdentifier<FlowCapableNode> nodeIdent, final Uint32 groupId) {
         NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
         InstanceIdentifier<Group> groupInstanceId = InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class)
-                .child(Group.class, new GroupKey(new GroupId(groupId))).build();
+                .child(Node.class, new NodeKey(nodeId))
+                .augmentation(FlowCapableNode.class)
+                .child(Group.class, new GroupKey(new GroupId(groupId)))
+                .build();
         return groupInstanceId;
     }
 
     public static BundleId getActiveBundle(final InstanceIdentifier<FlowCapableNode> nodeIdent,
-            final ForwardingRulesManager provider) {
+                                           final ForwardingRulesManager provider) {
         BigInteger dpId = getDpnIdFromNodeName(nodeIdent);
         final NodeRef nodeRef = new NodeRef(nodeIdent.firstIdentifierOf(Node.class));
         GetActiveBundleInputBuilder input = new GetActiveBundleInputBuilder().setNodeId(dpId).setNode(nodeRef);
@@ -127,8 +141,9 @@ public final class FrmUtil {
     }
 
     public static boolean isGroupExistsOnDevice(final InstanceIdentifier<FlowCapableNode> nodeIdent,
-            final Uint32 groupId, final ForwardingRulesManager provider) {
-        NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+                                                final Uint32 groupId,
+                                                final ForwardingRulesManager provider) {
+        String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
         return provider.getDevicesGroupRegistry().isGroupPresent(nodeId, groupId);
     }
 }