Merge "Bug 3328: Set icmpv4-match into OF10 match."
authormichal rehak <mirehak@cisco.com>
Tue, 26 May 2015 19:13:20 +0000 (19:13 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 26 May 2015 19:13:20 +0000 (19:13 +0000)
113 files changed:
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/StatisticsManager.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatListenCommitFlow.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatListenCommitGroup.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatListenCommitMeter.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatListenCommitQueue.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatNodeRegistrationImpl.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatNotifyCommitPort.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatNotifyCommitTable.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatisticsManagerImpl.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/NiciraExtensionProvider.java
legacy/sal-compatibility/src/test/java/org/opendaylight/openflowplugin/legacy/sal/compatibility/test/TestToSalConversionsUtils.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/exception/DeviceDataException.java [deleted file]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/handlers/DeviceReplyProcessor.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/handlers/MultiMsgCollector.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/DeviceFlowRegistry.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/FlowRegistryKey.java [moved from openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/FlowHash.java with 92% similarity]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/StatisticsContext.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartRequestInputFactory.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManager.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/listener/MultiMsgCollectorImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/karaf/StatisticsCommandCompleter.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java [moved from openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowHashFactory.java with 51% similarity]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java [moved from openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/CommonService.java with 60% similarity]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractSimpleService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractVoidService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/FlowCapableTransactionServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/FlowRemoveService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/FlowService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/GroupService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MeterService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestCallback.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/PacketProcessingServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalEchoServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalPortServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalTableServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SimpleRequestCallback.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/VoidRequestCallback.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInAllTablesService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInTableService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllGroupsStatsService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterStatsService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllPortStatsService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesAllPortsService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesOnePortService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/FlowsInTableService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupStatsService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MatchingFlowsInTableService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterStatsService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OneQueueOnePortService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsService.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/HashUtil.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/StatisticsServiceUtil.java [deleted file]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/api/openflow/device/RpcManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/MultiMsgCollectorImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/listener/OpenflowProtocolListenerFullImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java [moved from openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowHashFactoryTest.java with 86% similarity]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/HashUtilTest.java [deleted file]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/ActionExtensionHelper.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtil.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesReplyConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/OrderComparator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorUtil.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchReactor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/FlowRemovedTranslator.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV10Test.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV13Test.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtilTest.java [new file with mode: 0644]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl2Test.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplV13Test.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorUtilTest.java
test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/AbstractDropTest.java
test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestStats.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java

index e1c3fbc1ef57b390e2614b45ed4305bc1e20d136..3edbadcc4c38d9bc82d45f554f8bc0c9922fea9a 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.openflowplugin.applications.statistics.manager;
 
 import java.util.List;
-
+import java.util.UUID;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
@@ -25,7 +25,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.q
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
 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.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.meter.statistics.rev131111.OpendaylightMeterStatisticsListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsListener;
@@ -73,12 +75,14 @@ public interface StatisticsManager extends AutoCloseable, TransactionChainListen
 
         private NodeId nodeId;
         private StatsManagerOperationType operationType = StatsManagerOperationType.DATA_COMMIT_OPER_DS;
+        private UUID nodeUUID;
 
         public StatDataStoreOperation(final StatsManagerOperationType operType, final NodeId id){
             if(operType != null){
                 operationType = operType;
             }
             nodeId = id;
+            nodeUUID = generatedUUIDForNode();
         }
 
         public final StatsManagerOperationType getType() {
@@ -89,6 +93,10 @@ public interface StatisticsManager extends AutoCloseable, TransactionChainListen
             return nodeId;
         }
 
+        public UUID getNodeUUID() {
+            return nodeUUID;
+        }
+
         /**
          * Apply all read / write (put|merge) operation for DataStore
          *
@@ -96,6 +104,41 @@ public interface StatisticsManager extends AutoCloseable, TransactionChainListen
          */
         public abstract void applyOperation(ReadWriteTransaction tx);
 
+        protected abstract UUID generatedUUIDForNode();
+
+        public InstanceIdentifier<Node> getNodeIdentifier() {
+            final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class)
+                    .child(Node.class, new NodeKey(nodeId));
+            return nodeIdent;
+        }
+
+    }
+
+
+    class Pair<L,R> {
+
+        private final L left;
+        private final R right;
+
+        public Pair(L left, R right) {
+            this.left = left;
+            this.right = right;
+        }
+
+        public L getLeft() { return left; }
+        public R getRight() { return right; }
+
+        @Override
+        public int hashCode() { return left.hashCode() ^ right.hashCode(); }
+
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof Pair)) return false;
+            Pair pairo = (Pair) o;
+            return this.left.equals(pairo.getLeft()) &&
+                    this.right.equals(pairo.getRight());
+        }
+
     }
 
     /**
@@ -222,5 +265,12 @@ public interface StatisticsManager extends AutoCloseable, TransactionChainListen
 
     StatisticsManagerConfig getConfiguration();
 
+    /**
+     * A unique UUID is generated with each node added by the statistics manager implementation in order to uniquely
+     * identify a session.
+     * @param nodeInstanceIdentifier
+     */
+    UUID getGeneratedUUIDForNode(InstanceIdentifier<Node> nodeInstanceIdentifier);
+
 }
 
index 59b215798ceee7308e1377a407a5d76b2342991e..71d34dca08b39ef7d024b2b7a642299231a71ad5 100644 (file)
@@ -18,6 +18,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
@@ -156,6 +157,11 @@ public class StatListenCommitFlow extends StatAbstractListenCommit<Flow, Openday
                     }
                 }
             }
+
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
@@ -218,6 +224,11 @@ public class StatListenCommitFlow extends StatAbstractListenCommit<Flow, Openday
                 notifyToCollectNextStatistics(nodeIdent, transId);
             }
 
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
+
         });
     }
 
index ed0b5531014b30fb23357e9dcbbc8ee2d1d5590f..f30984ffab4228dd7b9f5e847fab42b96f69cac5 100644 (file)
@@ -12,6 +12,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import java.util.UUID;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -140,6 +141,11 @@ public class StatListenCommitGroup extends StatAbstractListenCommit<Group, Opend
                 /* Notification for continue collecting statistics */
                 notifyToCollectNextStatistics(nodeIdent, transId);
             }
+
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
@@ -194,6 +200,11 @@ public class StatListenCommitGroup extends StatAbstractListenCommit<Group, Opend
                     }
                 }
             }
+
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
@@ -252,6 +263,10 @@ public class StatListenCommitGroup extends StatAbstractListenCommit<Group, Opend
                     notifyToCollectNextStatistics(nodeIdent, transId);
                 }
             }
+
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
index 74d9040c487af118214122a2ee93f025d42b6033..e0a8ec3267b800c12115c40b66220e6759aed36c 100644 (file)
@@ -12,6 +12,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import java.util.UUID;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -140,6 +141,10 @@ public class StatListenCommitMeter extends StatAbstractListenCommit<Meter, Opend
                 /* Notification for continue collecting statistics */
                 notifyToCollectNextStatistics(nodeIdent, transId);
             }
+
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
@@ -194,6 +199,11 @@ public class StatListenCommitMeter extends StatAbstractListenCommit<Meter, Opend
                     }
                 }
             }
+
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
@@ -252,6 +262,11 @@ public class StatListenCommitMeter extends StatAbstractListenCommit<Meter, Opend
                     notifyToCollectNextStatistics(nodeIdent, transId);
                 }
             }
+
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
index 834939e6b6eaf58cf04df3223998b85a9a55784f..af8cb213f50fe8308a7b8be4aedb331c451ac060 100644 (file)
@@ -15,6 +15,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+
+import java.util.UUID;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -138,6 +140,11 @@ public class StatListenCommitQueue extends StatAbstractListenCommit<Queue, Opend
                 /* Notification for continue collecting statistics */
                 notifyToCollectNextStatistics(nodeIdent, transId);
             }
+
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
index c8ce46d7c89ab94cd55872fa81f161618d406b80..6795f6f339c8ffb5a2a211a4564de45a70c7a112 100644 (file)
@@ -8,23 +8,21 @@
 
 package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.openflowplugin.applications.statistics.manager.StatNodeRegistration;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
 import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermCollector.StatCapabTypes;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager.StatDataStoreOperation;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager.StatDataStoreOperation.StatsManagerOperationType;
+import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
@@ -41,16 +39,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRem
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
 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.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
 /**
  * statistics-manager
  * org.opendaylight.openflowplugin.applications.statistics.manager.impl
@@ -116,36 +110,29 @@ public class StatNodeRegistrationImpl implements StatNodeRegistration, DataChang
         Preconditions.checkNotNull(data, "SwitchFeatures data for {} can not be null!", keyIdent);
         Preconditions.checkArgument(( ! keyIdent.isWildcarded()), "InstanceIdentifier is WildCarded!");
 
-        manager.enqueue(new StatDataStoreOperation(StatsManagerOperationType.NODE_UPDATE,nodeIdent.firstKeyOf(Node.class, NodeKey.class).getId()) {
-
-            @Override
-            public void applyOperation(final ReadWriteTransaction tx) {
-
-                final List<StatCapabTypes> statCapabTypes = new ArrayList<>();
-                Short maxCapTables = Short.valueOf("1");
-
-                final List<Class<? extends FeatureCapability>> capabilities = data.getCapabilities() != null
-                        ? data.getCapabilities() : Collections.<Class<? extends FeatureCapability>> emptyList();
-                for (final Class<? extends FeatureCapability> capability : capabilities) {
-                    if (FlowFeatureCapabilityTableStats.class.equals(capability)) {
-                        statCapabTypes.add(StatCapabTypes.TABLE_STATS);
-                    } else if (FlowFeatureCapabilityFlowStats.class.equals(capability)) {
-                        statCapabTypes.add(StatCapabTypes.FLOW_STATS);
-                    } else if (FlowFeatureCapabilityGroupStats.class.equals(capability)) {
-                        statCapabTypes.add(StatCapabTypes.GROUP_STATS);
-                    } else if (FlowFeatureCapabilityPortStats.class.equals(capability)) {
-                        statCapabTypes.add(StatCapabTypes.PORT_STATS);
-                    } else if (FlowFeatureCapabilityQueueStats.class.equals(capability)) {
-                        statCapabTypes.add(StatCapabTypes.QUEUE_STATS);
-                    }
-                }
-                maxCapTables = data.getMaxTables();
-
-                final Optional<Short> maxTables = Optional.<Short> of(maxCapTables);
-                manager.connectedNodeRegistration(nodeIdent,
-                        Collections.unmodifiableList(statCapabTypes), maxTables.get());
+        LOG.trace("STAT-MANAGER - connecting flow capable node {}", nodeIdent);
+        final List<StatCapabTypes> statCapabTypes = new ArrayList<>();
+        Short maxCapTables = Short.valueOf("1");
+
+        final List<Class<? extends FeatureCapability>> capabilities = data.getCapabilities() != null
+                ? data.getCapabilities() : Collections.<Class<? extends FeatureCapability>> emptyList();
+        for (final Class<? extends FeatureCapability> capability : capabilities) {
+            if (FlowFeatureCapabilityTableStats.class.equals(capability)) {
+                statCapabTypes.add(StatCapabTypes.TABLE_STATS);
+            } else if (FlowFeatureCapabilityFlowStats.class.equals(capability)) {
+                statCapabTypes.add(StatCapabTypes.FLOW_STATS);
+            } else if (FlowFeatureCapabilityGroupStats.class.equals(capability)) {
+                statCapabTypes.add(StatCapabTypes.GROUP_STATS);
+            } else if (FlowFeatureCapabilityPortStats.class.equals(capability)) {
+                statCapabTypes.add(StatCapabTypes.PORT_STATS);
+            } else if (FlowFeatureCapabilityQueueStats.class.equals(capability)) {
+                statCapabTypes.add(StatCapabTypes.QUEUE_STATS);
             }
-        });
+        }
+        maxCapTables = data.getMaxTables();
+
+        final Optional<Short> maxTables = Optional.<Short> of(maxCapTables);
+        manager.connectedNodeRegistration(nodeIdent, Collections.unmodifiableList(statCapabTypes), maxTables.get());
     }
 
     @Override
@@ -153,13 +140,8 @@ public class StatNodeRegistrationImpl implements StatNodeRegistration, DataChang
         Preconditions.checkArgument(nodeIdent != null, "InstanceIdentifier can not be NULL!");
         Preconditions.checkArgument(( ! nodeIdent.isWildcarded()),
                 "InstanceIdentifier {} is WildCarded!", nodeIdent);
-        manager.enqueue(new StatDataStoreOperation(StatsManagerOperationType.NODE_REMOVAL,nodeIdent.firstKeyOf(Node.class, NodeKey.class).getId()) {
-
-            @Override
-            public void applyOperation(final ReadWriteTransaction tx) {
-                manager.disconnectedNodeUnregistration(nodeIdent);
-            }
-        });
+        LOG.trace("STAT-MANAGER - disconnect flow capable node {}", nodeIdent);
+        manager.disconnectedNodeUnregistration(nodeIdent);
     }
 
 
@@ -181,6 +163,7 @@ public class StatNodeRegistrationImpl implements StatNodeRegistration, DataChang
         final InstanceIdentifier<Node> nodeIdent =
                 nodeRefIdent.firstIdentifierOf(Node.class);
         if (nodeIdent != null) {
+            LOG.debug("Received onNodeRemoved for node:{} ", nodeIdent);
             disconnectFlowCapableNode(nodeIdent);
         }
     }
index ee7f0ef9fc5e0a91702c838c9fb723cbc6c6f8ff..61a8dc03ca149fbbdddbbaa1e3f69068ace25f64 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
 import java.util.ArrayList;
 import java.util.List;
 
+import java.util.UUID;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
@@ -108,6 +109,11 @@ public class StatNotifyCommitPort extends StatAbstractNotifyCommit<OpendaylightP
                  * and they are small - don't need to wait for whole apply operation*/
                 notifyToCollectNextStatistics(nodeIdent, transId);
             }
+
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
index fede1abc76ae3bc5eaee2604015f9894a84aa0a3..d5bd27e23066d6ecf0797fb35caf5edb8969433e 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
 import java.util.ArrayList;
 import java.util.List;
 
+import java.util.UUID;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
@@ -108,6 +109,11 @@ public class StatNotifyCommitTable extends StatAbstractNotifyCommit<Opendaylight
                  * and they are small - don't need to wait to whole apply operation */
                 notifyToCollectNextStatistics(nodeIdent, transId);
             }
+
+            @Override
+            public UUID generatedUUIDForNode() {
+                return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+            }
         });
     }
 
index 347941518d9566deb960194267071299c860247e..d4779c931fab57b7918dde77cda941ebf5075237 100644 (file)
@@ -8,15 +8,20 @@
 
 package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
 
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.LinkedBlockingDeque;
 import java.util.concurrent.ThreadFactory;
-
+import java.util.concurrent.atomic.AtomicInteger;
 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
@@ -31,7 +36,6 @@ import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermC
 import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermCollector.StatCapabTypes;
 import org.opendaylight.openflowplugin.applications.statistics.manager.StatRpcMsgManager;
 import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager.StatDataStoreOperation.StatsManagerOperationType;
 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.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
@@ -48,9 +52,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
 /**
 * statistics-manager
 * org.opendaylight.openflowplugin.applications.statistics.manager.impl
@@ -73,8 +74,11 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
    private static final int MAX_BATCH = 100;
 
    private final BlockingQueue<StatDataStoreOperation> dataStoreOperQueue = new LinkedBlockingDeque<>(QUEUE_DEPTH);
+    private final Map<InstanceIdentifier<Node>, Pair<StatPermCollector, UUID>> nodeCollectorMap = new ConcurrentHashMap<>();
+    private AtomicInteger numNodesBeingCollected = new AtomicInteger(0);
 
-   private final DataBroker dataBroker;
+
+    private final DataBroker dataBroker;
    private final ExecutorService statRpcMsgManagerExecutor;
    private final ExecutorService statDataStoreOperationServ;
    private StatRpcMsgManager rpcMsgManager;
@@ -173,9 +177,18 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
 
                int ops = 0;
                do {
-                   op.applyOperation(tx);
+                   Pair<StatPermCollector, UUID> statPermCollectorUUIDPair = nodeCollectorMap.get(op.getNodeIdentifier());
+                   if (statPermCollectorUUIDPair != null && statPermCollectorUUIDPair.getRight().equals(op.getNodeUUID())) {
+                       // dont apply operations for nodes which have been disconnected or if there uuids do not match
+                       // this can happen if operations are queued and node is removed.
+                       // if the uuids dont match, it means that the stat operation are stale and belong to the same node
+                       // which got disconnected and connected again.
+                       op.applyOperation(tx);
+                       ops++;
+                   } else {
+                       LOG.debug("{} not found or UUID mismatch for statistics datastore operation", op.getNodeIdentifier());
+                   }
 
-                   ops++;
                    if (ops < MAX_BATCH) {
                        op = dataStoreOperQueue.poll();
                    } else {
@@ -185,7 +198,7 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
 
                LOG.trace("Processed {} operations, submitting transaction {}", ops, tx.getIdentifier());
 
-                   tx.submit().checkedGet();
+               tx.submit().checkedGet();
            } catch (final InterruptedException e) {
                LOG.warn("Stat Manager DS Operation thread interupted!", e);
                finishing = true;
@@ -203,19 +216,7 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
    private synchronized void cleanDataStoreOperQueue() {
        // Drain all events, making sure any blocked threads are unblocked
        while (! dataStoreOperQueue.isEmpty()) {
-           StatDataStoreOperation op = dataStoreOperQueue.poll();
-
-           // Execute the node removal clean up operation if queued in the
-           // operational queue.
-           if (op.getType() == StatsManagerOperationType.NODE_REMOVAL) {
-               try {
-                   LOG.debug("Node {} disconnected. Cleaning internal data.",op.getNodeId());
-                   op.applyOperation(null);
-               } catch (final Exception e) {
-                   LOG.warn("Unhandled exception while cleaning up internal data of node [{}]. "
-                           + "Exception {}",op.getNodeId(), e);
-               }
-           }
+           dataStoreOperQueue.poll();
        }
    }
 
@@ -249,52 +250,81 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
        }
    }
 
-   @Override
-   public void connectedNodeRegistration(final InstanceIdentifier<Node> nodeIdent,
-           final List<StatCapabTypes> statTypes, final Short nrOfSwitchTables) {
-       for (final StatPermCollector collector : statCollectors) {
-           if (collector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables)) {
-               return;
-           }
-       }
-       synchronized (statCollectorLock) {
-           for (final StatPermCollector collector : statCollectors) {
-               if (collector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables)) {
-                   return;
-               }
-           }
-           final StatPermCollectorImpl newCollector = new StatPermCollectorImpl(this,
-                   statManagerConfig.getMinRequestNetMonitorInterval(), statCollectors.size() + 1,
-                   statManagerConfig.getMaxNodesForCollector());
-           final List<StatPermCollector> statCollectorsNew = new ArrayList<>(statCollectors);
-           newCollector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables);
-           statCollectorsNew.add(newCollector);
-           statCollectors = Collections.unmodifiableList(statCollectorsNew);
-       }
-   }
+    @Override
+    public void connectedNodeRegistration(final InstanceIdentifier<Node> nodeIdent,
+            final List<StatCapabTypes> statTypes, final Short nrOfSwitchTables) {
+
+
+        Pair<StatPermCollector, UUID> collectorUUIDPair = nodeCollectorMap.get(nodeIdent);
+        if (collectorUUIDPair == null) {
+            // no collector contains this node,
+            // check if one of the collectors can accommodate it
+            // if no then add a new collector
+
+            synchronized(statCollectorLock) {
+                for (int i = statCollectors.size() - 1; i >= 0; i--) {
+                    // start from back of the list as most likely previous ones might be full
+                    final StatPermCollector aCollector = statCollectors.get(i);
+                    if (aCollector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables)) {
+                        // if the collector returns true after adding node, then return
+                        nodeCollectorMap.put(nodeIdent, new Pair(aCollector, UUID.randomUUID()));
+                        LOG.debug("NodeAdded: Num Nodes Registered with StatisticsManager:{}",
+                                numNodesBeingCollected.incrementAndGet());
+                        return;
+                    }
+                }
+                // no collector was able to add this node
+                LOG.info("No existing collector found for new node. Creating a new collector for {}", nodeIdent);
+                final StatPermCollectorImpl newCollector = new StatPermCollectorImpl(this,
+                        statManagerConfig.getMinRequestNetMonitorInterval(), statCollectors.size() + 1,
+                        statManagerConfig.getMaxNodesForCollector());
+
+                final List<StatPermCollector> statCollectorsNew = new ArrayList<>(statCollectors);
+                statCollectorsNew.add(newCollector);
+                statCollectors = Collections.unmodifiableList(statCollectorsNew);
+                nodeCollectorMap.put(nodeIdent, new Pair(newCollector, UUID.randomUUID()));
+                LOG.debug("NodeAdded: Num Nodes Registered with StatisticsManager:{}", numNodesBeingCollected.incrementAndGet());
+
+                newCollector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables);
+            }
+
+
+        } else {
+            // add to the collector, even if it rejects it.
+            collectorUUIDPair.getLeft().connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables);
+        }
+    }
 
-   @Override
-   public void disconnectedNodeUnregistration(final InstanceIdentifier<Node> nodeIdent) {
-       flowListeningCommiter.cleanForDisconnect(nodeIdent);
 
-       for (final StatPermCollector collector : statCollectors) {
-           if (collector.disconnectedNodeUnregistration(nodeIdent)) {
-               if ( ! collector.hasActiveNodes()) {
-                   synchronized (statCollectorLock) {
-                       if (collector.hasActiveNodes()) {
-                           return;
-                       }
-                       final List<StatPermCollector> newStatColl =
-                               new ArrayList<>(statCollectors);
-                       newStatColl.remove(collector);
-                       statCollectors = Collections.unmodifiableList(newStatColl);
-                   }
-               }
-               return;
-           }
-       }
-       LOG.debug("Node {} has not been removed.", nodeIdent);
-   }
+    @Override
+    public void disconnectedNodeUnregistration(final InstanceIdentifier<Node> nodeIdent) {
+        flowListeningCommiter.cleanForDisconnect(nodeIdent);
+
+        Pair<StatPermCollector, UUID> collectorUUIDPair = nodeCollectorMap.get(nodeIdent);
+        StatPermCollector collector = collectorUUIDPair.getLeft();
+        if (collector != null) {
+            nodeCollectorMap.remove(nodeIdent);
+            LOG.debug("NodeRemoved: Num Nodes Registered with StatisticsManager:{}", numNodesBeingCollected.decrementAndGet());
+
+            if (collector.disconnectedNodeUnregistration(nodeIdent)) {
+                if (!collector.hasActiveNodes()) {
+                    synchronized (statCollectorLock) {
+                        if (collector.hasActiveNodes()) {
+                            return;
+                        }
+                        final List<StatPermCollector> newStatColl = new ArrayList<>(statCollectors);
+                        newStatColl.remove(collector);
+                        statCollectors = Collections.unmodifiableList(newStatColl);
+                    }
+                }
+                LOG.info("Node:{} successfully removed by StatisticsManager ", nodeIdent);
+            } else {
+                LOG.error("Collector not disconnecting for node, no operations will be committed for this node:{}", nodeIdent);
+            }
+        } else {
+            LOG.error("Received node removed for {}, but unable to find it in nodeCollectorMap", nodeIdent);
+        }
+    }
 
    @Override
    public void registerAdditionalNodeFeature(final InstanceIdentifier<Node> nodeIdent,
@@ -353,5 +383,15 @@ public class StatisticsManagerImpl implements StatisticsManager, Runnable {
     public StatisticsManagerConfig getConfiguration() {
         return statManagerConfig;
     }
+
+    @Override
+    public UUID getGeneratedUUIDForNode(InstanceIdentifier<Node> nodeInstanceIdentifier) {
+        Pair<StatPermCollector, UUID> permCollectorUUIDPair = nodeCollectorMap.get(nodeInstanceIdentifier);
+        if (permCollectorUUIDPair != null) {
+            return permCollectorUUIDPair.getRight();
+        }
+        // we dont want to mark operations with null uuid and get NPEs later. So mark them with invalid ones
+        return UUID.fromString("invalid-uuid");
+    }
 }
 
index 0d2487aaf4c2897cc6bc7cbff562199eb02dbf5e..5c00b88df72c5fbd86b1c7cb45d30f83dd905777 100644 (file)
@@ -46,11 +46,14 @@ import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec;
+import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
+import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
 import org.opendaylight.openflowplugin.extension.api.ExtensionConverterRegistrator;
 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action.MultipathConvertor;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action.OutputRegConvertor;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action.RegLoadConvertor;
@@ -80,6 +83,14 @@ import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.R
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.TunIPv4SrcConvertor;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.TunIdConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionOutputReg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegLoad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMove;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionResubmit;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNsp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.flow.input.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionMultipathRpcAddFlowApplyActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.flow.input.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionOutputRegRpcAddFlowApplyActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.flow.input.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadRpcAddFlowApplyActionsCase;
@@ -380,6 +391,15 @@ public class NiciraExtensionProvider implements AutoCloseable {
         registerAction13(NxActionSetNshc4RpcUpdateGroupOriginalCase.class, SET_NSC4_CONVERTOR);
         registerAction13(NxActionSetNshc4RpcUpdateGroupUpdatedCase.class, SET_NSC4_CONVERTOR);
 
+
+        registerAction13(ActionRegLoad.class, REG_LOAD_CONVERTOR);
+        registerAction13(ActionRegMove.class, REG_MOVE_CONVERTOR);
+        registerAction13(ActionOutputReg.class, OUTPUT_REG_CONVERTOR);
+        registerAction13(ActionResubmit.class, RESUBMIT_CONVERTOR);
+        registerAction13(ActionMultipath.class, MULTIPATH_CONVERTOR);
+        registerAction13(ActionSetNsp.class, SET_NSP_CONVERTOR);
+        registerAction13(ActionSetNsi.class, SET_NSI_CONVERTOR);
+
         registrations.add(extensionConverterRegistrator.registerActionConvertor(NiciraUtil.createOfJavaKeyFrom(RegLoadCodec.SERIALIZER_KEY), REG_LOAD_CONVERTOR));
         registrations.add(extensionConverterRegistrator.registerActionConvertor(NiciraUtil.createOfJavaKeyFrom(RegMoveCodec.SERIALIZER_KEY), REG_MOVE_CONVERTOR));
         registrations.add(extensionConverterRegistrator.registerActionConvertor(NiciraUtil.createOfJavaKeyFrom(OutputRegCodec.SERIALIZER_KEY), OUTPUT_REG_CONVERTOR));
@@ -453,5 +473,15 @@ public class NiciraExtensionProvider implements AutoCloseable {
         TypeVersionKey<? extends Action> key = new TypeVersionKey<>(actionCaseType, EncodeConstants.OF13_VERSION_ID);
         registrations.add(extensionConverterRegistrator.registerActionConvertor(key, actionConvertor));
     }
+    /**
+     * @param actionCaseType
+     * @param actionConvertor
+     */
+    private void registerAction13(
+            Class<? extends ActionChoice> actionCaseType,
+            ConvertorActionFromOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action, ActionPath> actionConvertor) {
+        ActionSerializerKey<?> key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, actionCaseType, null);
+        registrations.add(extensionConverterRegistrator.registerActionConvertor(key, actionConvertor));
+    }
 
 }
index 3ea3dbf2c9e743902e350f56a7d103abb87c8fdd..60e5645e8d0cadc7679af573a3c2c0acf76a66ae 100644 (file)
@@ -15,6 +15,7 @@ import static org.opendaylight.openflowplugin.legacy.sal.compatibility.ProtocolC
 import static org.opendaylight.openflowplugin.legacy.sal.compatibility.ProtocolConstants.TCP;
 import static org.opendaylight.openflowplugin.legacy.sal.compatibility.ProtocolConstants.UDP;
 
+import com.google.common.net.InetAddresses;
 import java.math.BigInteger;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
@@ -22,7 +23,6 @@ import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-
 import org.junit.Test;
 import org.opendaylight.controller.sal.action.Flood;
 import org.opendaylight.controller.sal.action.FloodAll;
@@ -146,8 +146,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
 
-import com.google.common.net.InetAddresses;
-
 public class TestToSalConversionsUtils {
     // prefix:
     // od|Od = Open Daylight
@@ -160,7 +158,7 @@ public class TestToSalConversionsUtils {
         FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
         odNodeFlowBuilder = prepareOdFlowCommon();
 
-        Node node = new Node(NodeIDType.OPENFLOW,(long)1);
+        final Node node = new Node(NodeIDType.OPENFLOW,(long)1);
 
         Flow salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.other), node);
         checkSalMatch(salFlow.getMatch(), MtchType.other);
@@ -195,35 +193,35 @@ public class TestToSalConversionsUtils {
      */
     @Test
     public void testFromNodeConnectorRef() throws ConstructionException {
-        Node node = new Node(NodeIDType.OPENFLOW, 42L);
-        NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node);
+        final Node node = new Node(NodeIDType.OPENFLOW, 42L);
+        final NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node);
         assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString());
     }
 
     @Test
     public void testActionFrom() throws ConstructionException {
         // Bug 2021: Convert AD-SAL notation into MD-SAL notation before calling NodeConnector
-        Node node = new Node(NodeIDType.OPENFLOW, 42L);
-        List<Action> odActions = new ArrayList<>();
+        final Node node = new Node(NodeIDType.OPENFLOW, 42L);
+        final List<Action> odActions = new ArrayList<>();
 
-        OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
+        final OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
         outputActionBuilder.setOutputNodeConnector(new Uri("openflow:42:CONTROLLER"));
-        OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
+        final OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
         outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
         odActions.add(new ActionBuilder().setAction(outputActionCaseBuilder.build()).build());
 
-        List<org.opendaylight.controller.sal.action.Action> targetAction =
+        final List<org.opendaylight.controller.sal.action.Action> targetAction =
                 ToSalConversionsUtils.actionFrom(odActions, node);
         assertNotNull(targetAction);
         assertTrue( Output.class.isInstance(targetAction.get(0)) );
-        Output targetActionOutput = (Output) targetAction.get(0);
-        NodeConnector port = targetActionOutput.getPort();
+        final Output targetActionOutput = (Output) targetAction.get(0);
+        final NodeConnector port = targetActionOutput.getPort();
         assertNotNull(port);
         assertEquals(port.getType(), NodeConnectorIDType.CONTROLLER);
         assertEquals(port.getID(), org.opendaylight.controller.sal.core.NodeConnector.SPECIALNODECONNECTORID);
     }
 
-    private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) throws ConstructionException {
+    private void checkSalMatch(final org.opendaylight.controller.sal.match.Match match, final MtchType mt) throws ConstructionException {
         switch (mt) {
         case other:
             /*assertNotNull("DL_DST isn't equal.", "3C:A9:F4:00:E0:C8",
@@ -231,8 +229,8 @@ public class TestToSalConversionsUtils {
             assertEquals("DL_SRC isn't equal.", "24:77:03:7C:C5:F1",
                     new String((byte[]) match.getField(MatchType.DL_SRC).getValue()));
             */
-            Node node = new Node(NodeIDType.OPENFLOW, 12L);
-            NodeConnector port = new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf((short)345), node);
+            final Node node = new Node(NodeIDType.OPENFLOW, 12L);
+            final NodeConnector port = new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf((short)345), node);
             assertEquals("IN_PORT isn't equal.", port, match.getField(MatchType.IN_PORT).getValue());
             assertEquals("DL_TYPE isn't equal.", (short) 0xffff, (short) match.getField(MatchType.DL_TYPE).getValue());
             assertEquals("NW_TOS isn't equal.", (byte) 0x33, (byte) match.getField(MatchType.NW_TOS).getValue());
@@ -293,7 +291,7 @@ public class TestToSalConversionsUtils {
 
     }
 
-    private void checkSalFlow(Flow salFlow) {
+    private void checkSalFlow(final Flow salFlow) {
         assertTrue("Id value is incorrect.", salFlow.getId() == 9223372036854775807L);
         assertTrue("Hard timeout is incorrect.", salFlow.getHardTimeout() == 32767);
         assertTrue("Iddle timeout is incorrect.", salFlow.getIdleTimeout() == 32767);
@@ -302,7 +300,7 @@ public class TestToSalConversionsUtils {
         checkSalActions(salFlow.getActions());
     }
 
-    private void checkSalActions(List<org.opendaylight.controller.sal.action.Action> actions) {
+    private void checkSalActions(final List<org.opendaylight.controller.sal.action.Action> actions) {
         checkSalAction(actions, Flood.class, 1);
         checkSalAction(actions, FloodAll.class, 1);
         checkSalAction(actions, HwPath.class, 1);
@@ -325,15 +323,15 @@ public class TestToSalConversionsUtils {
         checkSalAction(actions, SwPath.class, 1);
     }
 
-    private void checkSalAction(List<org.opendaylight.controller.sal.action.Action> actions, Class<?> cls,
-            int numOfActions) {
+    private void checkSalAction(final List<org.opendaylight.controller.sal.action.Action> actions, final Class<?> cls,
+            final int numOfActions) {
         checkSalAction(actions, cls, numOfActions, false);
     }
 
-    private void checkSalAction(List<org.opendaylight.controller.sal.action.Action> actions, Class<?> cls,
-            int numOfActions, boolean additionalCheck) {
+    private void checkSalAction(final List<org.opendaylight.controller.sal.action.Action> actions, final Class<?> cls,
+            final int numOfActions, final boolean additionalCheck) {
         int numOfEqualClass = 0;
-        for (org.opendaylight.controller.sal.action.Action action : actions) {
+        for (final org.opendaylight.controller.sal.action.Action action : actions) {
             if (action.getClass().equals(cls)) {
                 if (additionalCheck) {
                     additionalActionCheck(action);
@@ -346,7 +344,7 @@ public class TestToSalConversionsUtils {
     }
 
     // implement special checks
-    private void additionalActionCheck(org.opendaylight.controller.sal.action.Action action) {
+    private void additionalActionCheck(final org.opendaylight.controller.sal.action.Action action) {
         if (action instanceof Output) {
             // ((Output)action).getPort() //TODO finish check when mapping will
             // be defined
@@ -361,13 +359,13 @@ public class TestToSalConversionsUtils {
         } else if (action instanceof SetDlType) {
             assertEquals("Wrong value for action SetDlType for.", 513L, ((SetDlType) action).getDlType());
         } else if (action instanceof SetNextHop) {
-            InetAddress inetAddress = ((SetNextHop) action).getAddress();
+            final InetAddress inetAddress = ((SetNextHop) action).getAddress();
             checkIpAddresses(inetAddress, "192.168.100.100", "2001:db8:85a3::8a2e:370:7334");
         } else if (action instanceof SetNwDst) {
-            InetAddress inetAddress = ((SetNwDst) action).getAddress();
+            final InetAddress inetAddress = ((SetNwDst) action).getAddress();
             checkIpAddresses(inetAddress, "192.168.100.101", "2001:db8:85a3::8a2e:370:7335");
         } else if (action instanceof SetNwSrc) {
-            InetAddress inetAddress = ((SetNwSrc) action).getAddress();
+            final InetAddress inetAddress = ((SetNwSrc) action).getAddress();
             checkIpAddresses(inetAddress, "192.168.100.102", "2001:db8:85a3::8a2e:370:7336");
         } else if (action instanceof SetNwTos) {
             assertEquals("Wrong value for action SetNwTos for tos.", 63, ((SetNwTos) action).getNwTos());
@@ -384,7 +382,7 @@ public class TestToSalConversionsUtils {
         }
     }
 
-    private void checkIpAddresses(InetAddress inetAddress, String ipv4, String ipv6) {
+    private void checkIpAddresses(final InetAddress inetAddress, final String ipv4, final String ipv6) {
         if (inetAddress instanceof Inet4Address) {
             assertEquals("Wrong value for IP address.", ipv4, InetAddresses.toAddrString(inetAddress));
         } else if (inetAddress instanceof Inet6Address) {
@@ -393,7 +391,7 @@ public class TestToSalConversionsUtils {
     }
 
     private FlowAddedBuilder prepareOdFlowCommon() {
-        FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
+        final FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
 
         odNodeFlowBuilder.setCookie(new FlowCookie(new BigInteger("9223372036854775807")));
         odNodeFlowBuilder.setHardTimeout(32767);
@@ -403,39 +401,39 @@ public class TestToSalConversionsUtils {
         return odNodeFlowBuilder;
     }
 
-    private NodeFlow prepareOdFlow(FlowAddedBuilder odNodeFlowBuilder, MtchType mt) {
+    private NodeFlow prepareOdFlow(final FlowAddedBuilder odNodeFlowBuilder, final MtchType mt) {
         odNodeFlowBuilder.setMatch(prepOdMatch(mt));
         return odNodeFlowBuilder.build();
     }
 
     private Instructions prepareOdActions() {
-        List<Action> odActions = new ArrayList<>();
-
-        ControllerActionCaseBuilder controllerActionBuilder = new ControllerActionCaseBuilder();
-        DropActionCaseBuilder dropActionBuilder = new DropActionCaseBuilder();
-        FloodActionCaseBuilder floodActionBuilder = new FloodActionCaseBuilder();
-        FloodAllActionCaseBuilder floodAllActionBuilder = new FloodAllActionCaseBuilder();
-        HwPathActionCaseBuilder hwPathActionBuilder = new HwPathActionCaseBuilder();
-        LoopbackActionCaseBuilder loopbackActionBuilder = new LoopbackActionCaseBuilder();
-        OutputActionCaseBuilder outputActionBuilder = new OutputActionCaseBuilder();
-        PopMplsActionCaseBuilder popMplsActionBuilder = new PopMplsActionCaseBuilder();
-        PopVlanActionCaseBuilder popVlanActionBuilder = new PopVlanActionCaseBuilder();
-        PushMplsActionCaseBuilder pushMplsActionBuilder = new PushMplsActionCaseBuilder();
-        PushPbbActionCaseBuilder pushPbbActionBuilder = new PushPbbActionCaseBuilder();
-        PushVlanActionCaseBuilder pushVlanActionBuilder = new PushVlanActionCaseBuilder();
-        SetDlDstActionCaseBuilder setDlDstActionBuilder = new SetDlDstActionCaseBuilder();
-        SetDlSrcActionCaseBuilder setDlSrcActionBuilder = new SetDlSrcActionCaseBuilder();
-        SetDlTypeActionCaseBuilder setDlTypeActionBuilder = new SetDlTypeActionCaseBuilder();
-        SetMplsTtlActionCaseBuilder setMplsTtlActionBuilder = new SetMplsTtlActionCaseBuilder();
-        SetNwTosActionCaseBuilder setNwTosActionBuilder = new SetNwTosActionCaseBuilder();
-        SetNwTtlActionCaseBuilder setNwTtlActionBuilder = new SetNwTtlActionCaseBuilder();
-        SetQueueActionCaseBuilder setQueueActionBuilder = new SetQueueActionCaseBuilder();
-        SetTpDstActionCaseBuilder setTpDstActionBuilder = new SetTpDstActionCaseBuilder();
-        SetTpSrcActionCaseBuilder setTpSrcActionBuilder = new SetTpSrcActionCaseBuilder();
-        SetVlanCfiActionCaseBuilder setVlanCfiActionBuilder = new SetVlanCfiActionCaseBuilder();
-        SetVlanIdActionCaseBuilder setVlanIdActionBuilder = new SetVlanIdActionCaseBuilder();
-        SetVlanPcpActionCaseBuilder setVlanPcpActionBuilder = new SetVlanPcpActionCaseBuilder();
-        SwPathActionCaseBuilder swPathActionBuilder = new SwPathActionCaseBuilder();
+        final List<Action> odActions = new ArrayList<>();
+
+        final ControllerActionCaseBuilder controllerActionBuilder = new ControllerActionCaseBuilder();
+        final DropActionCaseBuilder dropActionBuilder = new DropActionCaseBuilder();
+        final FloodActionCaseBuilder floodActionBuilder = new FloodActionCaseBuilder();
+        final FloodAllActionCaseBuilder floodAllActionBuilder = new FloodAllActionCaseBuilder();
+        final HwPathActionCaseBuilder hwPathActionBuilder = new HwPathActionCaseBuilder();
+        final LoopbackActionCaseBuilder loopbackActionBuilder = new LoopbackActionCaseBuilder();
+        final OutputActionCaseBuilder outputActionBuilder = new OutputActionCaseBuilder();
+        final PopMplsActionCaseBuilder popMplsActionBuilder = new PopMplsActionCaseBuilder();
+        final PopVlanActionCaseBuilder popVlanActionBuilder = new PopVlanActionCaseBuilder();
+        final PushMplsActionCaseBuilder pushMplsActionBuilder = new PushMplsActionCaseBuilder();
+        final PushPbbActionCaseBuilder pushPbbActionBuilder = new PushPbbActionCaseBuilder();
+        final PushVlanActionCaseBuilder pushVlanActionBuilder = new PushVlanActionCaseBuilder();
+        final SetDlDstActionCaseBuilder setDlDstActionBuilder = new SetDlDstActionCaseBuilder();
+        final SetDlSrcActionCaseBuilder setDlSrcActionBuilder = new SetDlSrcActionCaseBuilder();
+        final SetDlTypeActionCaseBuilder setDlTypeActionBuilder = new SetDlTypeActionCaseBuilder();
+        final SetMplsTtlActionCaseBuilder setMplsTtlActionBuilder = new SetMplsTtlActionCaseBuilder();
+        final SetNwTosActionCaseBuilder setNwTosActionBuilder = new SetNwTosActionCaseBuilder();
+        final SetNwTtlActionCaseBuilder setNwTtlActionBuilder = new SetNwTtlActionCaseBuilder();
+        final SetQueueActionCaseBuilder setQueueActionBuilder = new SetQueueActionCaseBuilder();
+        final SetTpDstActionCaseBuilder setTpDstActionBuilder = new SetTpDstActionCaseBuilder();
+        final SetTpSrcActionCaseBuilder setTpSrcActionBuilder = new SetTpSrcActionCaseBuilder();
+        final SetVlanCfiActionCaseBuilder setVlanCfiActionBuilder = new SetVlanCfiActionCaseBuilder();
+        final SetVlanIdActionCaseBuilder setVlanIdActionBuilder = new SetVlanIdActionCaseBuilder();
+        final SetVlanPcpActionCaseBuilder setVlanPcpActionBuilder = new SetVlanPcpActionCaseBuilder();
+        final SwPathActionCaseBuilder swPathActionBuilder = new SwPathActionCaseBuilder();
 
         prepareActionOutput(outputActionBuilder);
         prepareActionPushVlan(pushVlanActionBuilder);
@@ -479,133 +477,133 @@ public class TestToSalConversionsUtils {
         odActions.add(new ActionBuilder().setAction(swPathActionBuilder.build()).build());
 
 
-        ApplyActionsCase innerInst = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(odActions).build()).build();
-        Instruction applyActions = new InstructionBuilder().setInstruction(innerInst).build();
-        List<Instruction> instructions = Collections.singletonList(applyActions );
-        InstructionsBuilder instBuilder = new InstructionsBuilder();
+        final ApplyActionsCase innerInst = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(odActions).build()).build();
+        final Instruction applyActions = new InstructionBuilder().setInstruction(innerInst).build();
+        final List<Instruction> instructions = Collections.singletonList(applyActions );
+        final InstructionsBuilder instBuilder = new InstructionsBuilder();
 
         instBuilder.setInstruction(instructions);
 
         return instBuilder.build();
     }
 
-    private void prepareActionSetVlanPcp(SetVlanPcpActionCaseBuilder wrapper) {
-        SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
+    private void prepareActionSetVlanPcp(final SetVlanPcpActionCaseBuilder wrapper) {
+        final SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
         setVlanPcpActionBuilder.setVlanPcp(new VlanPcp((short) 7));
         wrapper.setSetVlanPcpAction(setVlanPcpActionBuilder.build());
     }
 
-    private void prepareActionSetVladId(SetVlanIdActionCaseBuilder wrapper) {
-        SetVlanIdActionBuilder setVlanIdActionBuilder = new SetVlanIdActionBuilder();
+    private void prepareActionSetVladId(final SetVlanIdActionCaseBuilder wrapper) {
+        final SetVlanIdActionBuilder setVlanIdActionBuilder = new SetVlanIdActionBuilder();
         setVlanIdActionBuilder.setVlanId(new VlanId(4095));
         wrapper.setSetVlanIdAction(setVlanIdActionBuilder.build());
     }
 
-    private void prepareActionSetVlanCfi(SetVlanCfiActionCaseBuilder wrapper) {
-        SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
+    private void prepareActionSetVlanCfi(final SetVlanCfiActionCaseBuilder wrapper) {
+        final SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
         setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(1));
         wrapper.setSetVlanCfiAction(setVlanCfiActionBuilder.build());
     }
 
-    private void prepareActionSetTpDst(SetTpDstActionCaseBuilder wrapper) {
-        SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
+    private void prepareActionSetTpDst(final SetTpDstActionCaseBuilder wrapper) {
+        final SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
         setTpDstActionBuilder.setPort(new PortNumber(65535));
         wrapper.setSetTpDstAction(setTpDstActionBuilder.build());
     }
 
-    private void prepareActionSetTpSrc(SetTpSrcActionCaseBuilder wrapper) {
-        SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
+    private void prepareActionSetTpSrc(final SetTpSrcActionCaseBuilder wrapper) {
+        final SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
         setTpSrcActionBuilder.setPort(new PortNumber(65535));
         wrapper.setSetTpSrcAction(setTpSrcActionBuilder.build());
     }
 
-    private void prepareActionSetNwTos(SetNwTosActionCaseBuilder wrapper) {
-        SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
+    private void prepareActionSetNwTos(final SetNwTosActionCaseBuilder wrapper) {
+        final SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
         setNwTosActionBuilder.setTos(252);
         wrapper.setSetNwTosAction(setNwTosActionBuilder.build());
     }
 
-    private void prepareActionSetNwSrc(List<Action> odActions) {
+    private void prepareActionSetNwSrc(final List<Action> odActions) {
         // test case for IPv4
-        SetNwSrcActionBuilder setNwSrcActionBuilderIpv4 = new SetNwSrcActionBuilder();
+        final SetNwSrcActionBuilder setNwSrcActionBuilderIpv4 = new SetNwSrcActionBuilder();
         setNwSrcActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.102"));
         odActions.add(new ActionBuilder().setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilderIpv4.build()).build()).build());
 
         // test case for IPv6
-        SetNwSrcActionBuilder setNwSrcActionBuilderIpv6 = new SetNwSrcActionBuilder();
-        setNwSrcActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7336"));
+        final SetNwSrcActionBuilder setNwSrcActionBuilderIpv6 = new SetNwSrcActionBuilder();
+        setNwSrcActionBuilderIpv6.setAddress(prapareIpv6Prefix("2001:0db8:85a3:0000:0000:8a2e:0370:7336/128"));
         odActions.add(new ActionBuilder().setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilderIpv6.build()).build()).build());
     }
 
-    private void prepareActionSetNwDst(List<Action> odActions) {
+    private void prepareActionSetNwDst(final List<Action> odActions) {
         // test case for IPv4
 
-        SetNwDstActionBuilder setNwDstActionBuilderIpv4 = new SetNwDstActionBuilder();
+        final SetNwDstActionBuilder setNwDstActionBuilderIpv4 = new SetNwDstActionBuilder();
         setNwDstActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.101"));
         odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv4.build()).build()).build());
 
         // test case for IPv6
-        SetNwDstActionBuilder setNwDstActionBuilderIpv6 = new SetNwDstActionBuilder();
-        setNwDstActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7335"));
+        final SetNwDstActionBuilder setNwDstActionBuilderIpv6 = new SetNwDstActionBuilder();
+        setNwDstActionBuilderIpv6.setAddress(prapareIpv6Prefix("2001:0db8:85a3:0000:0000:8a2e:0370:7335/128"));
         odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv6.build()).build()).build());
     }
 
-    private void prepareActionNextHop(List<Action> odActions) {
+    private void prepareActionNextHop(final List<Action> odActions) {
         // test case for IPv4
-        SetNextHopActionBuilder setNextHopActionBuilderIpv4 = new SetNextHopActionBuilder();
+        final SetNextHopActionBuilder setNextHopActionBuilderIpv4 = new SetNextHopActionBuilder();
         setNextHopActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.100"));
         odActions.add(new ActionBuilder().setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilderIpv4.build()).build()).build());
 
         // test case for IPv6
-        SetNextHopActionBuilder setNextHopActionBuilderIpv6 = new SetNextHopActionBuilder();
-        setNextHopActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334"));
+        final SetNextHopActionBuilder setNextHopActionBuilderIpv6 = new SetNextHopActionBuilder();
+        setNextHopActionBuilderIpv6.setAddress(prapareIpv6Prefix("2001:0db8:85a3:0000:0000:8a2e:0370:7334/128"));
         odActions.add(new ActionBuilder().setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilderIpv6.build()).build()).build());
     }
 
-    private Address prapareIpv4Address(String ipv4Address) {
-        Ipv4Builder ipv4Builder = new Ipv4Builder();
+    private Address prapareIpv4Address(final String ipv4Address) {
+        final Ipv4Builder ipv4Builder = new Ipv4Builder();
         ipv4Builder.setIpv4Address(new Ipv4Prefix(ipv4Address + "/32"));
         return ipv4Builder.build();
     }
 
-    private Address prapareIpv6Address(String ipv6Address) {
-        Ipv6Builder ipv6Builder = new Ipv6Builder();
+    private Address prapareIpv6Prefix(final String ipv6Address) {
+        final Ipv6Builder ipv6Builder = new Ipv6Builder();
         ipv6Builder.setIpv6Address(new Ipv6Prefix(ipv6Address));
         return ipv6Builder.build();
     }
 
-    private void prepareActionSetDlType(SetDlTypeActionCaseBuilder wrapper) {
-        SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
+    private void prepareActionSetDlType(final SetDlTypeActionCaseBuilder wrapper) {
+        final SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
         setDlTypeActionBuilder.setDlType(new EtherType(513L));
         wrapper.setSetDlTypeAction(setDlTypeActionBuilder.build());
     }
 
-    private void prepareActionSetDlSrc(SetDlSrcActionCaseBuilder wrapper) {
-        SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
+    private void prepareActionSetDlSrc(final SetDlSrcActionCaseBuilder wrapper) {
+        final SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
         setDlSrcActionBuilder.setAddress(new MacAddress("24:77:03:7C:C5:F1"));
         wrapper.setSetDlSrcAction(setDlSrcActionBuilder.build());
     }
 
-    private void prepareActionSetDlDst(SetDlDstActionCaseBuilder wrapper) {
-        SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
+    private void prepareActionSetDlDst(final SetDlDstActionCaseBuilder wrapper) {
+        final SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
         setDlDstActionBuilder.setAddress(new MacAddress("3C:A9:F4:00:E0:C8"));
         wrapper.setSetDlDstAction(setDlDstActionBuilder.build());
     }
 
-    private void prepareActionPushVlan(PushVlanActionCaseBuilder wrapper) {
-        PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
+    private void prepareActionPushVlan(final PushVlanActionCaseBuilder wrapper) {
+        final PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
         pushVlanActionBuilder.setTag(0x8100); // 12 bit
         wrapper.setPushVlanAction(pushVlanActionBuilder.build());
     }
 
-    private void prepareActionOutput(OutputActionCaseBuilder wrapper) {
-        OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
+    private void prepareActionOutput(final OutputActionCaseBuilder wrapper) {
+        final OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
         outputActionBuilder.setOutputNodeConnector(new Uri("openflow:1:1"));
         wrapper.setOutputAction(outputActionBuilder.build());
     }
 
-    private Match prepOdMatch(MtchType mt) {
-        MatchBuilder odMatchBuilder = new MatchBuilder();
+    private Match prepOdMatch(final MtchType mt) {
+        final MatchBuilder odMatchBuilder = new MatchBuilder();
         switch (mt) {
         case other:
             odMatchBuilder.setInPort(new NodeConnectorId("openflow:12:345"));
@@ -641,7 +639,7 @@ public class TestToSalConversionsUtils {
     }
 
     private Layer4Match prepLayer4MatchUdp() {
-        UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
+        final UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
 
         udpMatchBuilder.setUdpSourcePort(new PortNumber(11));
         udpMatchBuilder.setUdpDestinationPort(new PortNumber(12));
@@ -650,7 +648,7 @@ public class TestToSalConversionsUtils {
     }
 
     private Layer4Match prepLayer4MatchTcp() {
-        TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
+        final TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
 
         tcpMatchBuilder.setTcpSourcePort(new PortNumber(21));
         tcpMatchBuilder.setTcpDestinationPort(new PortNumber(22));
@@ -659,7 +657,7 @@ public class TestToSalConversionsUtils {
     }
 
     private Layer4Match prepLayer4MatchSctp() {
-        SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
+        final SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
 
         sctpMatchBuilder.setSctpSourcePort(new PortNumber(31));
         sctpMatchBuilder.setSctpDestinationPort(new PortNumber(32));
@@ -668,38 +666,38 @@ public class TestToSalConversionsUtils {
     }
 
     private Layer3Match prepLayer3MatchIpv4() {
-        Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
+        final Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
         ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("192.168.1.104/32"));
         ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("192.168.1.105/32"));
         return ipv4MatchBuilder.build();
     }
 
     private Layer3Match prepLayer3MatchIpv6() {
-        Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
-        ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7334"));
-        ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7335"));
+        final Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
+        ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7334/128"));
+        ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7335/128"));
         return ipv6MatchBuilder.build();
     }
 
     private Layer3Match prepLayer3MatchArp() {
-        ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
+        final ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
         arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix("192.168.1.101/32"));
         arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix("192.168.1.102/32"));
 
-        ArpSourceHardwareAddressBuilder arpSourAddressBuild = new ArpSourceHardwareAddressBuilder();
+        final ArpSourceHardwareAddressBuilder arpSourAddressBuild = new ArpSourceHardwareAddressBuilder();
         arpSourAddressBuild.setAddress(new MacAddress("22:44:66:88:AA:CC"));
         arpMatchBuilder.setArpSourceHardwareAddress(arpSourAddressBuild.build());
 
-        ArpTargetHardwareAddressBuilder arpTarAddressBuild = new ArpTargetHardwareAddressBuilder();
+        final ArpTargetHardwareAddressBuilder arpTarAddressBuild = new ArpTargetHardwareAddressBuilder();
         arpTarAddressBuild.setAddress(new MacAddress("11:33:55:77:BB:DD"));
         arpMatchBuilder.setArpTargetHardwareAddress(arpTarAddressBuild.build());
         return arpMatchBuilder.build();
     }
 
     private VlanMatch prepVlanMatch() {
-        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+        final VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
 
-        VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().setVlanId(new VlanId(0xfff));
+        final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().setVlanId(new VlanId(0xfff));
         vlanMatchBuilder.setVlanId(vlanIdBuilder.setVlanIdPresent(true).build());
         vlanMatchBuilder.setVlanPcp(new VlanPcp((short) 0x7));
 
@@ -707,9 +705,9 @@ public class TestToSalConversionsUtils {
     }
 
     private VlanMatch prepVlanNoneMatch() {
-        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+        final VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
 
-        VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().
+        final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().
             setVlanIdPresent(false);
         vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
 
@@ -717,14 +715,14 @@ public class TestToSalConversionsUtils {
     }
 
     private IpMatch prepIpMatch() {
-        IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
+        final IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
         ipMatchBuilder.setIpDscp(new Dscp((short) 0x33));
         ipMatchBuilder.setIpProtocol((short) 0x3f);
         return ipMatchBuilder.build();
     }
 
     private EthernetMatch prepEthernetMatch() {
-        EthernetMatchBuilder odEthernetMatchBuilder = new EthernetMatchBuilder();
+        final EthernetMatchBuilder odEthernetMatchBuilder = new EthernetMatchBuilder();
         odEthernetMatchBuilder.setEthernetDestination(prepEthDest());
         odEthernetMatchBuilder.setEthernetSource(prepEthSour());
         odEthernetMatchBuilder.setEthernetType(prepEthType());
@@ -732,19 +730,19 @@ public class TestToSalConversionsUtils {
     }
 
     private EthernetType prepEthType() {
-        EthernetTypeBuilder ethTypeBuild = new EthernetTypeBuilder();
+        final EthernetTypeBuilder ethTypeBuild = new EthernetTypeBuilder();
         ethTypeBuild.setType(new EtherType(0xffffL));
         return ethTypeBuild.build();
     }
 
     private EthernetSource prepEthSour() {
-        EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder();
+        final EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder();
         ethSourBuild.setAddress(new MacAddress("24:77:03:7C:C5:F1"));
         return ethSourBuild.build();
     }
 
     private EthernetDestination prepEthDest() {
-        EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder();
+        final EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder();
         ethDestBuild.setAddress(new MacAddress("3C:A9:F4:00:E0:C8"));
         return ethDestBuild.build();
     }
index de5669500b410af82038d45793aa07b6212c123b..eb17433141d3bc6df8fe36b55b560ffda45afd3f 100644 (file)
@@ -10,13 +10,14 @@ package org.opendaylight.openflowplugin.api.openflow.device;
 
 import io.netty.util.Timeout;
 import java.math.BigInteger;
+import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginTimer;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextClosedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
@@ -27,6 +28,7 @@ import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRe
 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -87,6 +89,12 @@ public interface DeviceContext extends AutoCloseable,
      */
     <T extends DataObject> void addDeleteToTxChain(final LogicalDatastoreType store, final InstanceIdentifier<T> path);
 
+    /**
+     * Method submits Transaction to DataStore.
+     * @return transaction is submitted successfully
+     */
+    boolean submitTransaction();
+
     /**
      * Method exposes transaction created for device
      * represented by this context. This read only transaction has a fresh dataStore snapshot.
@@ -160,11 +168,7 @@ public interface DeviceContext extends AutoCloseable,
      */
     void addDeviceContextClosedHandler(DeviceContextClosedHandler deviceContextClosedHandler);
 
-    void startGatheringOperationsToOneTransaction();
-
-    void commitOperationsGatheredInOneTransaction();
-
-    MultiMsgCollector getMultiMsgCollector();
+    MultiMsgCollector getMultiMsgCollector(final RequestContext<List<MultipartReply>> requestContext);
 
     Long getReservedXid();
 
@@ -175,10 +179,14 @@ public interface DeviceContext extends AutoCloseable,
 
 
     /**
-     * Method registers outbound queue handler that should be invalidated when device context is closed.s
-     * @param outboundQueueHandlerRegistration
+     * Method registers outbound queue provider into current device context's primary connection adapter.
+     *
+     * @param outboundQueueProvider
+     * @param maxQueueDepth
+     * @param barrierNanos
      */
-    void registerOutboundQueueHandler(OutboundQueueHandlerRegistration outboundQueueHandlerRegistration);
+    void registerOutboundQueueProvider(OutboundQueueProvider outboundQueueProvider, int maxQueueDepth, long barrierNanos);
+
 
 }
 
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/exception/DeviceDataException.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/exception/DeviceDataException.java
deleted file mode 100644 (file)
index 48f99d2..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.api.openflow.device.exception;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
-
-/**
- * @deprecated FIXME: TO BE REMOVED: migrate to org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException.
- */
-@Deprecated
-public class DeviceDataException extends Exception {
-
-    /**
-     *
-     */
-    private static final long serialVersionUID = 1L;
-    private Error error;
-
-    public DeviceDataException(final String message) {
-        super(message);
-    }
-
-    public DeviceDataException(final String message, final Throwable cause) {
-        super(message, cause);
-    }
-
-    public DeviceDataException(final String message, final Error error) {
-        super(message);
-        this.error= error;
-    }
-
-    public Error getError() {
-        return error;
-    }
-}
index 29206bb46a93bf5abf36c3668a02c3296b054ed5..f692865551f8bc100c0b055572097dba5f0bd071 100644 (file)
@@ -9,52 +9,50 @@
 package org.opendaylight.openflowplugin.api.openflow.device.handlers;
 
 import java.util.List;
-
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
 
 /**
- *
  * @author tkubas
- *
  */
 public interface DeviceReplyProcessor {
 
     /**
      * Method that set future to context in Map
+     *
      * @param ofHeader
      */
     public void processReply(OfHeader ofHeader);
 
     /**
      * Method that set future to context in Map
+     *
      * @param xid,
      * @param ofHeaderList
      */
     public void processReply(Xid xid, List<MultipartReply> ofHeaderList);
 
-    /**
-     * Method that set exception to the future
-     * @param xid,
-     * @param deviceDataException
-     */
-    public void processException(Xid xid, DeviceDataException deviceDataException);
-
     /**
      * Method process async flow removed from device
+     *
      * @param flowRemoved
      */
     public void processFlowRemovedMessage(FlowRemoved flowRemoved);
 
     /**
      * Method process async port status from device
+     *
      * @param portStatus
      */
     public void processPortStatusMessage(PortStatusMessage portStatus);
 
     /**
      * Method process async packet in from device
+     *
      * @param packetInMessage
      */
     public void processPacketInMessage(PacketInMessage packetInMessage);
index 330ef902bde54c9952de2491df9566a9b3aae3bc..2267d736fc5b711c334f86417bec2e3a3205adb6 100644 (file)
@@ -8,9 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.device.handlers;
 
-import java.util.List;
 import javax.annotation.Nonnull;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 
 /**
@@ -26,21 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  *         Created: Mar 23, 2015
  */
 public interface MultiMsgCollector {
-
-    /**
-     * Property used to know a max life time of Multipart collection in internal Cache
-     */
-    final int DEFAULT_TIME_OUT = 10;
-
-    /**
-     * Method registers a requst context to the Multipart messages collector
-     * and returns Settable future with all MultipartReply. Method has to be called before
-     * send a request to the device, otherwise there is a small possibility to miss a first msg.
-     *
-     * @param requestContext
-     */
-    void registerMultipartRequestContext(RequestContext<List<MultipartReply>> requestContext);
-
     /**
      * Method adds a reply multipart message to the collection and if the message has marker
      * "I'M A LAST" method set whole Collection to Future object and remove from cache.
@@ -49,8 +32,10 @@ public interface MultiMsgCollector {
      */
     void addMultipartMsg(@Nonnull MultipartReply reply);
 
-
-    void setDeviceReplyProcessor(DeviceReplyProcessor deviceReplyProcessor);
-
-    void invalidateRequestContext(RequestContext<List<MultipartReply>> requestContext);
+    /**
+     * Null response could be a valid end multipart collecting event for barrier response scenario.
+     * We are not able to resolve an issue (it is or it isn't barrier scenario) so we have to finish
+     * collecting multipart messages successfully.
+     */
+    void endCollecting();
 }
index 19d0475d44c5a4b8889c649b2f025e7deed82286..ab4da891c03710cddda8f6cdcbde7b1d8e89cf84 100644 (file)
@@ -17,17 +17,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl
  */
 public interface DeviceFlowRegistry extends AutoCloseable {
 
-    FlowDescriptor retrieveIdForFlow(FlowHash flowHash);
+    FlowDescriptor retrieveIdForFlow(FlowRegistryKey flowRegistryKey);
 
-    void store(FlowHash flowHash, FlowDescriptor flowDescriptor);
+    void store(FlowRegistryKey flowRegistryKey, FlowDescriptor flowDescriptor);
 
-    FlowId storeIfNecessary(FlowHash flowHash, short tableId);
+    FlowId storeIfNecessary(FlowRegistryKey flowRegistryKey, short tableId);
 
-    void markToBeremoved(FlowHash flowHash);
+    void markToBeremoved(FlowRegistryKey flowRegistryKey);
 
     void removeMarked();
 
-    Map<FlowHash, FlowDescriptor> getAllFlowDescriptors();
+    Map<FlowRegistryKey, FlowDescriptor> getAllFlowDescriptors();
 
     @Override
     void close();
similarity index 92%
rename from openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/FlowHash.java
rename to openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/FlowRegistryKey.java
index 8d24e8d89c04918cc021bcfadadd2a16202e5f34..9460552a438edc2f0d08199c5ec1c952dafeda65 100644 (file)
@@ -14,9 +14,7 @@ import java.math.BigInteger;
  * Marker interface identifying flow stored in OFP local flow registry.
  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 8.4.2015.
  */
-public interface FlowHash {
-
-    long getFlowHash();
+public interface FlowRegistryKey {
 
     short getTableId();
 
@@ -24,4 +22,5 @@ public interface FlowHash {
 
     BigInteger getCookie();
 
+
 }
index e45c0771c58ca913fc986d0b741d27c41917c1cc..6620fe4d055b8a62a2c6e6e5dedec878836e1de1 100644 (file)
@@ -9,7 +9,9 @@
 package org.opendaylight.openflowplugin.api.openflow.statistics;
 
 import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.CheckForNull;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 
 /**
  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 27.2.2015.
@@ -17,4 +19,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 public interface StatisticsContext extends RequestContextStack, AutoCloseable {
 
     public ListenableFuture<Boolean> gatherDynamicData();
+
+    ListenableFuture<Boolean> gatherDynamicData(@CheckForNull MultipartType multipartType);
+
 }
index 346c048c5046e7492eb3a6e5f1973c461992e9ec..469fff3197112d3b39742e922c92437c5c7b2459 100644 (file)
@@ -56,7 +56,9 @@ import org.slf4j.LoggerFactory;
 public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenFlowPluginExtensionRegistratorProvider {
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderImpl.class);
+    private static final MessageIntelligenceAgency messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
 
+    private final int rpcRequestsQuota;
     private DeviceManager deviceManager;
     private RpcManager rpcManager;
     private RpcProviderRegistry rpcProviderRegistry;
@@ -70,12 +72,10 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
     private DataBroker dataBroker;
     private OfpRole role;
     private Collection<SwitchConnectionProvider> switchConnectionProviders;
-    private final Long rpcRequestsQuota;
-    private static final MessageIntelligenceAgency messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
-
 
-    public OpenFlowPluginProviderImpl(final Long rpcRequestsQuota) {
-        this.rpcRequestsQuota = rpcRequestsQuota;
+    public OpenFlowPluginProviderImpl(final long rpcRequestsQuota) {
+        Preconditions.checkArgument(rpcRequestsQuota > 0 && rpcRequestsQuota <= Integer.MAX_VALUE, "rpcRequestQuota has to be in range <1,%s>", Integer.MAX_VALUE);
+        this.rpcRequestsQuota = (int) rpcRequestsQuota;
     }
 
 
index a4ead742448af0bf6c16d816b9fcd63d3f5d61ab..4db037f0d6264f4a121af2bfef4e5a7203b82808 100644 (file)
@@ -96,53 +96,7 @@ public final class MultipartRequestInputFactory {
         return maker(xid, type, ofVersion, false, makeDefaultEmptyRequestBody(type, ofVersion));
     }
 
-    /**
-     * Method validate input values and makes {@link MultipartRequestInput} from input values. Method set
-     * a moreRequest marker to false.
-     *
-     * @param xid
-     * @param type
-     * @param ofVersion
-     * @param body
-     * @return
-     */
-    public static MultipartRequestInput makeMultipartRequestInput(final long xid, final short ofVersion,
-                                                                  @Nonnull final MultipartType type, @Nonnull final MultipartRequestBody body) {
-        Preconditions.checkArgument(validationOfMultipartTypeAndRequestBody(type, body));
-        return maker(xid, type, ofVersion, false, body);
-    }
-
-    /**
-     * Method validates input and makes {@link MultipartRequestInput} from input values. Method creates
-     * default empty {@link MultipartRequestBody} by {@link MultipartType}
-     *
-     * @param xid
-     * @param type
-     * @param ofVersion
-     * @param moreRequests
-     * @return
-     */
-    public static MultipartRequestInput makeMultipartRequestInput(final long xid, final short ofVersion,
-                                                                  @Nonnull final MultipartType type, final boolean moreRequests) {
-        return maker(xid, type, ofVersion, moreRequests, makeDefaultEmptyRequestBody(type, ofVersion));
-    }
 
-    /**
-     * Method validates input values and makes {@link MultipartRequestInput} from input values.
-     *
-     * @param xid
-     * @param type
-     * @param ofVersion
-     * @param moreRequests
-     * @param body
-     * @return
-     */
-    public static MultipartRequestInput makeMultipartRequestInput(final long xid, final short ofVersion,
-                                                                  @Nonnull final MultipartType type, final boolean moreRequests,
-                                                                  @Nonnull final MultipartRequestBody body) {
-        Preconditions.checkArgument(validationOfMultipartTypeAndRequestBody(type, body));
-        return maker(xid, type, ofVersion, moreRequests, body);
-    }
 
     /**
      * Method build {@link MultipartRequestInput} from input values. It is private because we would like
index d49bfe6b2d71dd0709c3e15cb49a8a25e4db1536..7f16e813b80fcde8cb4cb119e586fa1a7d67c252 100644 (file)
@@ -112,12 +112,6 @@ public class ConnectionManagerImpl implements ConnectionManager {
         return bitmapNegotiationEnabled ;
     }
 
-    /**
-     * @param bitmapNegotiationEnabled the bitmapNegotiationEnabled to set
-     */
-    public void setBitmapNegotiationEnabled(final boolean bitmapNegotiationEnabled) {
-        this.bitmapNegotiationEnabled = bitmapNegotiationEnabled;
-    }
 
     @Override
     public boolean accept(final InetAddress switchAddress) {
index de860f7e18dacd5a24627275a40153d86ed9e16e..f176b5ceb2f9c10c8f48716cd2b48bcd2959720d 100644 (file)
@@ -30,13 +30,13 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextClosedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
@@ -83,7 +83,6 @@ import org.slf4j.LoggerFactory;
 public class DeviceContextImpl implements DeviceContext {
 
     private static final Logger LOG = LoggerFactory.getLogger(DeviceContextImpl.class);
-    public static final String DEVICE_DISCONNECTED = "Device disconnected.";
 
     private final ConnectionContext primaryConnectionContext;
     private final DeviceState deviceState;
@@ -101,19 +100,13 @@ public class DeviceContextImpl implements DeviceContext {
     private DeviceDisconnectedHandler deviceDisconnectedHandler;
     private final Collection<DeviceContextClosedHandler> closeHandlers = new HashSet<>();
     private NotificationPublishService notificationPublishService;
-    private final OutboundQueue outboundQueueProvider;
-    private final MultiMsgCollector multiMsgCollector = new MultiMsgCollectorImpl();
+    private OutboundQueue outboundQueueProvider;
 
     private volatile int outstandingNotificationsAmount = 0;
     private volatile boolean filteringPacketIn = false;
     private final Object throttlingLock = new Object();
     private int filteringHighWaterMark = 0;
-    private OutboundQueueHandlerRegistration outboundQueueHandlerRegistration;
-
-    @Override
-    public MultiMsgCollector getMultiMsgCollector() {
-        return multiMsgCollector;
-    }
+    private OutboundQueueHandlerRegistration<?> outboundQueueHandlerRegistration;
 
     @Override
     public Long getReservedXid() {
@@ -130,23 +123,20 @@ public class DeviceContextImpl implements DeviceContext {
         this.deviceState = Preconditions.checkNotNull(deviceState);
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         this.hashedWheelTimer = Preconditions.checkNotNull(hashedWheelTimer);
-        txChainManager = new TransactionChainManager(dataBroker, hashedWheelTimer, 500L, 500L);
+        txChainManager = new TransactionChainManager(dataBroker, deviceState);
         auxiliaryConnectionContexts = new HashMap<>();
         deviceFlowRegistry = new DeviceFlowRegistryImpl();
         deviceGroupRegistry = new DeviceGroupRegistryImpl();
         deviceMeterRegistry = new DeviceMeterRegistryImpl();
         messageSpy = _messageSpy;
-        multiMsgCollector.setDeviceReplyProcessor(this);
-        outboundQueueProvider = Preconditions.checkNotNull(primaryConnectionContext.getOutboundQueueProvider());
     }
 
     /**
      * This method is called from {@link DeviceManagerImpl} only. So we could say "posthandshake process finish"
      * and we are able to set a scheduler for an automatic transaction submitting by time (0,5sec).
      */
-    void submitTransaction() {
-        txChainManager.enableSubmit();
-        txChainManager.submitTransaction();
+    void initialSubmitTransaction() {
+        txChainManager.initialSubmitWriteTransaction();
     }
 
     @Override
@@ -190,6 +180,11 @@ public class DeviceContextImpl implements DeviceContext {
         txChainManager.addDeleteOperationTotTxChain(store, path);
     }
 
+    @Override
+    public boolean submitTransaction() {
+        return txChainManager.submitWriteTransaction();
+    }
+
     @Override
     public ConnectionContext getPrimaryConnectionContext() {
         return primaryConnectionContext;
@@ -231,11 +226,6 @@ public class DeviceContextImpl implements DeviceContext {
         }
     }
 
-    @Override
-    public void processException(final Xid xid, final DeviceDataException deviceDataException) {
-        messageSpy.spyMessage(deviceDataException.getClass(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
-    }
-
     @Override
     public void processFlowRemovedMessage(final FlowRemoved flowRemoved) {
         //TODO: will be defined later
@@ -258,6 +248,7 @@ public class DeviceContextImpl implements DeviceContext {
         } else if (portStatus.getReason().equals(PortReason.OFPPRDELETE)) {
             addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, iiToNodeConnector);
         }
+        submitTransaction();
     }
 
     private KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> provideIIToNodeConnector(final long portNo, final short version) {
@@ -282,7 +273,7 @@ public class DeviceContextImpl implements DeviceContext {
         }
         messageSpy.spyMessage(packetReceived.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_SRC_FAILURE);
 
-        ListenableFuture<? extends Object> offerNotification = notificationPublishService.offerNotification(packetReceived);
+        final ListenableFuture<? extends Object> offerNotification = notificationPublishService.offerNotification(packetReceived);
         synchronized (throttlingLock) {
             outstandingNotificationsAmount += 1;
         }
@@ -347,18 +338,15 @@ public class DeviceContextImpl implements DeviceContext {
     }
 
     @Override
-    public void close() {
+    public void close() throws Exception {
         deviceState.setValid(false);
 
-        outboundQueueHandlerRegistration.close();
-
-        LOG.trace("Removing node {} from operational DS.", getDeviceState().getNodeId());
-        addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, getDeviceState().getNodeInstanceIdentifier());
-
         deviceGroupRegistry.close();
         deviceFlowRegistry.close();
         deviceMeterRegistry.close();
 
+        outboundQueueHandlerRegistration.close();
+
         if (primaryConnectionContext.getConnectionAdapter().isAlive()) {
             primaryConnectionContext.setConnectionState(ConnectionContext.CONNECTION_STATE.RIP);
             primaryConnectionContext.getConnectionAdapter().disconnect();
@@ -368,14 +356,17 @@ public class DeviceContextImpl implements DeviceContext {
                 connectionContext.getConnectionAdapter().disconnect();
             }
         }
+
         for (final DeviceContextClosedHandler deviceContextClosedHandler : closeHandlers) {
             deviceContextClosedHandler.onDeviceContextClosed(this);
         }
+
+        txChainManager.close();
     }
 
     @Override
     public void onDeviceDisconnected(final ConnectionContext connectionContext) {
-        if (this.getPrimaryConnectionContext().equals(connectionContext)) {
+        if (getPrimaryConnectionContext().equals(connectionContext)) {
             try {
                 close();
             } catch (final Exception e) {
@@ -422,29 +413,27 @@ public class DeviceContextImpl implements DeviceContext {
 
     @Override
     public void addDeviceContextClosedHandler(final DeviceContextClosedHandler deviceContextClosedHandler) {
-        this.closeHandlers.add(deviceContextClosedHandler);
-    }
-
-    @Override
-    public void startGatheringOperationsToOneTransaction() {
-        txChainManager.startGatheringOperationsToOneTransaction();
-    }
-
-    @Override
-    public void commitOperationsGatheredInOneTransaction() {
-        txChainManager.commitOperationsGatheredInOneTransaction();
+        closeHandlers.add(deviceContextClosedHandler);
     }
 
     @Override
     public void onPublished() {
         primaryConnectionContext.getConnectionAdapter().setPacketInFiltering(false);
-        for (ConnectionContext switchAuxConnectionContext : auxiliaryConnectionContexts.values()) {
+        for (final ConnectionContext switchAuxConnectionContext : auxiliaryConnectionContexts.values()) {
             switchAuxConnectionContext.getConnectionAdapter().setPacketInFiltering(false);
         }
     }
 
     @Override
-    public void registerOutboundQueueHandler(final OutboundQueueHandlerRegistration outboundQueueHandlerRegistration) {
-        this.outboundQueueHandlerRegistration = outboundQueueHandlerRegistration;
+    public void registerOutboundQueueProvider(final OutboundQueueProvider outboundQueueProvider, final int maxQueueDepth, final long barrierNanos) {
+        final ConnectionAdapter primaryConnectionAdapter = primaryConnectionContext.getConnectionAdapter();
+        outboundQueueHandlerRegistration = primaryConnectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, maxQueueDepth, barrierNanos);
+        this.outboundQueueProvider = outboundQueueProvider;
+        primaryConnectionContext.setOutboundQueueProvider(outboundQueueProvider);
+    }
+
+    @Override
+    public MultiMsgCollector getMultiMsgCollector(final RequestContext<List<MultipartReply>> requestContext) {
+        return new MultiMsgCollectorImpl(this, requestContext);
     }
 }
index 358473e3283db983221723db30616f74dae1bf01..00cf64754abebf1a1cc58676bd156b00cf545ce3 100644 (file)
@@ -32,7 +32,6 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.openflowplugin.api.ConnectionException;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
@@ -150,7 +149,7 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable {
     public void onDeviceContextLevelUp(final DeviceContext deviceContext) {
         // final phase - we have to add new Device to MD-SAL DataStore
         Preconditions.checkNotNull(deviceContext);
-        ((DeviceContextImpl) deviceContext).submitTransaction();
+        ((DeviceContextImpl) deviceContext).initialSubmitTransaction();
 
         deviceContext.onPublished();
     }
@@ -166,18 +165,15 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable {
         connectionAdapter.setPacketInFiltering(true);
 
         final Short version = connectionContext.getFeatures().getVersion();
-        OutboundQueueProvider outboundQueueProvider = new OutboundQueueProviderImpl(version);
-
-        final OutboundQueueHandlerRegistration outboundQueueHandlerRegistration = connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, maxQueueDepth, barrierNanos);
-        connectionContext.setOutboundQueueProvider(outboundQueueProvider);
+        final OutboundQueueProvider outboundQueueProvider = new OutboundQueueProviderImpl(version);
 
         final DeviceState deviceState = new DeviceStateImpl(connectionContext.getFeatures(), connectionContext.getNodeId());
 
         final DeviceContext deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, hashedWheelTimer, messageIntelligenceAgency);
-        deviceContext.registerOutboundQueueHandler(outboundQueueHandlerRegistration);
+        deviceContext.registerOutboundQueueProvider(outboundQueueProvider, maxQueueDepth, barrierNanos);
         deviceContext.setNotificationService(notificationService);
         deviceContext.setNotificationPublishService(notificationPublishService);
-        NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(Collections.<NodeConnector>emptyList());
+        final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(Collections.<NodeConnector>emptyList());
         deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier(), nodeBuilder.build());
 
         connectionContext.setDeviceDisconnectedHandler(deviceContext);
@@ -363,35 +359,31 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable {
 
         LOG.trace("Hooking xid {} to device context - precaution.", reserved);
 
-        final MultiMsgCollector multiMsgCollector = deviceContext.getMultiMsgCollector();
-        multiMsgCollector.registerMultipartRequestContext(requestContext);
+        final MultiMsgCollector multiMsgCollector = deviceContext.getMultiMsgCollector(requestContext);
         queue.commitEntry(xid.getValue(), MultipartRequestInputFactory.makeMultipartRequestInput(xid.getValue(), version, type), new FutureCallback<OfHeader>() {
             @Override
             public void onSuccess(final OfHeader ofHeader) {
                 if (ofHeader instanceof MultipartReply) {
-                    MultipartReply multipartReply = (MultipartReply) ofHeader;
+                    final MultipartReply multipartReply = (MultipartReply) ofHeader;
                     multiMsgCollector.addMultipartMsg(multipartReply);
+                } else if (null != ofHeader) {
+                    LOG.info("Unexpected response type received {}.", ofHeader.getClass());
                 } else {
-                    if (null != ofHeader) {
-                        LOG.info("Unexpected response type received {}.", ofHeader.getClass());
-                    } else {
-                        LOG.info("Response received is null.");
-                    }
+                    multiMsgCollector.endCollecting();
+                    LOG.info("Response received is null.");
                 }
-
             }
 
             @Override
             public void onFailure(final Throwable t) {
                 LOG.info("Fail response from OutboundQueue for multipart type {}.", type, t);
-                multiMsgCollector.invalidateRequestContext(requestContext);
+                requestContext.close();
                 if (MultipartType.OFPMPTABLEFEATURES.equals(type)) {
                     makeEmptyTables(deviceContext, nodeII, deviceContext.getPrimaryConnectionContext().getFeatures().getTables());
                 }
             }
         });
 
-
         return requestContext.getFuture();
     }
 
@@ -517,7 +509,7 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable {
 
     @Override
     public void setNotificationPublishService(final NotificationPublishService notificationService) {
-        this.notificationPublishService = notificationService;
+        notificationPublishService = notificationService;
     }
 
     @Override
index 2a09f79d0c6feb5b90fc9a34e3d82d5e422eddeb..079297928a8cd467e4dfe7c6e87aa0297735bdda 100644 (file)
@@ -10,14 +10,6 @@ package org.opendaylight.openflowplugin.impl.device;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import io.netty.util.HashedWheelTimer;
-import io.netty.util.Timeout;
-import io.netty.util.TimerTask;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -26,7 +18,7 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -45,162 +37,117 @@ import org.slf4j.LoggerFactory;
  *         <p/>
  *         Created: Apr 2, 2015
  */
-@VisibleForTesting
-class TransactionChainManager implements TransactionChainListener {
+class TransactionChainManager implements TransactionChainListener, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(TransactionChainManager.class);
 
-    private final HashedWheelTimer hashedWheelTimer;
+    private final Object txLock = new Object();
+
+    private final DeviceState deviceState;
     private final DataBroker dataBroker;
-    private final long maxTx;
-    private final long timerValue;
-    private BindingTransactionChain txChainFactory;
     private WriteTransaction wTx;
-    private Timeout submitTaskTime;
-    private long nrOfActualTx;
+    private BindingTransactionChain txChainFactory;
     private boolean submitIsEnabled;
 
-    TransactionChainManager(@Nonnull final DataBroker dataBroker,
-                            @Nonnull final HashedWheelTimer hashedWheelTimer,
-                            final long maxTx,
-                            final long timerValue) {
+    TransactionChainManager(@Nonnull final DataBroker dataBroker, @Nonnull final DeviceState deviceState) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
-        this.hashedWheelTimer = Preconditions.checkNotNull(hashedWheelTimer);
-        this.maxTx = maxTx;
+        this.deviceState = Preconditions.checkNotNull(deviceState);
         txChainFactory = dataBroker.createTransactionChain(TransactionChainManager.this);
-        nrOfActualTx = 0L;
-        this.timerValue = timerValue;
-        LOG.debug("created txChainManager with operation limit {}", maxTx);
+        LOG.debug("created txChainManager");
     }
 
-
-    public void commitOperationsGatheredInOneTransaction() {
+    void initialSubmitWriteTransaction() {
         enableSubmit();
-        submitTransaction();
+        submitWriteTransaction();
     }
 
-    public void startGatheringOperationsToOneTransaction() {
-        submitIsEnabled = false;
-    }
-
-    <T extends DataObject> void writeToTransaction(final LogicalDatastoreType store,
-                                                   final InstanceIdentifier<T> path, final T data) {
-        try {
-            final WriteTransaction writeTx = getTransactionSafely();
-            writeTx.put(store, path, data);
-            countTxInAndCommit();
-        } catch (final Exception e) {
-            LOG.warn("failed to put into writeOnlyTransaction: {}", e.getMessage());
-            LOG.trace("failed to put into writeOnlyTransaction.. ", e);
+    boolean submitWriteTransaction() {
+        if ( ! submitIsEnabled) {
+            LOG.trace("transaction not committed - submit block issued");
+            return false;
         }
-    }
-
-    private WriteTransaction getTransactionSafely() {
         if (wTx == null) {
-            wTx = txChainFactory.newWriteOnlyTransaction();
+            LOG.trace("nothing to commit - submit returns true");
+            return true;
         }
-        return wTx;
+        if ( ! deviceState.isValid()) {
+            LOG.info("DeviceState is not valid will not submit transaction");
+            return false;
+        }
+        synchronized (txLock) {
+            wTx.submit();
+            wTx = null;
+        }
+        return true;
     }
 
     <T extends DataObject> void addDeleteOperationTotTxChain(final LogicalDatastoreType store,
-                                                             final InstanceIdentifier<T> path) {
+            final InstanceIdentifier<T> path) {
         try {
             final WriteTransaction writeTx = getTransactionSafely();
             writeTx.delete(store, path);
-            countTxInAndCommit();
         } catch (final Exception e) {
             LOG.warn("failed to put into writeOnlyTransaction : {}", e.getMessage());
             LOG.trace("failed to put into writeOnlyTransaction.. ", e);
         }
     }
 
-    private void countTxInAndCommit() {
-        nrOfActualTx += 1L;
-        if (nrOfActualTx >= maxTx) {
-            submitTransaction();
+    <T extends DataObject> void writeToTransaction(final LogicalDatastoreType store,
+            final InstanceIdentifier<T> path, final T data) {
+        try {
+            final WriteTransaction writeTx = getTransactionSafely();
+            writeTx.put(store, path, data);
+        } catch (final Exception e) {
+            LOG.warn("failed to put into writeOnlyTransaction: {}", e.getMessage());
+            LOG.trace("failed to put into writeOnlyTransaction.. ", e);
         }
     }
 
-    void submitScheduledTransaction(final Timeout timeout) {
-        if (timeout.isCancelled()) {
-            // zombie timer executed
-            return;
-        }
-
-        if (submitIsEnabled) {
-            if (nrOfActualTx > 0L) {
-                submitTransaction();
-            }
-        } else {
-            LOG.info("transaction submit task will not be scheduled - submit block issued.");
-        }
+    @Override
+    public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
+                                         final AsyncTransaction<?, ?> transaction, final Throwable cause) {
+        LOG.warn("txChain failed -> recreating", cause);
+        recreateTxChain();
     }
 
-    void submitTransaction() {
-        if (submitIsEnabled) {
-            if (wTx != null && nrOfActualTx > 0) {
-                LOG.trace("submitting transaction, counter: {}", nrOfActualTx);
-                final CheckedFuture<Void, TransactionCommitFailedException> submitResult = wTx.submit();
-                try {
-                    submitResult.get();
-                } catch (ExecutionException | InterruptedException e) {
-                    recreateTxChain();
-                }
-                hookTimeExpenseCounter(submitResult, String.valueOf(wTx.getIdentifier()) + "::" + nrOfActualTx);
-                wTx = null;
-                nrOfActualTx = 0L;
-            }
-            if (submitTaskTime != null) {
-                // if possible then cancel current timer (even if being executed via timer)
-                submitTaskTime.cancel();
-            }
-            submitTaskTime = hashedWheelTimer.newTimeout(new TimerTask() {
-                @Override
-                public void run(final Timeout timeout) throws Exception {
-                    submitScheduledTransaction(timeout);
-                }
-            }, timerValue, TimeUnit.MILLISECONDS);
+    @Override
+    public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+        // NOOP - only yet, here is probably place for notification to get new WriteTransaction
+    }
 
-        } else {
-            LOG.trace("transaction not committed - submit block issued");
+    private void recreateTxChain() {
+        txChainFactory.close();
+        txChainFactory = dataBroker.createTransactionChain(TransactionChainManager.this);
+        synchronized (txLock) {
+            wTx = null;
         }
     }
 
-    private static void hookTimeExpenseCounter(final CheckedFuture<Void, TransactionCommitFailedException> submitResult, final String name) {
-        final long submitFiredTime = System.nanoTime();
-        LOG.debug("submit of {} fired", name);
-        Futures.addCallback(submitResult, new FutureCallback<Void>() {
-            @Override
-            public void onSuccess(final Void result) {
-                LOG.debug("submit of {} finished in {} ms", name, System.nanoTime() - submitFiredTime);
-            }
-
-            @Override
-            public void onFailure(final Throwable t) {
-                LOG.warn("transaction submit failed: {}", t.getMessage());
+    private WriteTransaction getTransactionSafely() {
+        if (wTx == null) {
+            synchronized (txLock) {
+                if (wTx == null) {
+                    wTx = txChainFactory.newWriteOnlyTransaction();
+                }
             }
-        });
+        }
+        return wTx;
     }
 
+    @VisibleForTesting
     void enableSubmit() {
         submitIsEnabled = true;
     }
 
     @Override
-    public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
-                                         final AsyncTransaction<?, ?> transaction, final Throwable cause) {
-        LOG.warn("txChain failed -> recreating", cause);
-        recreateTxChain();
-    }
-
-    private void recreateTxChain() {
-        txChainFactory.close();
-        txChainFactory = dataBroker.createTransactionChain(TransactionChainManager.this);
-    }
-
-    @Override
-    public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
-        // NOOP - only yet, here is probably place for notification to get new WriteTransaction
+    public void close() throws Exception {
+        LOG.debug("Removing node {} from operational DS.", deviceState.getNodeId());
+        synchronized (txLock) {
+            final WriteTransaction writeTx = getTransactionSafely();
+            writeTx.delete(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier());
+            writeTx.submit();
+            wTx = null;
+            txChainFactory.close();
+        }
     }
-
 }
index 1acca2d0506ded99412fef1ff5ee54b8cdac9b9e..ffb44d2ee8949ccef0ed25419061f6246709f52d 100644 (file)
@@ -8,23 +8,16 @@
 
 package org.opendaylight.openflowplugin.impl.device.listener;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
@@ -33,9 +26,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * <p>
- * openflowplugin-api
- * org.opendaylight.openflowplugin.impl.openflow.device
- *
  * Implementation for {@link MultiMsgCollector} interface
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
@@ -43,148 +34,44 @@ import org.slf4j.LoggerFactory;
  *         </p>
  *         Created: Mar 23, 2015
  */
-@VisibleForTesting
 public class MultiMsgCollectorImpl implements MultiMsgCollector {
 
     private static final Logger LOG = LoggerFactory.getLogger(MultiMsgCollectorImpl.class);
 
-    private final Cache<Long, MultiCollectorObject> cache;
-    private DeviceReplyProcessor deviceReplyProcessor;
-
-    public MultiMsgCollectorImpl() {
-        this(DEFAULT_TIME_OUT);
-    }
-
-    public MultiMsgCollectorImpl(final int timeout) {
-        cache = initCacheBuilder(timeout).build();
-    }
-
-    private static RemovalListener<Long, MultiCollectorObject> getRemovalListener() {
-        return new RemovalListener<Long, MultiCollectorObject>() {
-            @Override
-            public void onRemoval(final RemovalNotification<Long, MultiCollectorObject> notification) {
-                LOG.trace("Removing data with XID {} from cache, cause: {}", notification.getKey(), notification.getCause());
-                switch (notification.getCause()) {
-                    case EXPIRED:
-                        notification.getValue().invalidateFutureByTimeout(notification.getKey());
-                }
-            }
-        };
-    }
-
-    private static CacheBuilder<Long, MultiCollectorObject> initCacheBuilder(final int timeout) {
-        return CacheBuilder.newBuilder()
-                .expireAfterAccess(timeout, TimeUnit.SECONDS)
-                .removalListener(getRemovalListener())
-                .initialCapacity(200)
-                .maximumSize(500)
-                .concurrencyLevel(1);
-    }
+    private final List<MultipartReply> replyCollection = new ArrayList<>();
+    private final RequestContext<List<MultipartReply>> requestContext;
+    private final DeviceReplyProcessor deviceReplyProcessor;
+    private MultipartType msgType;
 
-    @Override
-    public void registerMultipartRequestContext(final RequestContext<List<MultipartReply>> requestContext) {
-        cache.put(requestContext.getXid().getValue(), new MultiCollectorObject(requestContext));
+    public MultiMsgCollectorImpl(final DeviceReplyProcessor deviceReplyProcessor, final RequestContext<List<MultipartReply>> requestContext) {
+        this.deviceReplyProcessor = Preconditions.checkNotNull(deviceReplyProcessor);
+        this.requestContext = Preconditions.checkNotNull(requestContext);
     }
 
     @Override
     public void addMultipartMsg(final MultipartReply reply) {
         Preconditions.checkNotNull(reply);
+        Preconditions.checkArgument(requestContext.getXid().getValue().equals(reply.getXid()));
         LOG.trace("Try to add Multipart reply msg with XID {}", reply.getXid());
-        final long xid = reply.getXid();
-        final MultiCollectorObject cachedRef = cache.getIfPresent(xid);
-        if (cachedRef == null) {
-            MultipartType multipartType = reply.getType();
-            LOG.trace("Orphaned multipart msg with XID : {} of type {}", xid, multipartType);
-            deviceReplyProcessor.processException(new Xid(xid),
-                    new DeviceDataException("unknown xid received for multipart of type " + multipartType));
-            return;
-        }
 
-        try {
-            cachedRef.add(reply);
-            LOG.trace("Multipart reply msg with XID {} added successfully.", reply.getXid());
-            if (!reply.getFlags().isOFPMPFREQMORE()) {
-                // flag OFPMFFREEQMORE false says "I'm a last one'
-                cachedRef.publishCollection(xid); // settable future has now whole collection
-                cache.invalidate(xid);              // we don't need a reference anymore - remove explicitly
-            }
-        } catch (DeviceDataException e) {
-            deviceReplyProcessor.processException(new Xid(xid), e);
+        if (msgType == null) {
+            msgType = reply.getType();
         }
-    }
 
-    @Override
-    public void setDeviceReplyProcessor(final DeviceReplyProcessor deviceReplyProcessor) {
-        this.deviceReplyProcessor = deviceReplyProcessor;
-    }
-
-    @Override
-    public void invalidateRequestContext(final RequestContext<List<MultipartReply>> requestContext) {
-        MultiCollectorObject  multiCollectorObject = cache.getIfPresent(requestContext);
-        if (null != multiCollectorObject){
-            multiCollectorObject.invalidateFutureByTimeout(requestContext.getXid().getValue());
+        if (!msgType.equals(reply.getType())) {
+            LOG.warn("MultiMsgCollector get incorrect multipart msg with type {} but expected type is {}", reply.getType(), msgType);
         }
-    }
-
-    private class MultiCollectorObject {
-        private final List<MultipartReply> replyCollection = new ArrayList<>();
-        private final RequestContext<List<MultipartReply>> requestContext;
-        private MultipartType msgType;
 
-        MultiCollectorObject(final RequestContext<List<MultipartReply>> requestContext) {
-            this.requestContext = Preconditions.checkNotNull(requestContext);
+        replyCollection.add(reply);
+        if (!reply.getFlags().isOFPMPFREQMORE()) {
+            endCollecting();
         }
+    }
 
-        void add(final MultipartReply reply) throws DeviceDataException {
-            /* Rise possible exception if it possible */
-            msgTypeValidation(reply.getType(), reply.getXid());
-            replyCollection.add(reply);
-        }
-
-        void publishCollection(final long xid) {
-            final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
-                    .<List<MultipartReply>>success()
-                    .withResult(replyCollection)
-                    .build();
-            requestContext.setResult(rpcResult);
-            try {
-                requestContext.close();
-            } catch (final Exception e) {
-                LOG.warn("Closing RequestContext failed: {}", e.getMessage());
-                LOG.debug("Closing RequestContext failed.. ", e);
-            }
-            deviceReplyProcessor.processReply(new Xid(xid), replyCollection);
-        }
-
-        void invalidateFutureByTimeout(final long key) {
-            final String msg = "MultiMsgCollector can not wait for last multipart any more";
-            DeviceDataException deviceDataException = new DeviceDataException(msg);
-            final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
-                    .<List<MultipartReply>>failed()
-                    .withError(RpcError.ErrorType.APPLICATION, String.format("Message processing failed : %s", deviceDataException.getError()), deviceDataException)
-                    .build();
-            requestContext.setResult(rpcResult);
-            try {
-                requestContext.close();
-            } catch (final Exception e) {
-                LOG.warn("Closing RequestContext failed: ", e);
-                LOG.debug("Closing RequestContext failed..", e);
-            }
-            deviceReplyProcessor.processException(new Xid(key), deviceDataException);
-        }
-
-
-        private void msgTypeValidation(final MultipartType type, final long key) throws DeviceDataException {
-            if (msgType == null) {
-                msgType = type;
-                return;
-            }
-            if (!msgType.equals(type)) {
-                final String msg = "MultiMsgCollector get incorrect multipart msg with type {}"
-                        + " but expected type is {}";
-                LOG.trace(msg, type, msgType);
-                throw new DeviceDataException("multipart message type mismatch");
-            }
-        }
+    public void endCollecting() {
+        final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(replyCollection).build();
+        requestContext.setResult(rpcResult);
+        requestContext.close();
+        deviceReplyProcessor.processReply(requestContext.getXid(), replyCollection);
     }
 }
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/karaf/StatisticsCommandCompleter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/karaf/StatisticsCommandCompleter.java
deleted file mode 100644 (file)
index d5e2b3e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.impl.karaf;
-
-/**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 21.5.2015.
- */
-public class StatisticsCommandCompleter {
-}
index 02dceac8b5f971370f6ebac44f3af847d0eccd42..8b802249e1b4ef80926a84037ed0ecbf21e16f69 100644 (file)
@@ -14,7 +14,7 @@ import java.util.HashSet;
 import java.util.Map;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.openflowplugin.impl.util.FlowUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.slf4j.Logger;
@@ -26,56 +26,58 @@ import org.slf4j.LoggerFactory;
  */
 public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
 
-    private final Map<FlowHash, FlowDescriptor> flowRegistry = new HashMap<>();
-    private final Collection<FlowHash> marks = new HashSet<>();
+    private final Map<FlowRegistryKey, FlowDescriptor> flowRegistry = new HashMap<>();
+    private final Collection<FlowRegistryKey> marks = new HashSet<>();
     private static final Logger LOG = LoggerFactory.getLogger(DeviceFlowRegistryImpl.class);
 
     @Override
-    public FlowDescriptor retrieveIdForFlow(final FlowHash flowHash) {
-        FlowDescriptor flowDescriptor = flowRegistry.get(flowHash);
+    public FlowDescriptor retrieveIdForFlow(final FlowRegistryKey flowRegistryKey) {
+        FlowDescriptor flowDescriptor = flowRegistry.get(flowRegistryKey);
         return flowDescriptor;
     }
 
 
     @Override
-    public void store(final FlowHash flowHash, final FlowDescriptor flowDescriptor) {
-        LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}", flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), flowHash.hashCode());
+    public void store(final FlowRegistryKey flowRegistryKey, final FlowDescriptor flowDescriptor) {
+        LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}", flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), flowRegistryKey.hashCode());
         synchronized (flowRegistry) {
-            flowRegistry.put(flowHash, flowDescriptor);
+            flowRegistry.put(flowRegistryKey, flowDescriptor);
         }
     }
 
     @Override
-    public FlowId storeIfNecessary(final FlowHash flowHash, final short tableId) {
+    public FlowId storeIfNecessary(final FlowRegistryKey flowRegistryKey, final short tableId) {
+
+
         FlowId alienFlowId = FlowUtil.createAlienFlowId(tableId);
         FlowDescriptor alienFlowDescriptor = FlowDescriptorFactory.create(tableId, alienFlowId);
         synchronized (flowRegistry) {
-            FlowDescriptor flowDescriptorFromRegistry = flowRegistry.get(flowHash);
+            FlowDescriptor flowDescriptorFromRegistry = flowRegistry.get(flowRegistryKey);
             if (flowDescriptorFromRegistry != null) {
                 return flowDescriptorFromRegistry.getFlowId();
             } else {
-                LOG.trace("Flow descriptor for flow hash {} wasn't found.", flowHash.hashCode());
-                flowRegistry.put(flowHash, alienFlowDescriptor);
+                LOG.trace("Flow descriptor for flow hash {} wasn't found.", flowRegistryKey.hashCode());
+                flowRegistry.put(flowRegistryKey, alienFlowDescriptor);
                 return alienFlowId;
             }
         }
     }
 
     @Override
-    public void markToBeremoved(final FlowHash flowHash) {
+    public void markToBeremoved(final FlowRegistryKey flowRegistryKey) {
         synchronized (marks) {
-            marks.add(flowHash);
+            marks.add(flowRegistryKey);
         }
-        LOG.trace("Flow hash {} was marked for removal.", flowHash.hashCode());
+        LOG.trace("Flow hash {} was marked for removal.", flowRegistryKey.hashCode());
 
     }
 
     @Override
     public void removeMarked() {
         synchronized (flowRegistry) {
-            for (FlowHash flowHash : marks) {
-                LOG.trace("Removing flowDescriptor for flow hash : {}", flowHash.hashCode());
-                flowRegistry.remove(flowHash);
+            for (FlowRegistryKey flowRegistryKey : marks) {
+                LOG.trace("Removing flowDescriptor for flow hash : {}", flowRegistryKey.hashCode());
+                flowRegistry.remove(flowRegistryKey);
             }
         }
         synchronized (marks) {
@@ -85,7 +87,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
 
 
     @Override
-    public Map<FlowHash, FlowDescriptor> getAllFlowDescriptors() {
+    public Map<FlowRegistryKey, FlowDescriptor> getAllFlowDescriptors() {
         return flowRegistry;
     }
 
similarity index 51%
rename from openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowHashFactory.java
rename to openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java
index 9124a90cb2e430bc76081e4562422243700507f8..08f128e5b5d298705a1c3cd7d9b3ca1970897cec 100644 (file)
@@ -10,77 +10,59 @@ package org.opendaylight.openflowplugin.impl.registry.flow;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
-import com.google.common.primitives.Longs;
 import java.math.BigInteger;
-import java.util.Objects;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
-import org.opendaylight.openflowplugin.impl.util.HashUtil;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 
 /**
  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 8.4.2015.
  */
-public class FlowHashFactory {
+public class FlowRegistryKeyFactory {
 
 
-    public FlowHashFactory() {
+    public FlowRegistryKeyFactory() {
     }
 
-    public static FlowHash create(Flow flow, short version) {
-        long hash = calculateHash(flow, version);
-        return new FlowHashDto(hash, flow);
+    public static FlowRegistryKey create(Flow flow) {
+        return new FlowRegistryKeyDto(flow);
     }
 
-    private static long calculateHash(Flow flow, short version) {
-        return HashUtil.calculateMatchHash(flow.getMatch(), version);
-    }
-
-
-    private static final class FlowHashDto implements FlowHash {
-
-        private final long flowHash;
-        private final int intHashCode;
+    private static final class FlowRegistryKeyDto implements FlowRegistryKey {
 
         private final short tableId;
         private final int priority;
         private final BigInteger cookie;
+        private final Match match;
 
-        public FlowHashDto(final long flowHash, final Flow flow) {
-            this.flowHash = flowHash;
-            this.intHashCode = Longs.hashCode(flowHash);
+        public FlowRegistryKeyDto(final Flow flow) {
             tableId = Preconditions.checkNotNull(flow.getTableId(), "flow tableId must not be null");
             priority = Preconditions.checkNotNull(flow.getPriority(), "flow priority must not be null");
+            match = Preconditions.checkNotNull(flow.getMatch(), "Match value must not be null");
             cookie = MoreObjects.firstNonNull(flow.getCookie(), OFConstants.DEFAULT_FLOW_COOKIE).getValue();
         }
 
-
         @Override
-        public int hashCode() {
-            return intHashCode;
-        }
+        public boolean equals(final Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
 
-        @Override
-        public boolean equals(final Object obj) {
-            if (null == obj) {
-                return false;
-            }
-            if (!(obj instanceof FlowHash)) {
-                return false;
-            }
-            FlowHash that = (FlowHash) obj;
-            if (this.flowHash == that.getFlowHash()
-                    && this.tableId == that.getTableId()
-                    && this.priority == that.getPriority()
-                    && Objects.equals(this.cookie, that.getCookie())) {
-                return true;
-            }
-            return false;
+            final FlowRegistryKeyDto that = (FlowRegistryKeyDto) o;
+
+            if (priority != that.priority) return false;
+            if (tableId != that.tableId) return false;
+            if (!match.equals(that.match)) return false;
+
+            return true;
         }
 
         @Override
-        public long getFlowHash() {
-            return flowHash;
+        public int hashCode() {
+            int result = (int) tableId;
+            result = 31 * result + priority;
+            result = 31 * result + match.hashCode();
+            return result;
         }
 
         @Override
index 29eda5b168b8591b55dc71c788f3d7c065484fbe..975fcdd5566ae175ce61b2d49ea142a52d2aa448 100644 (file)
@@ -18,10 +18,10 @@ public class RpcManagerImpl implements RpcManager {
 
     private final RpcProviderRegistry rpcProviderRegistry;
     private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
-    private final Long maxRequestsQuota;
+    private final int maxRequestsQuota;
 
     public RpcManagerImpl(final RpcProviderRegistry rpcProviderRegistry,
-                          final Long quotaValue) {
+                          final int quotaValue) {
         this.rpcProviderRegistry = rpcProviderRegistry;
         maxRequestsQuota = quotaValue;
     }
@@ -33,7 +33,7 @@ public class RpcManagerImpl implements RpcManager {
 
     @Override
     public void onDeviceContextLevelUp(final DeviceContext deviceContext) {
-        final RpcContext rpcContext = new RpcContextImpl(deviceContext.getMessageSpy(), rpcProviderRegistry, deviceContext, maxRequestsQuota.intValue());
+        final RpcContext rpcContext = new RpcContextImpl(deviceContext.getMessageSpy(), rpcProviderRegistry, deviceContext, maxRequestsQuota);
         deviceContext.setDeviceDisconnectedHandler(rpcContext);
         MdSalRegistratorUtils.registerServices(rpcContext, deviceContext);
         // finish device initialization cycle back to DeviceManager
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartService.java
new file mode 100644 (file)
index 0000000..2881d6d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.util.concurrent.FutureCallback;
+import java.util.List;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+
+public abstract class AbstractMultipartService<I> extends AbstractService<I, List<MultipartReply>> {
+    protected AbstractMultipartService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext);
+    }
+
+    @Override
+    protected final FutureCallback<OfHeader> createCallback(final RequestContext<List<MultipartReply>> context, final Class<?> requestType) {
+        return new MultipartRequestCallback(context, requestType, getDeviceContext());
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java
new file mode 100644 (file)
index 0000000..47692c7
--- /dev/null
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.FutureCallback;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy.STATISTIC_GROUP;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+abstract class AbstractRequestCallback<T> implements FutureCallback<OfHeader> {
+    private final RequestContext<T> context;
+    private final Class<?> requestType;
+    private final MessageSpy spy;
+
+    protected AbstractRequestCallback(final RequestContext<T> context, final Class<?> requestType, final MessageSpy spy) {
+        this.context = Preconditions.checkNotNull(context);
+        this.requestType = Preconditions.checkNotNull(requestType);
+        this.spy = Preconditions.checkNotNull(spy);
+    }
+
+    protected final void setResult(@Nullable final RpcResult<T> result) {
+        context.setResult(result);
+        context.close();
+    }
+
+    protected final void spyMessage(@Nonnull final STATISTIC_GROUP group) {
+        spy.spyMessage(requestType, Preconditions.checkNotNull(group));
+    }
+
+    @Override
+    public final void onFailure(final Throwable t) {
+        final RpcResultBuilder<T> builder;
+        if (t instanceof DeviceRequestFailedException) {
+            final Error err = ((DeviceRequestFailedException) t).getError();
+            final String errorString = String.format("Device reported error type %s code %s", err.getTypeString(), err.getCodeString());
+
+            builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, errorString, t);
+            spyMessage(MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
+        } else {
+            builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, t.getMessage(), t);
+            spyMessage(MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_ERROR);
+        }
+
+        context.setResult(builder.build());
+        RequestContextUtil.closeRequstContext(context);
+    }
+}
similarity index 60%
rename from openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/CommonService.java
rename to openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java
index 169d06cf8a359f7b1ab8e53a6a0d96b54cade0e3..075271017e524b03eed72dbf9aa4a7532c15d7be 100644 (file)
@@ -7,24 +7,32 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Verify;
+import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
+import javax.annotation.Nonnull;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public abstract class CommonService {
-    private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(CommonService.class);
+abstract class AbstractService<I, O> {
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractService.class);
     private static final long WAIT_TIME = 2000;
     private static final BigInteger PRIMARY_CONNECTION = BigInteger.ZERO;
 
@@ -35,8 +43,7 @@ public abstract class CommonService {
     private final ConnectionAdapter primaryConnectionAdapter;
     private final MessageSpy messageSpy;
 
-
-    public CommonService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    public AbstractService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
         this.requestContextStack = requestContextStack;
         this.deviceContext = deviceContext;
         final FeaturesReply features = this.deviceContext.getPrimaryConnectionContext().getFeatures();
@@ -46,10 +53,6 @@ public abstract class CommonService {
         this.messageSpy = deviceContext.getMessageSpy();
     }
 
-    public static BigInteger getPrimaryConnection() {
-        return PRIMARY_CONNECTION;
-    }
-
     public short getVersion() {
         return version;
     }
@@ -66,43 +69,29 @@ public abstract class CommonService {
         return deviceContext;
     }
 
-    public ConnectionAdapter getPrimaryConnectionAdapter() {
-        return primaryConnectionAdapter;
-    }
-
     public MessageSpy getMessageSpy() {
         return messageSpy;
     }
 
-    protected long provideWaitTime() {
-        return WAIT_TIME;
-    }
-
+    protected abstract OfHeader buildRequest(Xid xid, I input);
+    protected abstract FutureCallback<OfHeader> createCallback(RequestContext<O> context, Class<?> requestType);
 
-    protected ConnectionAdapter provideConnectionAdapter(final BigInteger connectionID) {
-        if (connectionID == null) {
-            return primaryConnectionAdapter;
-        }
-        if (connectionID.equals(PRIMARY_CONNECTION)) {
-            return primaryConnectionAdapter;
-        }
+    public final ListenableFuture<RpcResult<O>> handleServiceCall(@Nonnull final I input) {
+        Preconditions.checkNotNull(input);
 
-        final ConnectionContext auxiliaryConnectionContext =
-                deviceContext.getAuxiliaryConnectiobContexts(connectionID);
-        if (auxiliaryConnectionContext != null) {
-            return auxiliaryConnectionContext.getConnectionAdapter();
+        final Class<?> requestType;
+        if (input instanceof DataContainer) {
+            requestType = ((DataContainer) input).getImplementedInterface();
+        } else {
+            requestType = input.getClass();
         }
-
-        return primaryConnectionAdapter;
-    }
-
-    public final <T> ListenableFuture<RpcResult<T>> handleServiceCall(final Function<RequestContext<T>, ListenableFuture<RpcResult<T>>> function) {
+        getMessageSpy().spyMessage(requestType, MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
 
         LOG.trace("Handling general service call");
-        final RequestContext<T> requestContext = createRequestContext();
+        final RequestContext<O> requestContext = requestContextStack.createRequestContext();
         if (requestContext == null) {
             LOG.trace("Request context refused.");
-            deviceContext.getMessageSpy().spyMessage(CommonService.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_DISREGARDED);
+            deviceContext.getMessageSpy().spyMessage(AbstractService.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_DISREGARDED);
             return failedFuture();
         }
 
@@ -112,14 +101,21 @@ public abstract class CommonService {
         }
 
         messageSpy.spyMessage(requestContext.getClass(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_READY_FOR_SUBMIT);
-        function.apply(requestContext);
-
-        return requestContext.getFuture();
 
-    }
+        final Xid xid = requestContext.getXid();
+        OfHeader request = null;
+        try {
+            request = buildRequest(xid, input);
+            Verify.verify(xid.getValue().equals(request.getXid()), "Expected XID %s got %s", xid.getValue(), request.getXid());
+        } catch (Exception e) {
+            LOG.error("Failed to build request for {}, forfeiting request {}", input, xid.getValue(), e);
+            // FIXME: complete the requestContext
+        } finally {
+            final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
+            outboundQueue.commitEntry(xid.getValue(), request, createCallback(requestContext, requestType));
+        }
 
-    protected final <T> RequestContext<T> createRequestContext() {
-        return requestContextStack.createRequestContext();
+        return requestContext.getFuture();
     }
 
     protected static <T> ListenableFuture<RpcResult<T>> failedFuture() {
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractSimpleService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractSimpleService.java
new file mode 100644 (file)
index 0000000..38de909
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.FutureCallback;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public abstract class AbstractSimpleService<I, O extends DataObject> extends AbstractService<I, O> {
+    private final Class<O> clazz;
+
+    protected AbstractSimpleService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+        super(requestContextStack, deviceContext);
+        this.clazz = Preconditions.checkNotNull(clazz);
+    }
+
+    @Override
+    protected final FutureCallback<OfHeader> createCallback(final RequestContext<O> context, final Class<?> requestType) {
+        return SimpleRequestCallback.create(context, requestType, getMessageSpy(), clazz);
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractVoidService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractVoidService.java
new file mode 100644 (file)
index 0000000..15ca0d1
--- /dev/null
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.util.concurrent.FutureCallback;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public abstract class AbstractVoidService<T extends DataObject> extends AbstractService<T, Void> {
+    protected AbstractVoidService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext);
+    }
+
+    @Override
+    protected final FutureCallback<OfHeader> createCallback(final RequestContext<Void> context, final Class<?> requestType) {
+        return new VoidRequestCallback(context, requestType, getMessageSpy());
+    }
+}
index 4450a82613c7d5aa05403d3205caf232c7f64ab6..bbba541d3d630be96aa732f918c7f36fce8a9b4b 100644 (file)
@@ -7,73 +7,31 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.util.concurrent.FutureCallback;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FlowCapableTransactionServiceImpl extends CommonService implements FlowCapableTransactionService {
-
-    private static final Logger LOG = LoggerFactory.getLogger(FlowCapableTransactionServiceImpl.class);
 
+public class FlowCapableTransactionServiceImpl extends AbstractVoidService<SendBarrierInput> implements FlowCapableTransactionService {
     public FlowCapableTransactionServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
         super(requestContextStack, deviceContext);
     }
 
     @Override
     public Future<RpcResult<Void>> sendBarrier(final SendBarrierInput input) {
-        final RequestContext<Void> requestContext = getRequestContextStack().createRequestContext();
-        if (requestContext == null) {
-            getMessageSpy().spyMessage(null, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-            return failedFuture();
-        }
-
+        return handleServiceCall(input);
+    }
 
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final SendBarrierInput input) {
         final BarrierInputBuilder barrierInputOFJavaBuilder = new BarrierInputBuilder();
-        final Xid xid = requestContext.getXid();
         barrierInputOFJavaBuilder.setVersion(getVersion());
         barrierInputOFJavaBuilder.setXid(xid.getValue());
-
-        LOG.trace("Hooking xid {} to device context - precaution.", requestContext.getXid().getValue());
-
-        final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-        final BarrierInput barrierInput = barrierInputOFJavaBuilder.build();
-        outboundQueue.commitEntry(xid.getValue(), barrierInput, new FutureCallback<OfHeader>() {
-
-            RpcResultBuilder<Void> rpcResultBuilder;
-            @Override
-            public void onSuccess(final OfHeader ofHeader) {
-                rpcResultBuilder = RpcResultBuilder.<Void>success();
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(barrierInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-                rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(barrierInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-            }
-        });
-        return requestContext.getFuture();
+        return barrierInputOFJavaBuilder.build();
     }
 }
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/FlowRemoveService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/FlowRemoveService.java
new file mode 100644 (file)
index 0000000..6a0bdf4
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+
+final class FlowRemoveService extends AbstractSimpleService<RemoveFlowInput, RemoveFlowOutput> {
+    FlowRemoveService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, RemoveFlowOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final RemoveFlowInput input) {
+        final FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(input, getVersion(),
+            getDatapathId());
+        ofFlowModInput.setXid(xid.getValue());
+        return ofFlowModInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/FlowService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/FlowService.java
new file mode 100644 (file)
index 0000000..ee0d64e
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+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.util.ArrayList;
+import java.util.List;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+final class FlowService<O extends DataObject> extends AbstractSimpleService<FlowModInputBuilder, O> {
+
+    protected FlowService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+        super(requestContextStack, deviceContext, clazz);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final FlowModInputBuilder input) {
+        input.setXid(xid.getValue());
+        return input.build();
+    }
+
+    List<FlowModInputBuilder> toFlowModInputs(final Flow input) {
+        return FlowConvertor.toFlowModInputs(input, getVersion(), getDatapathId());
+    }
+
+    ListenableFuture<RpcResult<O>> processFlowModInputBuilders(final List<FlowModInputBuilder> ofFlowModInputs) {
+        final List<ListenableFuture<RpcResult<O>>> partialFutures = new ArrayList<>(ofFlowModInputs.size());
+
+        for (final FlowModInputBuilder flowModInputBuilder : ofFlowModInputs) {
+            partialFutures.add(handleServiceCall(flowModInputBuilder));
+        }
+
+        final ListenableFuture<List<RpcResult<O>>> allFutures = Futures.successfulAsList(partialFutures);
+        final SettableFuture<RpcResult<O>> finalFuture = SettableFuture.create();
+        Futures.addCallback(allFutures, new FutureCallback<List<RpcResult<O>>>() {
+            @Override
+            public void onSuccess(final List<RpcResult<O>> results) {
+                RpcResultBuilder<O> rpcResultBuilder = RpcResultBuilder.success();
+                finalFuture.set(rpcResultBuilder.build());
+            }
+
+            @Override
+            public void onFailure(final Throwable t) {
+                RpcResultBuilder<O> rpcResultBuilder = RpcResultBuilder.failed();
+                finalFuture.set(rpcResultBuilder.build());
+            }
+        });
+
+        return finalFuture;
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/GroupService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/GroupService.java
new file mode 100644 (file)
index 0000000..431fea1
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+final class GroupService<I extends Group, O extends DataObject> extends AbstractSimpleService<I, O> {
+    GroupService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+        super(requestContextStack, deviceContext, clazz);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final I input) {
+        final GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(input, getVersion(), getDatapathId());
+        ofGroupModInput.setXid(xid.getValue());
+
+        return ofGroupModInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MeterService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MeterService.java
new file mode 100644 (file)
index 0000000..73cf63f
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+final class MeterService<I extends Meter, O extends DataObject> extends AbstractSimpleService<I, O> {
+
+    MeterService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+        super(requestContextStack, deviceContext, clazz);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final I input) {
+        final MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(input, getVersion());
+        ofMeterModInput.setXid(xid.getValue());
+        return ofMeterModInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestCallback.java
new file mode 100644 (file)
index 0000000..56a12a4
--- /dev/null
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import java.util.List;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+final class MultipartRequestCallback extends AbstractRequestCallback<List<MultipartReply>> {
+    private static final Logger LOG = LoggerFactory.getLogger(MultipartRequestCallback.class);
+    private final MultiMsgCollector collector;
+
+    public MultipartRequestCallback(final RequestContext<List<MultipartReply>> context, final Class<?> requestType, final DeviceContext deviceContext) {
+        super(context, requestType, deviceContext.getMessageSpy());
+        collector = deviceContext.getMultiMsgCollector(context);
+    }
+
+    @Override
+    public void onSuccess(final OfHeader result) {
+        if (result == null) {
+            LOG.info("Ofheader was null.");
+            collector.endCollecting();
+            return;
+        }
+
+        if (!(result instanceof MultipartReply)) {
+            LOG.info("Unexpected response type received {}.", result.getClass());
+            final RpcResultBuilder<List<MultipartReply>> rpcResultBuilder =
+                    RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION,
+                        String.format("Unexpected response type received %s.", result.getClass()));
+            setResult(rpcResultBuilder.build());
+        } else {
+            collector.addMultipartMsg((MultipartReply) result);
+        }
+    }
+
+}
index b04f5ed854b83c8fc7fe40a7d784236399fd409a..420dc80827b4209d86296f76fafbe09b12f01436 100644 (file)
@@ -7,73 +7,37 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-public class NodeConfigServiceImpl extends CommonService implements NodeConfigService {
-
 
+public final class NodeConfigServiceImpl extends AbstractSimpleService<SetConfigInput, SetConfigOutput> implements NodeConfigService {
     public NodeConfigServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+        super(requestContextStack, deviceContext, SetConfigOutput.class);
     }
 
     @Override
     public Future<RpcResult<SetConfigOutput>> setConfig(final SetConfigInput input) {
-        final RequestContext<SetConfigOutput> requestContext = createRequestContext();
-        if (requestContext == null) {
-            return failedFuture();
-        }
+        return handleServiceCall(input);
+    }
 
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final SetConfigInput input) {
         SetConfigInputBuilder builder = new SetConfigInputBuilder();
         SwitchConfigFlag flag = SwitchConfigFlag.valueOf(input.getFlag());
 
-        final Xid xid = requestContext.getXid();
         builder.setXid(xid.getValue());
         builder.setFlags(flag);
         builder.setMissSendLen(input.getMissSearchLength());
         builder.setVersion(getVersion());
-        final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
-        final SettableFuture<RpcResult<SetConfigOutput>> settableFuture = SettableFuture.create();
-        final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput setConfigInput = builder.build();
-        outboundQueue.commitEntry(xid.getValue(), setConfigInput, new FutureCallback<OfHeader>() {
-
-            RpcResultBuilder<SetConfigOutput> rpcResultBuilder;
-            @Override
-            public void onSuccess(final OfHeader ofHeader) {
-                rpcResultBuilder =  RpcResultBuilder.<SetConfigOutput>success();
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(setConfigInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-                rpcResultBuilder = RpcResultBuilder.<SetConfigOutput>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(setConfigInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-            }
-        });
-        return requestContext.getFuture();
-
+        return builder.build();
     }
 }
index bb818c476fdb020c36f648fef6e21f9aa56a2845..85e198ef24c6fd8c53ce1ec88e882451927be904 100644 (file)
@@ -7,26 +7,17 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-public class PacketProcessingServiceImpl extends CommonService implements PacketProcessingService {
+public final class PacketProcessingServiceImpl extends AbstractVoidService<TransmitPacketInput> implements PacketProcessingService {
 
     public PacketProcessingServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
         super(requestContextStack, deviceContext);
@@ -34,39 +25,11 @@ public class PacketProcessingServiceImpl extends CommonService implements Packet
 
     @Override
     public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
-        getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
-
-        return handleServiceCall(new Function<RequestContext<Void>, ListenableFuture<RpcResult<Void>>>() {
-            @Override
-            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<Void> requestContext) {
-                final Xid xid = requestContext.getXid();
-                final PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, getVersion(), xid.getValue(),
-                        getDatapathId());
-
-                final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
-                outboundQueue.commitEntry(xid.getValue(), message, new FutureCallback<OfHeader>() {
-
-                    RpcResultBuilder<Void> rpcResultBuilder;
-                    @Override
-                    public void onSuccess(final OfHeader ofHeader) {
-                        getMessageSpy().spyMessage(message.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-                        final RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.<Void>success();
-                        requestContext.setResult(rpcResultBuilder.build());
-                        RequestContextUtil.closeRequstContext(requestContext);
-                    }
-
-                    @Override
-                    public void onFailure(final Throwable throwable) {
-                        getMessageSpy().spyMessage(message.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-                        final RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                        requestContext.setResult(rpcResultBuilder.build());
-                        RequestContextUtil.closeRequstContext(requestContext);
-                    }
-                });
-                return requestContext.getFuture();
-            }
-        });
+        return handleServiceCall(input);
+    }
 
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final TransmitPacketInput input) {
+        return PacketOutConvertor.toPacketOutInput(input, getVersion(), xid.getValue(), getDatapathId());
     }
 }
index f125a9252b1fd5f2b5624bd08d73c9b98b5cfe9a..ce952bf1d1bc165d39ad422d8570418b9da6655b 100644 (file)
@@ -7,76 +7,33 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.util.concurrent.FutureCallback;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SalEchoService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SalEchoServiceImpl extends CommonService implements SalEchoService {
-
-    private static final Logger LOG = LoggerFactory.getLogger(SalEchoServiceImpl.class);
 
+public final class SalEchoServiceImpl extends AbstractSimpleService<SendEchoInput, SendEchoOutput> implements SalEchoService {
     public SalEchoServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+        super(requestContextStack, deviceContext, SendEchoOutput.class);
     }
 
     @Override
     public Future<RpcResult<SendEchoOutput>> sendEcho(final SendEchoInput sendEchoInput) {
-        final RequestContext<SendEchoOutput> requestContext = getRequestContextStack().createRequestContext();
-        if (requestContext == null) {
-            getMessageSpy().spyMessage(null, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-            return failedFuture();
-        }
-
-
+        return handleServiceCall(sendEchoInput);
+    }
 
-        LOG.trace("Hooking xid {} to device context - precaution.", requestContext.getXid().getValue());
-        final Xid xid = requestContext.getXid();
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final SendEchoInput input) {
         final EchoInputBuilder echoInputOFJavaBuilder = new EchoInputBuilder();
         echoInputOFJavaBuilder.setVersion(getVersion());
-        echoInputOFJavaBuilder.setXid(requestContext.getXid().getValue());
-        echoInputOFJavaBuilder.setData(sendEchoInput.getData());
-        final EchoInput echoInputOFJava = echoInputOFJavaBuilder.build();
-
-        LOG.debug("Echo with xid {} was sent from controller", xid);
-
-        final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-        outboundQueue.commitEntry(xid.getValue(), echoInputOFJava, new FutureCallback<OfHeader>() {
-
-            RpcResultBuilder<SendEchoOutput> rpcResultBuilder;
-            @Override
-            public void onSuccess(final OfHeader ofHeader) {
-                rpcResultBuilder = RpcResultBuilder.<SendEchoOutput>success();
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(echoInputOFJava.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-                rpcResultBuilder = RpcResultBuilder.<SendEchoOutput>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(echoInputOFJava.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-            }
-        });
-        return requestContext.getFuture();
+        echoInputOFJavaBuilder.setXid(xid.getValue());
+        echoInputOFJavaBuilder.setData(input.getData());
+        return echoInputOFJavaBuilder.build();
     }
 }
index 8342730fad7fe764fd6c6534974ab39f0cfae19c..515acd918631ded9aafc0d3a1b53fa398ccb50f2 100644 (file)
@@ -1,34 +1,27 @@
 /**
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- * <p/>
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.base.Function;
 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.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
-import org.opendaylight.openflowplugin.impl.registry.flow.FlowHashFactory;
+import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
 import org.opendaylight.openflowplugin.impl.util.FlowUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
@@ -44,29 +37,27 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Upda
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public class SalFlowServiceImpl extends CommonService implements SalFlowService {
-
-    private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalFlowServiceImpl.class);
+public class SalFlowServiceImpl implements SalFlowService {
+    private static final Logger LOG = LoggerFactory.getLogger(SalFlowServiceImpl.class);
+    private final FlowService<UpdateFlowOutput> flowUpdate;
+    private final FlowService<AddFlowOutput> flowAdd;
+    private final FlowRemoveService flowRemove;
 
     public SalFlowServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+        flowRemove = new FlowRemoveService(requestContextStack, deviceContext);
+        flowAdd = new FlowService<>(requestContextStack, deviceContext, AddFlowOutput.class);
+        flowUpdate = new FlowService<>(requestContextStack, deviceContext, UpdateFlowOutput.class);
     }
 
     @Override
     public Future<RpcResult<AddFlowOutput>> addFlow(final AddFlowInput input) {
-        getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
-
-        final List<FlowModInputBuilder> ofFlowModInputs = FlowConvertor.toFlowModInputs(input, getVersion(), getDatapathId());
-        final ListenableFuture<RpcResult<AddFlowOutput>> future = processFlowModInputBuilders(ofFlowModInputs);
+        final ListenableFuture<RpcResult<AddFlowOutput>> future = flowAdd.processFlowModInputBuilders(flowAdd.toFlowModInputs(input));
         final FlowId flowId;
         if (null != input.getFlowRef()) {
             flowId = input.getFlowRef().getValue().firstKeyOf(Flow.class, FlowKey.class).getId();
@@ -74,13 +65,11 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
             flowId = FlowUtil.createAlienFlowId(input.getTableId());
         }
 
-        final DeviceContext deviceContext = getDeviceContext();
-        final FlowHash flowHash = FlowHashFactory.create(input, deviceContext.getPrimaryConnectionContext().getFeatures().getVersion());
+        final DeviceContext deviceContext = flowAdd.getDeviceContext();
+        final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(input);
         final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create(input.getTableId(), flowId);
-        deviceContext.getDeviceFlowRegistry().store(flowHash, flowDescriptor);
+        deviceContext.getDeviceFlowRegistry().store(flowRegistryKey, flowDescriptor);
         Futures.addCallback(future, new FutureCallback<RpcResult<AddFlowOutput>>() {
-
-
             @Override
             public void onSuccess(final RpcResult<AddFlowOutput> rpcResult) {
                 if (rpcResult.isSuccessful()) {
@@ -92,7 +81,7 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
 
             @Override
             public void onFailure(final Throwable throwable) {
-                deviceContext.getDeviceFlowRegistry().markToBeremoved(flowHash);
+                deviceContext.getDeviceFlowRegistry().markToBeremoved(flowRegistryKey);
                 LOG.trace("Service call for adding flows failed, id={}.", flowId.getValue(), throwable);
             }
         });
@@ -103,44 +92,35 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
     @Override
     public Future<RpcResult<RemoveFlowOutput>> removeFlow(final RemoveFlowInput input) {
         LOG.trace("Calling remove flow for flow with ID ={}.", input.getFlowRef());
-        return handleServiceCall(new Function<RequestContext<RemoveFlowOutput>, ListenableFuture<RpcResult<RemoveFlowOutput>>>() {
-            @Override
-            public ListenableFuture<RpcResult<RemoveFlowOutput>> apply(final RequestContext<RemoveFlowOutput> requestContext) {
-                final FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(input, getVersion(),
-                        getDatapathId());
-                final ListenableFuture<RpcResult<RemoveFlowOutput>> future = createResultForFlowMod(requestContext, ofFlowModInput);
-                Futures.addCallback(future, new FutureCallback<RpcResult<RemoveFlowOutput>>() {
-                    @Override
-                    public void onSuccess(final RpcResult<RemoveFlowOutput> o) {
-                        final DeviceContext deviceContext = getDeviceContext();
-                        getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-                        FlowHash flowHash = FlowHashFactory.create(input, deviceContext.getPrimaryConnectionContext().getFeatures().getVersion());
-                        deviceContext.getDeviceFlowRegistry().markToBeremoved(flowHash);
-                    }
 
-                    @Override
-                    public void onFailure(final Throwable throwable) {
-                        getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-                        LOG.trace("Flow modification failed..", throwable);
+        final ListenableFuture<RpcResult<RemoveFlowOutput>> future = flowRemove.handleServiceCall(input);
+        Futures.addCallback(future, new FutureCallback<RpcResult<RemoveFlowOutput>>() {
+            @Override
+            public void onSuccess(final RpcResult<RemoveFlowOutput> result) {
+                if (result.isSuccessful()) {
+                    FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(input);
+                    flowRemove.getDeviceContext().getDeviceFlowRegistry().markToBeremoved(flowRegistryKey);
+                } else {
+                    if (LOG.isTraceEnabled()) {
                         StringBuilder errors = new StringBuilder();
-                        try {
-                            RpcResult<RemoveFlowOutput> result = future.get();
-                            Collection<RpcError> rpcErrors = result.getErrors();
-                            if (null != rpcErrors && rpcErrors.size() > 0) {
-                                for (RpcError rpcError : rpcErrors) {
-                                    errors.append(rpcError.getMessage());
-                                }
+                        Collection<RpcError> rpcErrors = result.getErrors();
+                        if (null != rpcErrors && rpcErrors.size() > 0) {
+                            for (RpcError rpcError : rpcErrors) {
+                                errors.append(rpcError.getMessage());
                             }
-                        } catch (InterruptedException | ExecutionException e) {
-                            LOG.trace("Flow modification failed. Can't read errors from RpcResult.");
-                        } finally {
-                            LOG.trace("Flow modification failed. Errors : {}", errors.toString());
                         }
+                        LOG.trace("Flow modification failed. Errors : {}", errors.toString());
                     }
-                });
-                return future;
+                }
+            }
+
+            @Override
+            public void onFailure(final Throwable throwable) {
+                LOG.trace("Flow modification failed..", throwable);
             }
         });
+
+        return future;
     }
 
     @Override
@@ -150,110 +130,42 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
         final OriginalFlow original = in.getOriginalFlow();
 
         final List<FlowModInputBuilder> allFlowMods = new ArrayList<>();
-        List<FlowModInputBuilder> ofFlowModInputs;
+        final List<FlowModInputBuilder> ofFlowModInputs;
 
-        if (!FlowCreatorUtil.canModifyFlow(original, updated, getVersion())) {
+        if (!FlowCreatorUtil.canModifyFlow(original, updated, flowUpdate.getVersion())) {
             // We would need to remove original and add updated.
 
             // remove flow
             final RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(original);
-            final List<FlowModInputBuilder> ofFlowRemoveInput = FlowConvertor.toFlowModInputs(removeflow.build(),
-                    getVersion(), getDatapathId());
+            final List<FlowModInputBuilder> ofFlowRemoveInput = flowUpdate.toFlowModInputs(removeflow.build());
             // remove flow should be the first
             allFlowMods.addAll(ofFlowRemoveInput);
             final AddFlowInputBuilder addFlowInputBuilder = new AddFlowInputBuilder(updated);
-            ofFlowModInputs = FlowConvertor.toFlowModInputs(addFlowInputBuilder.build(), getVersion(), getDatapathId());
+            ofFlowModInputs = flowUpdate.toFlowModInputs(addFlowInputBuilder.build());
         } else {
-            ofFlowModInputs = FlowConvertor.toFlowModInputs(updated, getVersion(), getDatapathId());
+            ofFlowModInputs = flowUpdate.toFlowModInputs(updated);
         }
 
         allFlowMods.addAll(ofFlowModInputs);
-        ListenableFuture<RpcResult<UpdateFlowOutput>> future = processFlowModInputBuilders(allFlowMods);
+        ListenableFuture<RpcResult<UpdateFlowOutput>> future = flowUpdate.processFlowModInputBuilders(allFlowMods);
         Futures.addCallback(future, new FutureCallback<RpcResult<UpdateFlowOutput>>() {
             @Override
             public void onSuccess(final RpcResult<UpdateFlowOutput> o) {
-                final DeviceContext deviceContext = getDeviceContext();
-                getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-                final short version = deviceContext.getPrimaryConnectionContext().getFeatures().getVersion();
-                FlowHash flowHash = FlowHashFactory.create(original, version);
+                FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(original);
 
-                FlowHash updatedflowHash = FlowHashFactory.create(updated, version);
+                FlowRegistryKey updatedflowRegistryKey = FlowRegistryKeyFactory.create(updated);
                 FlowId flowId = input.getFlowRef().getValue().firstKeyOf(Flow.class, FlowKey.class).getId();
                 FlowDescriptor flowDescriptor = FlowDescriptorFactory.create(updated.getTableId(), flowId);
-                final DeviceFlowRegistry deviceFlowRegistry = deviceContext.getDeviceFlowRegistry();
-                deviceFlowRegistry.markToBeremoved(flowHash);
-                deviceFlowRegistry.store(updatedflowHash, flowDescriptor);
+                final DeviceFlowRegistry deviceFlowRegistry = flowUpdate.getDeviceContext().getDeviceFlowRegistry();
+                deviceFlowRegistry.markToBeremoved(flowRegistryKey);
+                deviceFlowRegistry.store(updatedflowRegistryKey, flowDescriptor);
             }
 
             @Override
             public void onFailure(final Throwable throwable) {
-                getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
+                LOG.debug("Flow update failed", throwable);
             }
         });
         return future;
     }
-
-    private <T> ListenableFuture<RpcResult<T>> processFlowModInputBuilders(final List<FlowModInputBuilder> ofFlowModInputs) {
-
-        final List<ListenableFuture<RpcResult<T>>> partialFutures = new ArrayList<>();
-
-        for (final FlowModInputBuilder flowModInputBuilder : ofFlowModInputs) {
-            ListenableFuture<RpcResult<T>> partialFuture = handleServiceCall(
-                    new Function<RequestContext<T>, ListenableFuture<RpcResult<T>>>() {
-                        @Override
-                        public ListenableFuture<RpcResult<T>> apply(final RequestContext<T> requestContext) {
-                            return createResultForFlowMod(requestContext, flowModInputBuilder);
-                        }
-                    });
-            partialFutures.add(partialFuture);
-        }
-
-        final ListenableFuture<List<RpcResult<T>>> allFutures = Futures.successfulAsList(partialFutures);
-        final SettableFuture<RpcResult<T>> finalFuture = SettableFuture.create();
-        Futures.addCallback(allFutures, new FutureCallback<List<RpcResult<T>>>() {
-            @Override
-            public void onSuccess(final List<RpcResult<T>> results) {
-                RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.success();
-                finalFuture.set(rpcResultBuilder.build());
-            }
-
-            @Override
-            public void onFailure(final Throwable t) {
-                RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.failed();
-                finalFuture.set(rpcResultBuilder.build());
-            }
-        });
-
-        return finalFuture;
-    }
-
-    protected <T> ListenableFuture<RpcResult<T>> createResultForFlowMod(final RequestContext<T> requestContext, final FlowModInputBuilder flowModInputBuilder) {
-        final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-        final long xid = requestContext.getXid().getValue();
-        flowModInputBuilder.setXid(xid);
-        final FlowModInput flowModInput = flowModInputBuilder.build();
-
-        outboundQueue.commitEntry(xid, flowModInput, new FutureCallback<OfHeader>() {
-            @Override
-            public void onSuccess(final OfHeader ofHeader) {
-                getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
-                RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.<T>success();
-                requestContext.setResult(rpcResultBuilder.build());
-
-                RequestContextUtil.closeRequstContext(requestContext);
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-                getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-                RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.<T>failed().withError(ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                requestContext.setResult(rpcResultBuilder.build());
-
-                RequestContextUtil.closeRequstContext(requestContext);
-            }
-        });
-        return requestContext.getFuture();
-    }
-
 }
index 4eecd199692afd853d79c7866b2d44b6ef82ba51..2a6b134b702455415c595caf44f401f9de4bacd7 100644 (file)
@@ -7,17 +7,9 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
@@ -26,89 +18,33 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.Sal
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-
-public class SalGroupServiceImpl extends CommonService implements SalGroupService {
 
+public class SalGroupServiceImpl implements SalGroupService {
+    private final GroupService<AddGroupInput, AddGroupOutput> addGroup;
+    private final GroupService<Group, UpdateGroupOutput> updateGroup;
+    private final GroupService<RemoveGroupInput, RemoveGroupOutput> removeGroup;
 
     public SalGroupServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+        addGroup = new GroupService<>(requestContextStack, deviceContext, AddGroupOutput.class);
+        updateGroup = new GroupService<>(requestContextStack, deviceContext, UpdateGroupOutput.class);
+        removeGroup = new GroupService<>(requestContextStack, deviceContext, RemoveGroupOutput.class);
     }
 
-    private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalGroupServiceImpl.class);
-
     @Override
     public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
-        getDeviceContext().getDeviceGroupRegistry().store(input.getGroupId());
-        return handleServiceCall(new Function<RequestContext<AddGroupOutput>,
-                ListenableFuture<RpcResult<AddGroupOutput>>>() {
-            @Override
-            public ListenableFuture<RpcResult<AddGroupOutput>> apply(final RequestContext<AddGroupOutput> requestContext) {
-                return convertAndSend(input, requestContext);
-            }
-        });
+        addGroup.getDeviceContext().getDeviceGroupRegistry().store(input.getGroupId());
+        return addGroup.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
-        return handleServiceCall(new Function<RequestContext<UpdateGroupOutput>,
-                ListenableFuture<RpcResult<UpdateGroupOutput>>>() {
-
-            @Override
-            public ListenableFuture<RpcResult<UpdateGroupOutput>> apply(final RequestContext<UpdateGroupOutput> requestContext) {
-                return convertAndSend(input.getUpdatedGroup(), requestContext);
-            }
-        });
+        return updateGroup.handleServiceCall(input.getUpdatedGroup());
     }
 
     @Override
     public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
-        getDeviceContext().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
-        return handleServiceCall(new Function<RequestContext<RemoveGroupOutput>,
-                ListenableFuture<RpcResult<RemoveGroupOutput>>>() {
-
-            @Override
-            public ListenableFuture<RpcResult<RemoveGroupOutput>> apply(final RequestContext<RemoveGroupOutput> requestContext) {
-                return convertAndSend(input, requestContext);
-            }
-        });
-    }
-
-    <T> ListenableFuture<RpcResult<T>> convertAndSend(final Group iputGroup, final RequestContext<T> requestContext) {
-        final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-        getMessageSpy().spyMessage(iputGroup.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-        final GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(iputGroup, getVersion(), getDatapathId());
-        final Xid xid = requestContext.getXid();
-        ofGroupModInput.setXid(xid.getValue());
-
-        final GroupModInput groupModInput = ofGroupModInput.build();
-        outboundQueue.commitEntry(xid.getValue(), groupModInput, new FutureCallback<OfHeader>() {
-
-            RpcResultBuilder<T> rpcResultBuilder;
-            @Override
-            public void onSuccess(final OfHeader ofHeader) {
-                rpcResultBuilder = RpcResultBuilder.<T>success();
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(groupModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-                rpcResultBuilder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(groupModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-            }
-        });
-        return requestContext.getFuture();
+        removeGroup.getDeviceContext().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
+        return removeGroup.handleServiceCall(input);
     }
 }
index ec646feb3b08093582d0ed749bf75c80e864784c..bb6aa658b4036d5a15737cc085af21dd2ce1b4d7 100644 (file)
@@ -7,18 +7,9 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
@@ -27,87 +18,34 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Sal
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
 
-public class SalMeterServiceImpl extends CommonService implements SalMeterService {
-
-    private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalMeterServiceImpl.class);
+public class SalMeterServiceImpl implements SalMeterService {
+    private final MeterService<AddMeterInput, AddMeterOutput> addMeter;
+    private final MeterService<Meter, UpdateMeterOutput> updateMeter;
+    private final MeterService<RemoveMeterInput, RemoveMeterOutput> removeMeter;
 
     public SalMeterServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+        addMeter = new MeterService<>(requestContextStack, deviceContext, AddMeterOutput.class);
+        updateMeter = new MeterService<>(requestContextStack, deviceContext, UpdateMeterOutput.class);
+        removeMeter = new MeterService<>(requestContextStack, deviceContext, RemoveMeterOutput.class);
     }
 
     @Override
     public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
-        getDeviceContext().getDeviceMeterRegistry().store(input.getMeterId());
-        return handleServiceCall(new Function<RequestContext<AddMeterOutput>,
-                ListenableFuture<RpcResult<AddMeterOutput>>>() {
-            @Override
-            public ListenableFuture<RpcResult<AddMeterOutput>> apply(final RequestContext<AddMeterOutput> requestContext) {
-                return convertAndSend(input, requestContext);
-            }
-        });
+        addMeter.getDeviceContext().getDeviceMeterRegistry().store(input.getMeterId());
+
+        return addMeter.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
-        return handleServiceCall(new Function<RequestContext<UpdateMeterOutput>,
-                ListenableFuture<RpcResult<UpdateMeterOutput>>>() {
-            @Override
-            public ListenableFuture<RpcResult<UpdateMeterOutput>> apply(final RequestContext<UpdateMeterOutput> requestContext) {
-                return convertAndSend(input.getUpdatedMeter(), requestContext);
-            }
-        });
+        return updateMeter.handleServiceCall(input.getUpdatedMeter());
     }
 
     @Override
     public Future<RpcResult<RemoveMeterOutput>> removeMeter(final RemoveMeterInput input) {
-        getDeviceContext().getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
-        return handleServiceCall(new Function<RequestContext<RemoveMeterOutput>,
-                ListenableFuture<RpcResult<RemoveMeterOutput>>>() {
-            @Override
-            public ListenableFuture<RpcResult<RemoveMeterOutput>> apply(final RequestContext<RemoveMeterOutput> requestContext) {
-                return convertAndSend(input, requestContext);
-            }
-        });
-    }
-
-    <T> ListenableFuture<RpcResult<T>> convertAndSend(final Meter iputMeter, final RequestContext<T> requestContext) {
-        getMessageSpy().spyMessage(iputMeter.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-        final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
-        final MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(iputMeter, getVersion());
-        final Xid xid = requestContext.getXid();
-        ofMeterModInput.setXid(xid.getValue());
-
-        final MeterModInput meterModInput = ofMeterModInput.build();
-        outboundQueue.commitEntry(xid.getValue(), meterModInput, new FutureCallback<OfHeader>() {
-
-            RpcResultBuilder<T> rpcResultBuilder;
-            @Override
-            public void onSuccess(final OfHeader ofHeader) {
-                rpcResultBuilder = RpcResultBuilder.<T>success();
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(meterModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-                rpcResultBuilder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                requestContext.setResult(rpcResultBuilder.build());
-                RequestContextUtil.closeRequstContext(requestContext);
-
-                getMessageSpy().spyMessage(meterModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-            }
-        });
-        return requestContext.getFuture();
+        removeMeter.getDeviceContext().getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
+        return removeMeter.handleServiceCall(input);
     }
 }
index 5321832484b90bea2fea336a044774f44b4b42e9..3bd932bd0f04b145783a49609b82cabc57cc8f82 100644 (file)
@@ -7,16 +7,10 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
@@ -25,56 +19,25 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-
-public class SalPortServiceImpl extends CommonService implements SalPortService {
-    private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalPortServiceImpl.class);
 
+public final class SalPortServiceImpl extends AbstractSimpleService<UpdatePortInput, UpdatePortOutput> implements SalPortService {
     public SalPortServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+        super(requestContextStack, deviceContext, UpdatePortOutput.class);
     }
 
     @Override
     public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
-        return handleServiceCall(new Function<RequestContext<UpdatePortOutput>, ListenableFuture<RpcResult<UpdatePortOutput>>>() {
-            @Override
-            public ListenableFuture<RpcResult<UpdatePortOutput>> apply(final RequestContext<UpdatePortOutput> requestContext) {
-                getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
-                final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
-                final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, getVersion());
-                final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
-                final Xid xid = requestContext.getXid();
-                final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
-                mdInput.setXid(xid.getValue());
-                final PortModInput portModInput = mdInput.build();
-                outboundQueue.commitEntry(xid.getValue(), portModInput, new FutureCallback<OfHeader>() {
-                    RpcResultBuilder<UpdatePortOutput> rpcResultBuilder;
-                    @Override
-                    public void onSuccess(final OfHeader ofHeader) {
-                        rpcResultBuilder = RpcResultBuilder.<UpdatePortOutput>success();
-                        requestContext.setResult(rpcResultBuilder.build());
-                        RequestContextUtil.closeRequstContext(requestContext);
-
-                        getMessageSpy().spyMessage(portModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-                    }
+        return handleServiceCall(input);
+    }
 
-                    @Override
-                    public void onFailure(final Throwable throwable) {
-                        rpcResultBuilder = RpcResultBuilder.<UpdatePortOutput>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                        requestContext.setResult(rpcResultBuilder.build());
-                        RequestContextUtil.closeRequstContext(requestContext);
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final UpdatePortInput input) {
+        final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
+        final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, getVersion());
+        final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
+        mdInput.setXid(xid.getValue());
 
-                        getMessageSpy().spyMessage(portModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-                    }
-                });
-                return requestContext.getFuture();
-            }
-        });
+        return mdInput.build();
     }
-
 }
index a3edaf028d81bdb1ec40f3ad329f034cb1493792..f208c3726d5fd9f2460bc6130d9dd7b7287ef83f 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.base.Function;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -17,13 +16,9 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 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;
@@ -37,7 +32,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
@@ -53,14 +47,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd
 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.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 
-public class SalTableServiceImpl extends CommonService implements SalTableService {
-
+public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTableInput> implements SalTableService {
     private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalTableServiceImpl.class);
 
     public SalTableServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
@@ -69,80 +61,22 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
 
     @Override
     public Future<RpcResult<UpdateTableOutput>> updateTable(final UpdateTableInput input) {
-        class FunctionImpl implements
-                Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<List<MultipartReply>>>> {
-
-            @Override
-            public ListenableFuture<RpcResult<List<MultipartReply>>> apply(final RequestContext<List<MultipartReply>> requestContext) {
-                getMessageSpy().spyMessage(input.getImplementedInterface(),
-                        MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
-                final SettableFuture<RpcResult<List<MultipartReply>>> result = SettableFuture.create();
-
-                final MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
-                final MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
-                final List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input
-                        .getUpdatedTable());
-                requestBuilder.setTableFeatures(ofTableFeatureList);
-                caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
-
-                // Set request body to main multipart request
-                final Xid xid = requestContext.getXid();
-                final MultipartRequestInputBuilder mprInput = createMultipartHeader(MultipartType.OFPMPTABLEFEATURES,
-                        xid.getValue());
-                mprInput.setMultipartRequestBody(caseBuilder.build());
-                final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
-                final MultiMsgCollector multiMsgCollector = getDeviceContext().getMultiMsgCollector();
-                multiMsgCollector.registerMultipartRequestContext(requestContext);
-
-                final MultipartRequestInput multipartRequestInput = mprInput.build();
-                outboundQueue.commitEntry(xid.getValue(), multipartRequestInput, new FutureCallback<OfHeader>() {
-                    @Override
-                    public void onSuccess(final OfHeader ofHeader) {
-                        if (ofHeader instanceof MultipartReply) {
-                            MultipartReply multipartReply = (MultipartReply) ofHeader;
-                            multiMsgCollector.addMultipartMsg(multipartReply);
-                        } else {
-                            if (null != ofHeader) {
-                                LOG.info("Unexpected response type received {}.", ofHeader.getClass());
-                            } else {
-                                LOG.info("Response received is null.");
-                            }
-                        }
-                        getMessageSpy().spyMessage(multipartRequestInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-                    }
-
-                    @Override
-                    public void onFailure(final Throwable throwable) {
-                        RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                        RequestContextUtil.closeRequstContext(requestContext);
-                        multiMsgCollector.registerMultipartRequestContext(requestContext);
-                        getMessageSpy().spyMessage(multipartRequestInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-                    }
-                });
-                return requestContext.getFuture();
-            }
-        }
-
-        final ListenableFuture<RpcResult<List<MultipartReply>>> multipartFuture = handleServiceCall(new FunctionImpl());
+        final ListenableFuture<RpcResult<List<MultipartReply>>> multipartFuture = handleServiceCall(input);
         final SettableFuture<RpcResult<UpdateTableOutput>> finalFuture = SettableFuture.create();
 
         class CallBackImpl implements FutureCallback<RpcResult<List<MultipartReply>>> {
-            private final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(CallBackImpl.class);
-
             @Override
             public void onSuccess(final RpcResult<List<MultipartReply>> result) {
 
                 if (result.isSuccessful()) {
                     final List<MultipartReply> multipartReplies = result.getResult();
                     if (multipartReplies.isEmpty()) {
-                        LOGGER.debug("Multipart reply to table features request shouldn't be empty list.");
+                        LOG.debug("Multipart reply to table features request shouldn't be empty list.");
                         finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed()
                                 .withError(ErrorType.RPC, "Multipart reply list is empty.").build());
                     } else {
                         final Long xid = multipartReplies.get(0).getXid();
-                        LOGGER.debug(
+                        LOG.debug(
                                 "OnSuccess, rpc result successful, multipart response for rpc update-table with xid {} obtained.",
                                 xid);
                         final UpdateTableOutputBuilder updateTableOutputBuilder = new UpdateTableOutputBuilder();
@@ -151,7 +85,7 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
                         writeResponseToOperationalDatastore(multipartReplies);
                     }
                 } else {
-                    LOGGER.debug("OnSuccess, rpc result unsuccessful, multipart response for rpc update-table was unsuccessful.");
+                    LOG.debug("OnSuccess, rpc result unsuccessful, multipart response for rpc update-table was unsuccessful.");
                     finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed().withRpcErrors(result.getErrors())
                             .build());
                 }
@@ -159,59 +93,58 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
 
             @Override
             public void onFailure(final Throwable t) {
-                LOGGER.debug("Failure multipart response for table features request. Exception: {}", t);
+                LOG.debug("Failure multipart response for table features request. Exception: {}", t);
                 finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed()
                         .withError(ErrorType.RPC, "Future error", t).build());
             }
+        }
 
-            /**
-             * @param multipartReplies
-             */
-            private void writeResponseToOperationalDatastore(final List<MultipartReply> multipartReplies) {
-
-                final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeatures = convertToSalTableFeatures(multipartReplies);
-
-                final DeviceContext deviceContext = getDeviceContext();
-                final NodeId nodeId = deviceContext.getPrimaryConnectionContext().getNodeId();
-                final InstanceIdentifier<FlowCapableNode> flowCapableNodeII = InstanceIdentifier.create(Nodes.class)
-                        .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);
-                for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures tableFeatureData : salTableFeatures) {
-                    final Short tableId = tableFeatureData.getTableId();
-                    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,
-                            tableFeatureData);
-                }
+        Futures.addCallback(multipartFuture, new CallBackImpl());
 
-            }
+        return finalFuture;
+    }
 
-            private List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
-                    final List<MultipartReply> multipartReplies) {
-                final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll = new ArrayList<>();
-                for (MultipartReply multipartReply : multipartReplies) {
-                    if (multipartReply.getType().equals(MultipartType.OFPMPTABLEFEATURES)) {
-                        MultipartReplyBody multipartReplyBody = multipartReply.getMultipartReplyBody();
-                        if (multipartReplyBody instanceof MultipartReplyTableFeaturesCase) {
-                            MultipartReplyTableFeaturesCase tableFeaturesCase = ((MultipartReplyTableFeaturesCase) multipartReplyBody);
-                            MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase
-                                    .getMultipartReplyTableFeatures();
-                            List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesPartial = TableFeaturesReplyConvertor
-                                    .toTableFeaturesReply(salTableFeatures);
-                            salTableFeaturesAll.addAll(salTableFeaturesPartial);
-                            LOGGER.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
-                        }
-                    }
+    /**
+     * @param multipartReplies
+     */
+    private void writeResponseToOperationalDatastore(final List<MultipartReply> multipartReplies) {
+
+        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeatures = convertToSalTableFeatures(multipartReplies);
+
+        final DeviceContext deviceContext = getDeviceContext();
+        final NodeId nodeId = deviceContext.getPrimaryConnectionContext().getNodeId();
+        final InstanceIdentifier<FlowCapableNode> flowCapableNodeII = InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);
+        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,
+                    tableFeatureData);
+        }
+        deviceContext.submitTransaction();
+    }
+
+    protected static List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
+            final List<MultipartReply> multipartReplies) {
+        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll = new ArrayList<>();
+        for (final MultipartReply multipartReply : multipartReplies) {
+            if (multipartReply.getType().equals(MultipartType.OFPMPTABLEFEATURES)) {
+                final MultipartReplyBody multipartReplyBody = multipartReply.getMultipartReplyBody();
+                if (multipartReplyBody instanceof MultipartReplyTableFeaturesCase) {
+                    final MultipartReplyTableFeaturesCase tableFeaturesCase = ((MultipartReplyTableFeaturesCase) multipartReplyBody);
+                    final MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase
+                            .getMultipartReplyTableFeatures();
+                    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesPartial = TableFeaturesReplyConvertor
+                            .toTableFeaturesReply(salTableFeatures);
+                    salTableFeaturesAll.addAll(salTableFeaturesPartial);
+                    LOG.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
                 }
-                return salTableFeaturesAll;
             }
-
         }
-
-        Futures.addCallback(multipartFuture, new CallBackImpl());
-
-        return finalFuture;
+        return salTableFeaturesAll;
     }
 
     private MultipartRequestInputBuilder createMultipartHeader(final MultipartType multipart, final Long xid) {
@@ -223,4 +156,20 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
         return mprInput;
     }
 
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final UpdateTableInput input) {
+        final MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
+        final MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
+        final List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input
+            .getUpdatedTable());
+        requestBuilder.setTableFeatures(ofTableFeatureList);
+        caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
+
+        // Set request body to main multipart request
+        final MultipartRequestInputBuilder mprInput = createMultipartHeader(MultipartType.OFPMPTABLEFEATURES,
+            xid.getValue());
+        mprInput.setMultipartRequestBody(caseBuilder.build());
+
+        return mprInput.build();
+    }
 }
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SimpleRequestCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SimpleRequestCallback.java
new file mode 100644 (file)
index 0000000..034d2fa
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.FutureCallback;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+final class SimpleRequestCallback<T extends DataObject> extends AbstractRequestCallback<T> {
+    private static final Logger LOG = LoggerFactory.getLogger(SimpleRequestCallback.class);
+    private final Class<T> clazz;
+
+    private SimpleRequestCallback(final RequestContext<T> context, final Class<?> requestType, final MessageSpy spy, final Class<T> clazz) {
+        super(context, requestType, spy);
+        this.clazz = Preconditions.checkNotNull(clazz);
+    }
+
+    static <T extends DataObject> FutureCallback<OfHeader> create(final RequestContext<T> context, final Class<?> requestType, final MessageSpy spy, final Class<T> clazz) {
+        return new SimpleRequestCallback<>(context, requestType, spy, clazz);
+    }
+
+    @Override
+    public final void onSuccess(final OfHeader result) {
+        spyMessage(MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+
+        if (result == null) {
+            setResult(RpcResultBuilder.<T>success().build());
+            return;
+        }
+        if (!clazz.isInstance(result)) {
+            LOG.info("Expected response type {}, got {}, result is empty", clazz, result.getClass());
+            setResult(RpcResultBuilder.<T>success().build());
+            return;
+
+        }
+
+        setResult(RpcResultBuilder.success(clazz.cast(result)).build());
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/VoidRequestCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/VoidRequestCallback.java
new file mode 100644 (file)
index 0000000..5860a18
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy.STATISTIC_GROUP;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+final class VoidRequestCallback extends AbstractRequestCallback<Void> {
+    private static final RpcResult<Void> SUCCESS = RpcResultBuilder.<Void>success().build();
+
+    VoidRequestCallback(final RequestContext<Void> context, final Class<?> requestType, final MessageSpy spy) {
+        super(context, requestType, spy);
+    }
+
+    @Override
+    public void onSuccess(final OfHeader result) {
+        spyMessage(STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS_NO_RESPONSE);
+        setResult(SUCCESS);
+    }
+}
index 3b19338e46d68159f865453981f0cfc8cbf3991c..4e74a51de50410469d31124bf8d6f9856e15e6e7 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.statistics;
 
+import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -16,6 +17,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import javax.annotation.CheckForNull;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
@@ -37,68 +39,77 @@ public class StatisticsContextImpl implements StatisticsContext {
     private static final String CONNECTION_CLOSED = "Connection closed.";
     private final Collection<RequestContext<?>> requestContexts = new HashSet<>();
     private final DeviceContext deviceContext;
+    private final DeviceState devState;
+    private final ListenableFuture<Boolean> emptyFuture;
 
     private final StatisticsGatheringService statisticsGatheringService;
 
-    public StatisticsContextImpl(final DeviceContext deviceContext) {
-        this.deviceContext = deviceContext;
+    public StatisticsContextImpl(@CheckForNull final DeviceContext deviceContext) {
+        this.deviceContext = Preconditions.checkNotNull(deviceContext);
+        devState = Preconditions.checkNotNull(deviceContext.getDeviceState());
+        emptyFuture = Futures.immediateFuture(new Boolean(false));
         statisticsGatheringService = new StatisticsGatheringService(this, deviceContext);
     }
 
     @Override
     public ListenableFuture<Boolean> gatherDynamicData() {
-
         final SettableFuture<Boolean> settableResultingFuture = SettableFuture.create();
-        ListenableFuture<Boolean> resultingFuture = settableResultingFuture;
-
-
-        if (ConnectionContext.CONNECTION_STATE.WORKING.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
-            final DeviceState devState = deviceContext.getDeviceState();
-            final ListenableFuture<Boolean> emptyFuture = Futures.immediateFuture(new Boolean(false));
-            final ListenableFuture<Boolean> flowStatistics = devState.isFlowStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPFLOW) : emptyFuture;
-
-            final ListenableFuture<Boolean> tableStatistics = devState.isTableStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPTABLE) : emptyFuture;
-
-            final ListenableFuture<Boolean> portStatistics = devState.isPortStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPPORTSTATS) : emptyFuture;
-
-            final ListenableFuture<Boolean> queueStatistics = devState.isQueueStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPQUEUE) : emptyFuture;
-
-            final ListenableFuture<Boolean> groupDescStatistics = devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPGROUPDESC) : emptyFuture;
-            final ListenableFuture<Boolean> groupStatistics = devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPGROUP) : emptyFuture;
-
-            final ListenableFuture<Boolean> meterConfigStatistics = devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPMETERCONFIG) : emptyFuture;
-            final ListenableFuture<Boolean> meterStatistics = devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPMETER) : emptyFuture;
-
-
-            final ListenableFuture<List<Boolean>> allFutures = Futures.allAsList(Arrays.asList(flowStatistics, tableStatistics, groupDescStatistics, groupStatistics, meterConfigStatistics, meterStatistics, portStatistics, queueStatistics));
-            Futures.addCallback(allFutures, new FutureCallback<List<Boolean>>() {
-                @Override
-                public void onSuccess(final List<Boolean> booleans) {
-                    boolean atLeastOneSuccess = false;
-                    for (final Boolean bool : booleans) {
-                        atLeastOneSuccess |= bool.booleanValue();
-                    }
-                    settableResultingFuture.set(new Boolean(atLeastOneSuccess));
-                }
-
-                @Override
-                public void onFailure(final Throwable throwable) {
-                    settableResultingFuture.setException(throwable);
+        final ListenableFuture<Boolean> flowStatistics = gatherDynamicData(MultipartType.OFPMPFLOW);
+        final ListenableFuture<Boolean> tableStatistics = gatherDynamicData(MultipartType.OFPMPTABLE);
+        final ListenableFuture<Boolean> portStatistics = gatherDynamicData(MultipartType.OFPMPPORTSTATS);
+        final ListenableFuture<Boolean> queueStatistics = gatherDynamicData(MultipartType.OFPMPQUEUE);
+        final ListenableFuture<Boolean> groupDescStatistics = gatherDynamicData(MultipartType.OFPMPGROUPDESC);
+        final ListenableFuture<Boolean> groupStatistics = gatherDynamicData(MultipartType.OFPMPGROUP);
+        final ListenableFuture<Boolean> meterConfigStatistics = gatherDynamicData(MultipartType.OFPMPMETERCONFIG);
+        final ListenableFuture<Boolean> meterStatistics = gatherDynamicData(MultipartType.OFPMPMETER);
+
+        final ListenableFuture<List<Boolean>> allFutures = Futures.allAsList(Arrays.asList(flowStatistics, tableStatistics, groupDescStatistics, groupStatistics, meterConfigStatistics, meterStatistics, portStatistics, queueStatistics));
+        Futures.addCallback(allFutures, new FutureCallback<List<Boolean>>() {
+            @Override
+            public void onSuccess(final List<Boolean> booleans) {
+                boolean atLeastOneSuccess = false;
+                for (final Boolean bool : booleans) {
+                    atLeastOneSuccess |= bool.booleanValue();
                 }
-            });
-        } else {
-            switch (deviceContext.getPrimaryConnectionContext().getConnectionState()) {
-                case RIP:
-                    resultingFuture = Futures.immediateFailedFuture(new Throwable(String.format("Device connection doesn't exist anymore. Primary connection status : %s", deviceContext.getPrimaryConnectionContext().getConnectionState())));
-                    break;
-                default:
-                    resultingFuture = Futures.immediateCheckedFuture(Boolean.TRUE);
-                    break;
+                settableResultingFuture.set(new Boolean(atLeastOneSuccess));
             }
 
+            @Override
+            public void onFailure(final Throwable throwable) {
+                settableResultingFuture.setException(throwable);
+            }
+        });
+        return settableResultingFuture;
+    }
 
+    @Override
+    public ListenableFuture<Boolean> gatherDynamicData(final MultipartType multipartType) {
+        Preconditions.checkArgument(multipartType != null);
+        final ListenableFuture<Boolean> resultingFuture = deviceConnectionCheck();
+        if (resultingFuture != null) {
+            return resultingFuture;
+        }
+        switch (multipartType) {
+        case OFPMPFLOW:
+            return collectFlowStatistics(multipartType);
+        case OFPMPTABLE:
+            return collectTableStatistics(multipartType);
+        case OFPMPPORTSTATS:
+            return collectPortStatistics(multipartType);
+        case OFPMPQUEUE:
+            return collectQueueStatistics(multipartType);
+        case OFPMPGROUPDESC:
+            return collectGroupDescStatistics(multipartType);
+        case OFPMPGROUP:
+            return collectGroupStatistics(multipartType);
+        case OFPMPMETERCONFIG:
+            return collectMeterConfigStatistics(multipartType);
+        case OFPMPMETER:
+            return collectMeterStatistics(multipartType);
+        default:
+            LOG.warn("Unsuported Statistics type {}", multipartType);
+            return Futures.immediateCheckedFuture(Boolean.TRUE);
         }
-        return resultingFuture;
     }
 
     @Override
@@ -119,4 +130,68 @@ public class StatisticsContextImpl implements StatisticsContext {
             RequestContextUtil.closeRequestContextWithRpcError(requestContext, CONNECTION_CLOSED);
         }
     }
+
+    /**
+     * Method checks a device state. It returns null for be able continue. Otherwise it returns immediateFuture
+     * which has to be returned from caller too
+     *
+     * @return
+     */
+    private ListenableFuture<Boolean> deviceConnectionCheck() {
+        if ( ! ConnectionContext.CONNECTION_STATE.WORKING.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
+            ListenableFuture<Boolean> resultingFuture = SettableFuture.create();
+            switch (deviceContext.getPrimaryConnectionContext().getConnectionState()) {
+            case RIP:
+                final String errMsg = String.format("Device connection doesn't exist anymore. Primary connection status : %s",
+                        deviceContext.getPrimaryConnectionContext().getConnectionState());
+                resultingFuture = Futures.immediateFailedFuture(new Throwable(errMsg));
+                break;
+            default:
+                resultingFuture = Futures.immediateCheckedFuture(Boolean.TRUE);
+                break;
+            }
+            return resultingFuture;
+        }
+        return null;
+    }
+
+    private ListenableFuture<Boolean> collectFlowStatistics(final MultipartType multipartType) {
+        return devState.isFlowStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPFLOW*/ multipartType) : emptyFuture;
+    }
+
+    private ListenableFuture<Boolean> collectTableStatistics(final MultipartType multipartType) {
+        return devState.isTableStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPTABLE*/ multipartType) : emptyFuture;
+    }
+
+    private ListenableFuture<Boolean> collectPortStatistics(final MultipartType multipartType) {
+        return devState.isPortStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPPORTSTATS*/ multipartType) : emptyFuture;
+    }
+
+    private ListenableFuture<Boolean> collectQueueStatistics(final MultipartType multipartType) {
+        return devState.isQueueStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPQUEUE*/ multipartType) : emptyFuture;
+    }
+
+    private ListenableFuture<Boolean> collectGroupDescStatistics(final MultipartType multipartType) {
+        return devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPGROUPDESC*/ multipartType) : emptyFuture;
+    }
+
+    private ListenableFuture<Boolean> collectGroupStatistics(final MultipartType multipartType) {
+        return devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPGROUP*/ multipartType) : emptyFuture;
+    }
+
+    private ListenableFuture<Boolean> collectMeterConfigStatistics(final MultipartType multipartType) {
+        return devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPMETERCONFIG*/ multipartType) : emptyFuture;
+    }
+
+    private ListenableFuture<Boolean> collectMeterStatistics(final MultipartType multipartType) {
+        return devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+                statisticsGatheringService, deviceContext, /*MultipartType.OFPMPMETER*/ multipartType) : emptyFuture;
+    }
 }
index db67901af30e446dd17d7c29f367ea49a216fbd6..d3eabd2b6eea0fb120c0ae642bef2aea2c703de2 100644 (file)
@@ -23,8 +23,8 @@ import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
-import org.opendaylight.openflowplugin.impl.registry.flow.FlowHashFactory;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
+import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
 import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
@@ -106,9 +106,7 @@ public final class StatisticsGatheringUtils {
         throw new IllegalStateException("This class should not be instantiated.");
     }
 
-    private static KeyedInstanceIdentifier<Node, NodeKey> getInstanceIdentifier(final DeviceContext deviceContext) {
-        return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(deviceContext.getPrimaryConnectionContext().getNodeId()));
-    }
+
 
     public static ListenableFuture<Boolean> gatherStatistics(final StatisticsGatheringService statisticsGatheringService,
                                                              final DeviceContext deviceContext,
@@ -135,14 +133,10 @@ public final class StatisticsGatheringUtils {
                         allMultipartData = Iterables.concat(allMultipartData, multipartDataList);
                     }
 
-                    if (deviceContext.getDeviceState().isValid()) {
-                        deviceContext.startGatheringOperationsToOneTransaction();
-                    }
-
                     if (multipartData instanceof GroupStatisticsUpdated) {
-                        processGroupStatistics((Iterable<GroupStatisticsUpdated>)allMultipartData, deviceContext);
+                        processGroupStatistics((Iterable<GroupStatisticsUpdated>) allMultipartData, deviceContext);
                     } else if (multipartData instanceof MeterStatisticsUpdated) {
-                        processMetersStatistics((Iterable<MeterStatisticsUpdated>)allMultipartData, deviceContext);
+                        processMetersStatistics((Iterable<MeterStatisticsUpdated>) allMultipartData, deviceContext);
                     } else if (multipartData instanceof NodeConnectorStatisticsUpdate) {
                         processNodeConnectorStatistics((Iterable<NodeConnectorStatisticsUpdate>) allMultipartData, deviceContext);
                     } else if (multipartData instanceof FlowTableStatisticsUpdate) {
@@ -150,7 +144,7 @@ public final class StatisticsGatheringUtils {
                     } else if (multipartData instanceof QueueStatisticsUpdate) {
                         processQueueStatistics((Iterable<QueueStatisticsUpdate>) allMultipartData, deviceContext);
                     } else if (multipartData instanceof FlowsStatisticsUpdate) {
-                        processFlowStatistics((Iterable<FlowsStatisticsUpdate>)allMultipartData, deviceContext);
+                        processFlowStatistics((Iterable<FlowsStatisticsUpdate>) allMultipartData, deviceContext);
                     } else if (multipartData instanceof GroupDescStatsUpdated) {
                         processGroupDescStats((Iterable<GroupDescStatsUpdated>) allMultipartData, deviceContext);
                     } else if (multipartData instanceof MeterConfigStatsUpdated) {
@@ -160,9 +154,6 @@ public final class StatisticsGatheringUtils {
                     }
                     //TODO : implement experimenter
 
-                    if (deviceContext.getDeviceState().isValid()) {
-                        deviceContext.commitOperationsGatheredInOneTransaction();
-                    }
                     return isMultipartProcessed;
                 }
                 return Boolean.FALSE;
@@ -172,9 +163,9 @@ public final class StatisticsGatheringUtils {
 
     private static void processMeterConfigStatsUpdated(final Iterable<MeterConfigStatsUpdated> data, final DeviceContext deviceContext) {
         for (final MeterConfigStatsUpdated meterConfigStatsUpdated : data) {
-            NodeId nodeId = meterConfigStatsUpdated.getId();
+            final NodeId nodeId = meterConfigStatsUpdated.getId();
             final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
-            for (MeterConfigStats meterConfigStats : meterConfigStatsUpdated.getMeterConfigStats()) {
+            for (final MeterConfigStats meterConfigStats : meterConfigStatsUpdated.getMeterConfigStats()) {
                 final MeterId meterId = meterConfigStats.getMeterId();
                 final InstanceIdentifier<Meter> meterInstanceIdentifier = fNodeIdent.child(Meter.class, new MeterKey(meterId));
 
@@ -185,6 +176,7 @@ public final class StatisticsGatheringUtils {
                 deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, meterInstanceIdentifier, meterBuilder.build());
             }
         }
+        deviceContext.submitTransaction();
     }
 
     private static void processFlowStatistics(final Iterable<FlowsStatisticsUpdate> data, final DeviceContext deviceContext) {
@@ -195,11 +187,9 @@ public final class StatisticsGatheringUtils {
         for (final FlowsStatisticsUpdate flowsStatistics : data) {
             for (final FlowAndStatisticsMapList flowStat : flowsStatistics.getFlowAndStatisticsMapList()) {
                 final FlowBuilder flowBuilder = new FlowBuilder(flowStat);
-                short tableId = flowStat.getTableId();
-                final Short version = deviceContext.getPrimaryConnectionContext().getFeatures().getVersion();
-
-                final FlowHash flowHash = FlowHashFactory.create(flowBuilder.build(), version);
-                final FlowId flowId = deviceContext.getDeviceFlowRegistry().storeIfNecessary(flowHash, tableId);
+                final short tableId = flowStat.getTableId();
+                final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(flowBuilder.build());
+                final FlowId flowId = deviceContext.getDeviceFlowRegistry().storeIfNecessary(flowRegistryKey, tableId);
 
                 final FlowKey flowKey = new FlowKey(flowId);
                 flowBuilder.setKey(flowKey);
@@ -209,27 +199,28 @@ public final class StatisticsGatheringUtils {
                 deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build());
             }
         }
+        deviceContext.submitTransaction();
     }
 
     private static void deleteAllKnownFlows(final DeviceContext deviceContext, final InstanceIdentifier<Node> nodeIdent) {
         if (deviceContext.getDeviceState().deviceSynchronized()) {
             final Short numOfTablesOnDevice = deviceContext.getDeviceState().getFeatures().getTables();
             for (short i=0; i<numOfTablesOnDevice; i++) {
-                KeyedInstanceIdentifier<Table, TableKey> iiToTable
-                    = nodeIdent.augmentation(FlowCapableNode.class).child( Table.class, new TableKey(i) );
+                final KeyedInstanceIdentifier<Table, TableKey> iiToTable
+                    = nodeIdent.augmentation(FlowCapableNode.class).child( Table.class, new TableKey(i));
                 final ReadTransaction readTx = deviceContext.getReadTransaction();
-                CheckedFuture<Optional<Table>, ReadFailedException> tableDataFuture = readTx.read(LogicalDatastoreType.OPERATIONAL, iiToTable);
+                final CheckedFuture<Optional<Table>, ReadFailedException> tableDataFuture = readTx.read(LogicalDatastoreType.OPERATIONAL, iiToTable);
                 try {
-                    Optional<Table> tableDataOpt = tableDataFuture.get();
+                    final Optional<Table> tableDataOpt = tableDataFuture.get();
                     if (tableDataOpt.isPresent()) {
                         final Table tableData = tableDataOpt.get();
                         final Table table = new TableBuilder(tableData).setFlow(Collections.<Flow>emptyList()).build();
                         deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTable, table);
                     }
-                } catch (InterruptedException e) {
-                    LOG.trace("Reading of table features for table wit ID {} was interrputed.",i);
-                } catch (ExecutionException e) {
-                    LOG.trace("Reading of table features for table wit ID {} encountered execution exception {}.",i,e);
+                } catch (final InterruptedException e) {
+                    LOG.trace("Reading of table features for table wit ID {} was interrputed.", i);
+                } catch (final ExecutionException e) {
+                    LOG.trace("Reading of table features for table wit ID {} encountered execution exception {}.", i, e);
                 }
             }
         }
@@ -256,10 +247,11 @@ public final class StatisticsGatheringUtils {
                 }
             }
         }
+        deviceContext.submitTransaction();
     }
 
     private static void processFlowTableStatistics(final Iterable<FlowTableStatisticsUpdate> data, final DeviceContext deviceContext) {
-        for(final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
+        for (final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
             final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(flowTableStatisticsUpdate.getId());
 
             for (final FlowTableAndStatisticsMap tableStat : flowTableStatisticsUpdate.getFlowTableAndStatisticsMap()) {
@@ -269,6 +261,7 @@ public final class StatisticsGatheringUtils {
                 deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tStatIdent, stats);
             }
         }
+        deviceContext.submitTransaction();
     }
 
     private static void processNodeConnectorStatistics(final Iterable<NodeConnectorStatisticsUpdate> data, final DeviceContext deviceContext) {
@@ -286,14 +279,15 @@ public final class StatisticsGatheringUtils {
                 deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowCapNodeConnStatIdent, stats);
             }
         }
+        deviceContext.submitTransaction();
     }
 
     private static void processMetersStatistics(final Iterable<MeterStatisticsUpdated> data,
                                                 final DeviceContext deviceContext) {
-        NodeId nodeId = deviceContext.getDeviceState().getNodeId();
+        final NodeId nodeId = deviceContext.getDeviceState().getNodeId();
         final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
         deleteAllKnownMeters(deviceContext, fNodeIdent);
-        for (MeterStatisticsUpdated meterStatisticsUpdated : data) {
+        for (final MeterStatisticsUpdated meterStatisticsUpdated : data) {
             for (final MeterStats mStat : meterStatisticsUpdated.getMeterStats()) {
                 final MeterStatistics stats = new MeterStatisticsBuilder(mStat).build();
                 final MeterId meterId = mStat.getMeterId();
@@ -304,10 +298,11 @@ public final class StatisticsGatheringUtils {
                 deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, msIdent, stats);
             }
         }
+        deviceContext.submitTransaction();
     }
 
     private static void deleteAllKnownMeters(final DeviceContext deviceContext, final InstanceIdentifier<FlowCapableNode> fNodeIdent) {
-        for (MeterId meterId : deviceContext.getDeviceMeterRegistry().getAllMeterIds()) {
+        for (final MeterId meterId : deviceContext.getDeviceMeterRegistry().getAllMeterIds()) {
             final InstanceIdentifier<Meter> meterIdent = fNodeIdent.child(Meter.class, new MeterKey(meterId));
             deviceContext.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, meterIdent);
         }
@@ -315,11 +310,11 @@ public final class StatisticsGatheringUtils {
     }
 
     private static void processGroupDescStats(final Iterable<GroupDescStatsUpdated> data, final DeviceContext deviceContext) {
-        for ( GroupDescStatsUpdated groupDescStatsUpdated : data) {
-            NodeId nodeId = groupDescStatsUpdated.getId();
+        for (final GroupDescStatsUpdated groupDescStatsUpdated : data) {
+            final NodeId nodeId = groupDescStatsUpdated.getId();
             final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
 
-            for (GroupDescStats groupDescStats : groupDescStatsUpdated.getGroupDescStats()) {
+            for (final GroupDescStats groupDescStats : groupDescStatsUpdated.getGroupDescStats()) {
                 final GroupId groupId = groupDescStats.getGroupId();
 
                 final GroupBuilder groupBuilder = new GroupBuilder(groupDescStats);
@@ -332,10 +327,11 @@ public final class StatisticsGatheringUtils {
                 deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, groupIdent, groupBuilder.build());
             }
         }
+        deviceContext.submitTransaction();
     }
 
     private static void deleteAllKnownGroups(final DeviceContext deviceContext, final InstanceIdentifier<FlowCapableNode> fNodeIdent) {
-        for (GroupId groupId : deviceContext.getDeviceGroupRegistry().getAllGroupIds()) {
+        for (final GroupId groupId : deviceContext.getDeviceGroupRegistry().getAllGroupIds()) {
             final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(groupId));
             deviceContext.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, groupIdent);
         }
@@ -343,10 +339,10 @@ public final class StatisticsGatheringUtils {
     }
 
     private static void processGroupStatistics(final Iterable<GroupStatisticsUpdated> data, final DeviceContext deviceContext) {
-        NodeId nodeId = deviceContext.getDeviceState().getNodeId();
+        final NodeId nodeId = deviceContext.getDeviceState().getNodeId();
         final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
         deleteAllKnownGroups(deviceContext, fNodeIdent);
-        for (GroupStatisticsUpdated groupStatistics : data) {
+        for (final GroupStatisticsUpdated groupStatistics : data) {
             for (final GroupStats groupStats : groupStatistics.getGroupStats()) {
 
                 final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(groupStats.getGroupId()));
@@ -358,6 +354,7 @@ public final class StatisticsGatheringUtils {
                 deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gsIdent, stats);
             }
         }
+        deviceContext.submitTransaction();
     }
 
     private static InstanceIdentifier<FlowCapableNode> getFlowCapableNodeInstanceIdentifier(final NodeId nodeId) {
index 31e8f3112fac12860147764fd9f7674ec9ce1dd8..ebcb995d30309b0f13a6968b266713a29a2db2e1 100644 (file)
@@ -16,6 +16,7 @@ import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
+import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
@@ -53,7 +54,6 @@ public class StatisticsManagerImpl implements StatisticsManager {
         if (null == hashedWheelTimer) {
             LOG.trace("This is first device that delivered timer. Starting statistics polling immediately.");
             hashedWheelTimer = deviceContext.getTimer();
-            pollStatistics();
         }
 
         final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceContext);
@@ -65,6 +65,7 @@ public class StatisticsManagerImpl implements StatisticsManager {
                 if (statisticsGathered.booleanValue()) {
                     //there are some statistics on device worth gathering
                     contexts.put(deviceContext, statisticsContext);
+                    pollStatistics(deviceContext, statisticsContext);
                 }
                 LOG.trace("Device dynamic info collecting done. Going to announce raise to next level.");
                 deviceInitPhaseHandler.onDeviceContextLevelUp(deviceContext);
@@ -83,35 +84,38 @@ public class StatisticsManagerImpl implements StatisticsManager {
         });
     }
 
-    private void pollStatistics() {
-        try {
-            timeCounter.markStart();
-            for (final StatisticsContext statisticsContext : contexts.values()) {
-                ListenableFuture<Boolean> deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
-                Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
-                    @Override
-                    public void onSuccess(final Boolean o) {
-                        timeCounter.addTimeMark();
-                    }
-
-                    @Override
-                    public void onFailure(final Throwable throwable) {
-                        timeCounter.addTimeMark();
-                        LOG.info("Statistics gathering for single node was not successful: {}", throwable.getMessage());
-                        LOG.debug("Statistics gathering for single node was not successful.. ", throwable);
-                    }
-                });
+    private void pollStatistics(final DeviceContext deviceContext, final StatisticsContext statisticsContext) {
+        timeCounter.markStart();
+        ListenableFuture<Boolean> deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
+        Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
+            @Override
+            public void onSuccess(final Boolean o) {
+                timeCounter.addTimeMark();
+                calculateTimerDelay();
+                scheduleNextPolling(deviceContext, statisticsContext);
             }
-        } finally {
-            calculateTimerDelay();
-            if (null != hashedWheelTimer) {
-                hashedWheelTimer.newTimeout(new TimerTask() {
-                    @Override
-                    public void run(final Timeout timeout) throws Exception {
-                        pollStatistics();
-                    }
-                }, currentTimerDelay, TimeUnit.MILLISECONDS);
+
+            @Override
+            public void onFailure(final Throwable throwable) {
+                timeCounter.addTimeMark();
+                LOG.info("Statistics gathering for single node was not successful: {}", throwable.getMessage());
+                LOG.debug("Statistics gathering for single node was not successful.. ", throwable);
+                if (ConnectionContext.CONNECTION_STATE.WORKING.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
+                    calculateTimerDelay();
+                    scheduleNextPolling(deviceContext, statisticsContext);
+                }
             }
+        });
+    }
+
+    private void scheduleNextPolling(final DeviceContext deviceContext, final StatisticsContext statisticsContext) {
+        if (null != hashedWheelTimer) {
+            hashedWheelTimer.newTimeout(new TimerTask() {
+                @Override
+                public void run(final Timeout timeout) throws Exception {
+                    pollStatistics(deviceContext, statisticsContext);
+                }
+            }, currentTimerDelay, TimeUnit.MILLISECONDS);
         }
     }
 
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java
new file mode 100644 (file)
index 0000000..baaedcb
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+
+final class AggregateFlowsInTableService extends AbstractSimpleService<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> {
+    public AggregateFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
+        // Create multipart request body for fetch all the group stats
+        final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
+        final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
+        mprAggregateRequestBuilder.setTableId(input.getTableId().getValue());
+        mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+        mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+        mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+        mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+        final short version = getVersion();
+        FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
+
+        // Set request body to main multipart request
+        multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
+                .build());
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
+
+        mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
+
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInAllTablesService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInAllTablesService.java
new file mode 100644 (file)
index 0000000..d8b1f15
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+
+final class AllFlowsInAllTablesService extends AbstractSimpleService<GetAllFlowsStatisticsFromAllFlowTablesInput, GetAllFlowsStatisticsFromAllFlowTablesOutput> {
+    private final MultipartRequestFlowCase flowCase;
+
+    AllFlowsInAllTablesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAllFlowsStatisticsFromAllFlowTablesOutput.class);
+
+        final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+        final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+        mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
+        mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+        mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+        mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+        mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+        FlowCreatorUtil.setWildcardedFlowMatch(getVersion(), mprFlowRequestBuilder);
+        multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+
+        flowCase = multipartRequestFlowCaseBuilder.build();
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
+        mprInput.setMultipartRequestBody(flowCase);
+
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInTableService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInTableService.java
new file mode 100644 (file)
index 0000000..9ce0f89
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+
+public class AllFlowsInTableService extends AbstractSimpleService<GetAllFlowStatisticsFromFlowTableInput, GetAllFlowStatisticsFromFlowTableOutput> {
+
+    public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAllFlowStatisticsFromFlowTableOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAllFlowStatisticsFromFlowTableInput input) {
+        final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+        mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
+        mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+        mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+        mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+        mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+
+        final short version = getVersion();
+        FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
+
+        final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+        multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPFLOW, xid.getValue(), version);
+
+        mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllGroupsStatsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllGroupsStatsService.java
new file mode 100644 (file)
index 0000000..756dc24
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
+
+final class AllGroupsStatsService extends AbstractSimpleService<GetAllGroupStatisticsInput, GetAllGroupStatisticsOutput> {
+    private static final MultipartRequestGroupCase GROUP_CASE;
+
+    static {
+        final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
+        final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
+        mprGroupBuild.setGroupId(new GroupId(BinContent.intToUnsignedLong(Group.OFPGALL.getIntValue())));
+        caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
+
+        GROUP_CASE = caseBuilder.build();
+    }
+
+    AllGroupsStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAllGroupStatisticsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAllGroupStatisticsInput input) {
+        // Create multipart request header
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
+
+        // Set request body to main multipart request
+        mprInput.setMultipartRequestBody(GROUP_CASE);
+
+        // Send the request, no cookies associated, use any connection
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java
new file mode 100644 (file)
index 0000000..4842c27
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
+
+final class AllMeterConfigStatsService extends AbstractSimpleService<GetAllMeterConfigStatisticsInput, GetAllMeterConfigStatisticsOutput> {
+    private static final MultipartRequestMeterConfigCase METER_CONFIG_CASE;
+
+    static {
+        MultipartRequestMeterConfigCaseBuilder caseBuilder =
+                new MultipartRequestMeterConfigCaseBuilder();
+        MultipartRequestMeterConfigBuilder mprMeterConfigBuild =
+                new MultipartRequestMeterConfigBuilder();
+        mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(Meter.OFPMALL.getIntValue())));
+        caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
+
+        METER_CONFIG_CASE = caseBuilder.build();
+    }
+
+    AllMeterConfigStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAllMeterConfigStatisticsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAllMeterConfigStatisticsInput input) {
+        MultipartRequestInputBuilder mprInput = RequestInputUtils
+                .createMultipartHeader(MultipartType.OFPMPMETERCONFIG, xid.getValue(), getVersion());
+        return mprInput.setMultipartRequestBody(METER_CONFIG_CASE).build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterStatsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterStatsService.java
new file mode 100644 (file)
index 0000000..bd7fcde
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
+
+final class AllMeterStatsService extends AbstractSimpleService<GetAllMeterStatisticsInput, GetAllMeterStatisticsOutput> {
+    private static final MultipartRequestMeterCase METER_CASE;
+
+    static {
+        MultipartRequestMeterCaseBuilder caseBuilder =
+                new MultipartRequestMeterCaseBuilder();
+        MultipartRequestMeterBuilder mprMeterBuild =
+                new MultipartRequestMeterBuilder();
+        mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(Meter.OFPMALL.getIntValue())));
+        caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
+
+        METER_CASE = caseBuilder.build();
+    }
+
+    AllMeterStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAllMeterStatisticsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAllMeterStatisticsInput input) {
+        MultipartRequestInputBuilder mprInput = RequestInputUtils
+                .createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
+        return mprInput.setMultipartRequestBody(METER_CASE).build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllPortStatsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllPortStatsService.java
new file mode 100644 (file)
index 0000000..a45dfde
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
+
+final class AllPortStatsService extends AbstractSimpleService<GetAllNodeConnectorsStatisticsInput, GetAllNodeConnectorsStatisticsOutput> {
+    private static final MultipartRequestPortStatsCase PORT_STATS_CASE;
+
+    static {
+        MultipartRequestPortStatsCaseBuilder caseBuilder =
+                new MultipartRequestPortStatsCaseBuilder();
+        MultipartRequestPortStatsBuilder mprPortStatsBuilder =
+                new MultipartRequestPortStatsBuilder();
+        // Select all ports
+        mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
+        caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
+
+        PORT_STATS_CASE = caseBuilder.build();
+    }
+
+    AllPortStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAllNodeConnectorsStatisticsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAllNodeConnectorsStatisticsInput input) {
+        MultipartRequestInputBuilder mprInput = RequestInputUtils
+                .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), getVersion());
+        mprInput.setMultipartRequestBody(PORT_STATS_CASE);
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesAllPortsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesAllPortsService.java
new file mode 100644 (file)
index 0000000..89e707d
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
+
+final class AllQueuesAllPortsService extends AbstractSimpleService<GetAllQueuesStatisticsFromAllPortsInput, GetAllQueuesStatisticsFromAllPortsOutput> {
+    private static final MultipartRequestQueueCase QUEUE_CASE;
+
+    static {
+        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+        MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
+        // Select all ports
+        // Select all the ports
+        mprQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
+        mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
+        caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
+
+        QUEUE_CASE = caseBuilder.build();
+    }
+
+    AllQueuesAllPortsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAllQueuesStatisticsFromAllPortsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAllQueuesStatisticsFromAllPortsInput input) {
+        // Set request body to main multipart request
+        MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPQUEUE, xid.getValue(), getVersion());
+        mprInput.setMultipartRequestBody(QUEUE_CASE);
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesOnePortService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesOnePortService.java
new file mode 100644 (file)
index 0000000..86fa2dd
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
+
+final class AllQueuesOnePortService extends AbstractSimpleService<GetAllQueuesStatisticsFromGivenPortInput, GetAllQueuesStatisticsFromGivenPortOutput> {
+    AllQueuesOnePortService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetAllQueuesStatisticsFromGivenPortOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAllQueuesStatisticsFromGivenPortInput input) {
+        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+        MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
+        // Select all queues
+        // Select specific port
+        final short version = getVersion();
+        mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+                OpenflowVersion.get(version), input.getNodeConnectorId()));
+
+        mprQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
+        caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
+
+        // Set request body to main multipart request
+        MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPQUEUE, xid.getValue(), version);
+        mprInput.setMultipartRequestBody(caseBuilder.build());
+
+        return mprInput.build();
+    }
+
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/FlowsInTableService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/FlowsInTableService.java
new file mode 100644 (file)
index 0000000..d0f0bb9
--- /dev/null
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+
+final class FlowsInTableService extends AbstractSimpleService<GetFlowStatisticsFromFlowTableInput, GetFlowStatisticsFromFlowTableOutput> {
+    FlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetFlowStatisticsFromFlowTableOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetFlowStatisticsFromFlowTableInput input) {
+        final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+        final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+        mprFlowRequestBuilder.setTableId(input.getTableId());
+
+        if (input.getOutPort() != null) {
+            mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
+        } else {
+            mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+        }
+
+        if (input.getOutGroup() != null) {
+            mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
+        } else {
+            mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+        }
+
+        if (input.getCookie() != null) {
+            mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
+        } else {
+            mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+        }
+
+        if (input.getCookieMask() != null) {
+            mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
+        } else {
+            mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+        }
+
+        // convert and inject match
+        final short version = getVersion();
+        final DeviceContext deviceContext = getDeviceContext();
+        MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
+                deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
+
+        // Set request body to main multipart request
+        multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPFLOW, xid.getValue(), version);
+        mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java
new file mode 100644 (file)
index 0000000..0f7cd3d
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
+
+final class GroupDescriptionService extends AbstractSimpleService<GetGroupDescriptionInput, GetGroupDescriptionOutput> {
+    private static final MultipartRequestGroupDescCase GROUP_DESC_CASE = new MultipartRequestGroupDescCaseBuilder().build();
+
+    GroupDescriptionService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetGroupDescriptionOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetGroupDescriptionInput input) {
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPGROUPDESC, xid.getValue(), getVersion());
+        mprInput.setMultipartRequestBody(GROUP_DESC_CASE);
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java
new file mode 100644 (file)
index 0000000..fce8e93
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
+
+final class GroupFeaturesService extends AbstractSimpleService<GetGroupFeaturesInput, GetGroupFeaturesOutput> {
+    private static final MultipartRequestGroupFeaturesCase GROUP_FEAT_CASE =
+            new MultipartRequestGroupFeaturesCaseBuilder().build();
+
+    GroupFeaturesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetGroupFeaturesOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetGroupFeaturesInput input) {
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPGROUPFEATURES, xid.getValue(), getVersion());
+        mprInput.setMultipartRequestBody(GROUP_FEAT_CASE);
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupStatsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupStatsService.java
new file mode 100644 (file)
index 0000000..e8defee
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
+
+final class GroupStatsService extends AbstractSimpleService<GetGroupStatisticsInput, GetGroupStatisticsOutput> {
+    GroupStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetGroupStatisticsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetGroupStatisticsInput input) {
+        final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
+        final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
+        mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
+        caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
+
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
+
+        mprInput.setMultipartRequestBody(caseBuilder.build());
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MatchingFlowsInTableService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MatchingFlowsInTableService.java
new file mode 100644 (file)
index 0000000..9905d20
--- /dev/null
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import com.google.common.base.MoreObjects;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractMultipartService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+
+final class MatchingFlowsInTableService extends AbstractMultipartService<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput> {
+
+    public MatchingFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
+        final DeviceContext deviceContext = getDeviceContext();
+        final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
+        final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
+        final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL).shortValue();
+        mprAggregateRequestBuilder.setTableId(tableId);
+        long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue();
+        mprAggregateRequestBuilder.setOutPort(outputPortValue);
+        // TODO: repeating code
+
+        final short version = getVersion();
+        if (version == OFConstants.OFP_VERSION_1_3) {
+
+            if (input.getCookie() == null) {
+                mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+            } else {
+                mprAggregateRequestBuilder.setCookie(MoreObjects.firstNonNull(input.getCookie().getValue(), OFConstants.DEFAULT_COOKIE));
+            }
+
+            if (input.getCookieMask() == null) {
+                mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+            } else {
+                mprAggregateRequestBuilder.setCookieMask(MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
+            }
+            long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY).longValue();
+            mprAggregateRequestBuilder.setOutGroup(outGroup);
+        } else {
+            mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+            mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+            mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+        }
+
+        MatchReactor.getInstance().convert(input.getMatch(), version, mprAggregateRequestBuilder,
+                deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
+
+        FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
+
+        // Set request body to main multipart request
+        multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
+                .build());
+
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
+
+        mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
+
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java
new file mode 100644 (file)
index 0000000..44b988c
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
+
+final class MeterFeaturesService extends AbstractSimpleService<GetMeterFeaturesInput, GetMeterFeaturesOutput> {
+    private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE = new MultipartRequestMeterFeaturesCaseBuilder().build();
+
+    protected MeterFeaturesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetMeterFeaturesOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetMeterFeaturesInput input) {
+        MultipartRequestInputBuilder mprInput =
+                RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETERFEATURES, xid.getValue(), getVersion());
+        mprInput.setMultipartRequestBody(METER_FEATURES_CASE);
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterStatsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterStatsService.java
new file mode 100644 (file)
index 0000000..976b06f
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
+
+final class MeterStatsService extends AbstractSimpleService<GetMeterStatisticsInput, GetMeterStatisticsOutput> {
+
+    MeterStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetMeterStatisticsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetMeterStatisticsInput input) {
+        MultipartRequestMeterCaseBuilder caseBuilder =
+                new MultipartRequestMeterCaseBuilder();
+        MultipartRequestMeterBuilder mprMeterBuild =
+                new MultipartRequestMeterBuilder();
+        mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
+        caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
+
+        MultipartRequestInputBuilder mprInput =
+                RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
+        mprInput.setMultipartRequestBody(caseBuilder.build());
+        return mprInput.build();
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OneQueueOnePortService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OneQueueOnePortService.java
new file mode 100644 (file)
index 0000000..a8c80ea
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
+
+final class OneQueueOnePortService extends AbstractSimpleService<GetQueueStatisticsFromGivenPortInput, GetQueueStatisticsFromGivenPortOutput> {
+    OneQueueOnePortService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetQueueStatisticsFromGivenPortOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetQueueStatisticsFromGivenPortInput input) {
+        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+        MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
+        // Select specific queue
+        mprQueueBuilder.setQueueId(input.getQueueId().getValue());
+        // Select specific port
+        final short version = getVersion();
+        mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+                OpenflowVersion.get(version), input.getNodeConnectorId()));
+        caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
+
+        // Set request body to main multipart request
+        MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPQUEUE, xid.getValue(), version);
+        mprInput.setMultipartRequestBody(caseBuilder.build());
+        return mprInput.build();
+    }
+}
index 832ef48d889dcb762a97a7375e799853475e7db1..7879447c15176ee4db8e0164f0a4d56f7d9766ff 100644 (file)
@@ -8,26 +8,15 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import com.google.common.base.Function;
-import com.google.common.base.MoreObjects;
 import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
-import javax.annotation.Nullable;
-import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
-import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
@@ -41,14 +30,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.G
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
@@ -57,268 +40,86 @@ import org.slf4j.LoggerFactory;
 /**
  * @author joe
  */
-public class OpendaylightFlowStatisticsServiceImpl extends CommonService implements OpendaylightFlowStatisticsService {
-
+public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService {
     private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceImpl.class);
 
-    public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
-    }
-
-    @Override
-    public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
-            final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
-
-
-        return handleServiceCall(
-                new Function<RequestContext<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>, 
-                ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> apply(final RequestContext<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> requestContext) {
-
-                        // Create multipart request body for fetch all the group stats
-                        final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
-                        final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
-                        mprAggregateRequestBuilder.setTableId(input.getTableId().getValue());
-                        mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
-                        mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
-                        mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                        mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-                        final short version = getVersion();
-                        FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
+    private final Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> matchingConvertor =
+            new Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>() {
+                @Override
+                public RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> apply(final RpcResult<List<MultipartReply>> input) {
+                    final DeviceContext deviceContext = matchingFlowsInTable.getDeviceContext();
+                    TranslatorLibrary translatorLibrary = deviceContext.oook();
+                    RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
+                    if (input.isSuccessful()) {
+                        MultipartReply reply = input.getResult().get(0);
+                        final TranslatorKey translatorKey = new TranslatorKey(reply.getVersion(), MultipartReplyAggregateCase.class.getName());
+                        final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
+                        List<AggregatedFlowStatistics> aggregStats = new ArrayList<AggregatedFlowStatistics>();
+
+                        for (MultipartReply multipartReply : input.getResult()) {
+                            aggregStats.add(messageTranslator.translate(multipartReply, deviceContext, null));
+                        }
 
-                        // Set request body to main multipart request
-                        multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
-                                .build());
-                        final Xid xid = requestContext.getXid();
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
+                        GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder =
+                                new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
+                        getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder.setAggregatedFlowStatistics(aggregStats);
 
-                        mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
+                        rpcResult = RpcResultBuilder
+                                .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>success()
+                                .withResult(getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder.build())
+                                .build();
 
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
+                    } else {
+                        rpcResult = RpcResultBuilder
+                                .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>failed()
+                                .withRpcErrors(input.getErrors())
+                                .build();
                     }
-                });
+                    return rpcResult;
+                }
+    };
+
+    private final AggregateFlowsInTableService aggregateFlowsInTable;
+    private final MatchingFlowsInTableService matchingFlowsInTable;
+    private final AllFlowsInAllTablesService allFlowsInAllTables;
+    private final AllFlowsInTableService allFlowsInTable;
+    private final FlowsInTableService flowsInTable;
+
+    public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        aggregateFlowsInTable = new AggregateFlowsInTableService(requestContextStack, deviceContext);
+        allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext);
+        allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext);
+        flowsInTable = new FlowsInTableService(requestContextStack, deviceContext);
+        matchingFlowsInTable = new MatchingFlowsInTableService(requestContextStack, deviceContext);
+    }
 
+    @Override
+    public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
+            final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
+        return aggregateFlowsInTable.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
             final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
-
-
-        ListenableFuture<RpcResult<List<MultipartReply>>> rpcResultListenableFuture = handleServiceCall(
-                new Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<List<MultipartReply>>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<List<MultipartReply>>> apply(final RequestContext<List<MultipartReply>> requestContext) {
-                        final Xid xid = requestContext.getXid();
-                        final DeviceContext deviceContext = getDeviceContext();
-                        deviceContext.getMultiMsgCollector().registerMultipartRequestContext(requestContext);
-                        final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
-                        final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
-                        final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL).shortValue();
-                        mprAggregateRequestBuilder.setTableId(tableId);
-                        long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue();
-                        mprAggregateRequestBuilder.setOutPort(outputPortValue);
-                        // TODO: repeating code
-
-                        final short version = getVersion();
-                        if (version == OFConstants.OFP_VERSION_1_3) {
-
-                            if (input.getCookie() == null) {
-                                mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                            } else {
-                                mprAggregateRequestBuilder.setCookie(MoreObjects.firstNonNull(input.getCookie().getValue(), OFConstants.DEFAULT_COOKIE));
-                            }
-
-                            if (input.getCookieMask() == null) {
-                                mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-                            } else {
-                                mprAggregateRequestBuilder.setCookieMask(MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
-                            }
-                            long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY).longValue();
-                            mprAggregateRequestBuilder.setOutGroup(outGroup);
-                        } else {
-                            mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
-                            mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                            mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-                        }
-
-                        MatchReactor.getInstance().convert(input.getMatch(), version, mprAggregateRequestBuilder,
-                                deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
-
-                        FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
-
-                        // Set request body to main multipart request
-                        multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
-                                .build());
-
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
-
-                        mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
-                    }
-                });
-
-        return Futures.transform(rpcResultListenableFuture, new Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>() {
-            @Nullable
-            @Override
-            public RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> apply(RpcResult<List<MultipartReply>> input) {
-                final DeviceContext deviceContext = getDeviceContext();
-                TranslatorLibrary translatorLibrary = deviceContext.oook();
-                RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
-                if (input.isSuccessful()) {
-                    MultipartReply reply = input.getResult().get(0);
-                    final TranslatorKey translatorKey = new TranslatorKey(reply.getVersion(), MultipartReplyAggregateCase.class.getName());
-                    final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
-                    List<AggregatedFlowStatistics> aggregStats = new ArrayList<AggregatedFlowStatistics>();
-
-                    for (MultipartReply multipartReply : input.getResult()) {
-                        aggregStats.add(messageTranslator.translate(multipartReply, deviceContext, null));
-                    }
-
-                    GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder =
-                            new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
-                    getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder.setAggregatedFlowStatistics(aggregStats);
-
-                    rpcResult = RpcResultBuilder
-                            .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>success()
-                            .withResult(getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder.build())
-                            .build();
-
-                } else {
-                    rpcResult = RpcResultBuilder
-                            .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>failed()
-                            .withRpcErrors(input.getErrors())
-                            .build();
-                }
-                return rpcResult;
-            }
-        });
-
+        return Futures.transform(matchingFlowsInTable.handleServiceCall(input), matchingConvertor);
     }
 
     @Override
     public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
             final GetAllFlowStatisticsFromFlowTableInput input) {
-
-        return handleServiceCall(new Function<RequestContext<GetAllFlowStatisticsFromFlowTableOutput>,
-                ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>>>() {
-
-            @Override
-            public ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> apply(final RequestContext<GetAllFlowStatisticsFromFlowTableOutput> requestContext) {
-
-                final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
-                mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
-                mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
-                mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
-                mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-
-                final short version = getVersion();
-                FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
-
-                final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
-                multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
-
-                final Xid xid = requestContext.getXid();
-                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                        MultipartType.OFPMPFLOW, xid.getValue(), version);
-
-                mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
-                return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
-            }
-        });
+        return allFlowsInTable.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
             final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
-
-
-        return handleServiceCall(new Function<RequestContext<GetAllFlowsStatisticsFromAllFlowTablesOutput>,
-                ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>>() {
-
-            @Override
-            public ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> apply(final RequestContext<GetAllFlowsStatisticsFromAllFlowTablesOutput> requestContext) {
-
-                final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
-                final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
-                mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
-                mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
-                mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
-                mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-                final short version = getVersion();
-                FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
-
-                final Xid xid = requestContext.getXid();
-                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                        MultipartType.OFPMPFLOW, xid.getValue(), version);
-
-                multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
-                mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
-                return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
-            }
-        });
+        return allFlowsInAllTables.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
             final GetFlowStatisticsFromFlowTableInput input) {
-
-
-        return handleServiceCall(new Function<RequestContext<GetFlowStatisticsFromFlowTableOutput>, ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>>>() {
-
-            @Override
-            public ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> apply(final RequestContext<GetFlowStatisticsFromFlowTableOutput> requestContext) {
-
-                final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
-                final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
-                mprFlowRequestBuilder.setTableId(input.getTableId());
-
-                if (input.getOutPort() != null) {
-                    mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
-                } else {
-                    mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
-                }
-
-                if (input.getOutGroup() != null) {
-                    mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
-                } else {
-                    mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
-                }
-
-                if (input.getCookie() != null) {
-                    mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
-                } else {
-                    mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                }
-
-                if (input.getCookieMask() != null) {
-                    mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
-                } else {
-                    mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-                }
-
-                // convert and inject match
-                final short version = getVersion();
-                final DeviceContext deviceContext = getDeviceContext();
-                MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
-                        deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
-
-                // Set request body to main multipart request
-                final Xid xid = requestContext.getXid();
-                multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
-                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                        MultipartType.OFPMPFLOW, xid.getValue(), version);
-                mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
-                return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
-            }
-        });
+        return flowsInTable.handleServiceCall(input);
     }
-
 }
index ad16b6ac900d59ad673bb6dd01cea20c2f472bb2..d39d48e2730a0a367a5bbb62855adc4ff136a337 100644 (file)
@@ -7,61 +7,49 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-/**
- * @author joe
- */
-public class OpendaylightFlowTableStatisticsServiceImpl extends CommonService implements
+public final class OpendaylightFlowTableStatisticsServiceImpl extends AbstractSimpleService<GetFlowTablesStatisticsInput, GetFlowTablesStatisticsOutput> implements
         OpendaylightFlowTableStatisticsService {
 
-    public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+    public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetFlowTablesStatisticsOutput.class);
     }
 
     @Override
     public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
             final GetFlowTablesStatisticsInput input) {
+        return handleServiceCall(input);
+    }
 
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetFlowTablesStatisticsInput input) {
+        // Create multipart request body for fetch all the group stats
+        final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
+        final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
+        multipartRequestTableBuilder.setEmpty(true);
+        multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
 
-        return handleServiceCall(new Function<RequestContext<GetFlowTablesStatisticsOutput>,
-                ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>>>() {
-
-            @Override
-            public ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> apply(final RequestContext<GetFlowTablesStatisticsOutput> requestContext) {
-
-                // Create multipart request body for fetch all the group stats
-                final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
-                final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
-                multipartRequestTableBuilder.setEmpty(true);
-                multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
+        // Set request body to main multipart request
+        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
 
-                // Set request body to main multipart request
-                final Xid xid = requestContext.getXid();
-                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                        MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
+        mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
 
-                mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
-                return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
-            }
-        });
+        return mprInput.build();
     }
-
 }
index 7f627e47bd964a3d358b1966009e144394bcd6ad..674063b5e01427193fb4d7bf76dc37c3e5c787c9 100644 (file)
@@ -7,17 +7,9 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.util.BinContent;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
@@ -27,127 +19,41 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 /**
  * @author joe
  */
-public class OpendaylightGroupStatisticsServiceImpl extends CommonService implements OpendaylightGroupStatisticsService {
-
-
-    public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+public class OpendaylightGroupStatisticsServiceImpl implements OpendaylightGroupStatisticsService {
+    private final AllGroupsStatsService allGroups;
+    private final GroupDescriptionService groupDesc;
+    private final GroupFeaturesService groupFeat;
+    private final GroupStatsService groupStats;
+
+    public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        allGroups = new AllGroupsStatsService(requestContextStack, deviceContext);
+        groupDesc = new GroupDescriptionService(requestContextStack, deviceContext);
+        groupFeat = new GroupFeaturesService(requestContextStack, deviceContext);
+        groupStats = new GroupStatsService(requestContextStack, deviceContext);
     }
 
     @Override
     public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
-
-
-        return handleServiceCall(new Function<RequestContext<GetAllGroupStatisticsOutput>,
-                ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>>>() {
-
-            @Override
-            public ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> apply(final RequestContext<GetAllGroupStatisticsOutput> requestContext) {
-
-                final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
-                final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
-                mprGroupBuild.setGroupId(new GroupId(
-                        BinContent
-                                .intToUnsignedLong(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group.OFPGALL
-                                        .getIntValue())));
-                caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
-
-                // Create multipart request header
-                final Xid xid = requestContext.getXid();
-                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                        MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
-
-                // Set request body to main multipart request
-                mprInput.setMultipartRequestBody(caseBuilder.build());
-
-                // Send the request, no cookies associated, use any connection
-
-                MultipartRequestInput multipartRequestInput = mprInput.build();
-
-                return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-            }
-        });
-
+        return allGroups.handleServiceCall(input);
     }
 
-
     @Override
     public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
-        return handleServiceCall(
-                new Function<RequestContext<GetGroupDescriptionOutput>,
-                ListenableFuture<RpcResult<GetGroupDescriptionOutput>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<GetGroupDescriptionOutput>> apply(final RequestContext<GetGroupDescriptionOutput> requestContext) {
-                        final MultipartRequestGroupDescCaseBuilder mprGroupDescCaseBuild = new MultipartRequestGroupDescCaseBuilder();
-
-                        final Xid xid = requestContext.getXid();
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPGROUPDESC, xid.getValue(), getVersion());
-                        mprInput.setMultipartRequestBody(mprGroupDescCaseBuild.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
-
+        return groupDesc.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
-        return handleServiceCall(
-                new Function<RequestContext<GetGroupFeaturesOutput>,
-                ListenableFuture<RpcResult<GetGroupFeaturesOutput>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<GetGroupFeaturesOutput>> apply(final RequestContext<GetGroupFeaturesOutput> requestContext) {
-                        final MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild = new MultipartRequestGroupFeaturesCaseBuilder();
-
-                        final Xid xid = requestContext.getXid();
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPGROUPFEATURES, xid.getValue(), getVersion());
-                        mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
-
+        return groupFeat.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
-        return handleServiceCall(
-                new Function<RequestContext<GetGroupStatisticsOutput>, ListenableFuture<RpcResult<GetGroupStatisticsOutput>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<GetGroupStatisticsOutput>> apply(final RequestContext<GetGroupStatisticsOutput> requestContext) {
-
-                        final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
-                        final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
-                        mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
-                        caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
-
-                        final Xid xid = requestContext.getXid();
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
-
-                        mprInput.setMultipartRequestBody(caseBuilder.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
+        return groupStats.handleServiceCall(input);
     }
-
 }
index 4c1c4d0ced1890b2786652446cbc936e1d9693fc..ecee95ef785df4229edf5bcafe0ee42c70996a36 100644 (file)
@@ -7,17 +7,9 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.util.BinContent;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
@@ -27,127 +19,39 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-/**
- * @author joe
- */
-public class OpendaylightMeterStatisticsServiceImpl extends CommonService implements OpendaylightMeterStatisticsService {
-
-
-    public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+public class OpendaylightMeterStatisticsServiceImpl implements OpendaylightMeterStatisticsService {
+    private final AllMeterConfigStatsService allMeterConfig;
+    private final AllMeterStatsService allMeterStats;
+    private final MeterFeaturesService meterFeatures;
+    private final MeterStatsService meterStats;
+
+    public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        allMeterConfig = new AllMeterConfigStatsService(requestContextStack, deviceContext);
+        allMeterStats = new AllMeterStatsService(requestContextStack, deviceContext);
+        meterFeatures = new MeterFeaturesService(requestContextStack, deviceContext);
+        meterStats = new MeterStatsService(requestContextStack, deviceContext);
     }
 
     @Override
     public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
             final GetAllMeterConfigStatisticsInput input) {
-        return handleServiceCall(new Function<RequestContext<GetAllMeterConfigStatisticsOutput>,
-                ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> apply(final RequestContext<GetAllMeterConfigStatisticsOutput> requestContext) {
-
-                        MultipartRequestMeterConfigCaseBuilder caseBuilder =
-                                new MultipartRequestMeterConfigCaseBuilder();
-                        MultipartRequestMeterConfigBuilder mprMeterConfigBuild =
-                                new MultipartRequestMeterConfigBuilder();
-                        mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
-                                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
-                                        .types.rev130731.Meter.OFPMALL.getIntValue())));
-                        caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
-
-                        final Xid xid = requestContext.getXid();
-                        MultipartRequestInputBuilder mprInput = RequestInputUtils
-                                .createMultipartHeader(MultipartType.OFPMPMETERCONFIG, xid.getValue(), getVersion());
-                        mprInput.setMultipartRequestBody(caseBuilder.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
-
+        return allMeterConfig.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(final GetAllMeterStatisticsInput input) {
-
-        return handleServiceCall(
-                new Function<RequestContext<GetAllMeterStatisticsOutput>, ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>>>() {
-                    @Override
-                    public ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> apply(final RequestContext<GetAllMeterStatisticsOutput> requestContext) {
-
-                        MultipartRequestMeterCaseBuilder caseBuilder =
-                                new MultipartRequestMeterCaseBuilder();
-                        MultipartRequestMeterBuilder mprMeterBuild =
-                                new MultipartRequestMeterBuilder();
-                        mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
-                                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
-                                        .types.rev130731.Meter.OFPMALL.getIntValue())));
-                        caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
-
-                        final Xid xid = requestContext.getXid();
-                        MultipartRequestInputBuilder mprInput = RequestInputUtils
-                                .createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
-                        mprInput.setMultipartRequestBody(caseBuilder.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                }
-        );
-
+        return allMeterStats.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(final GetMeterFeaturesInput input) {
-        return handleServiceCall(
-                new Function<RequestContext<GetMeterFeaturesOutput>, ListenableFuture<RpcResult<GetMeterFeaturesOutput>>>() {
-                    @Override
-                    public ListenableFuture<RpcResult<GetMeterFeaturesOutput>> apply(final RequestContext<GetMeterFeaturesOutput> requestContext) {
-
-                        MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild =
-                                new MultipartRequestMeterFeaturesCaseBuilder();
-
-                        final Xid xid = requestContext.getXid();
-                        MultipartRequestInputBuilder mprInput =
-                                RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETERFEATURES, xid.getValue(), getVersion());
-                        mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
+        return meterFeatures.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(final GetMeterStatisticsInput input) {
-        return handleServiceCall(
-                new Function<RequestContext<GetMeterStatisticsOutput>, ListenableFuture<RpcResult<GetMeterStatisticsOutput>>>() {
-                    @Override
-                    public ListenableFuture<RpcResult<GetMeterStatisticsOutput>> apply(final RequestContext<GetMeterStatisticsOutput> requestContext) {
-                        MultipartRequestMeterCaseBuilder caseBuilder =
-                                new MultipartRequestMeterCaseBuilder();
-                        MultipartRequestMeterBuilder mprMeterBuild =
-                                new MultipartRequestMeterBuilder();
-                        mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
-                        caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
-
-                        final Xid xid = requestContext.getXid();
-                        MultipartRequestInputBuilder mprInput =
-                                RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
-                        mprInput.setMultipartRequestBody(caseBuilder.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
-
+        return meterStats.handleServiceCall(input);
     }
-
 }
index fed18d7f6dd8e6e3d4eff7bee84773e88f030445..4258c01331901e7d3b16bde9a331580a7ac6ba69 100644 (file)
@@ -7,24 +7,9 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
@@ -32,74 +17,24 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.G
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-/**
- * @author joe
- */
-public class OpendaylightPortStatisticsServiceImpl extends CommonService implements OpendaylightPortStatisticsService {
+public class OpendaylightPortStatisticsServiceImpl implements OpendaylightPortStatisticsService {
+    private final AllPortStatsService allPortStats;
+    private final PortStatsService portStats;
 
-    public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+    public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        allPortStats = new AllPortStatsService(requestContextStack, deviceContext);
+        portStats = new PortStatsService(requestContextStack, deviceContext);
     }
 
     @Override
     public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
             final GetAllNodeConnectorsStatisticsInput input) {
-        return handleServiceCall(
-                        new Function<RequestContext<GetAllNodeConnectorsStatisticsOutput>,
-                        ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>>>() {
-
-                            @Override
-                            public ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> apply(final RequestContext<GetAllNodeConnectorsStatisticsOutput> requestContext) {
-
-                                MultipartRequestPortStatsCaseBuilder caseBuilder =
-                                        new MultipartRequestPortStatsCaseBuilder();
-                                MultipartRequestPortStatsBuilder mprPortStatsBuilder =
-                                        new MultipartRequestPortStatsBuilder();
-                                // Select all ports
-                                mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
-                                caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
-
-                                final Xid xid = requestContext.getXid();
-                                MultipartRequestInputBuilder mprInput = RequestInputUtils
-                                        .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), getVersion());
-                                mprInput.setMultipartRequestBody(caseBuilder.build());
-                                MultipartRequestInput multipartRequestInput = mprInput.build();
-                                return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                            }
-                        });
+        return allPortStats.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
             final GetNodeConnectorStatisticsInput input) {
-        return handleServiceCall(
-                        new Function<RequestContext<GetNodeConnectorStatisticsOutput>,
-                        ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>>>() {
-
-                            @Override
-                            public ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> apply(final RequestContext<GetNodeConnectorStatisticsOutput> requestContext) {
-
-                                MultipartRequestPortStatsCaseBuilder caseBuilder =
-                                        new MultipartRequestPortStatsCaseBuilder();
-                                MultipartRequestPortStatsBuilder mprPortStatsBuilder =
-                                        new MultipartRequestPortStatsBuilder();
-                                // Set specific port
-                                final short version = getVersion();
-                                mprPortStatsBuilder
-                                        .setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
-                                                OpenflowVersion.get(version),
-                                                input.getNodeConnectorId()));
-                                caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
-
-                                final Xid xid = requestContext.getXid();
-                                MultipartRequestInputBuilder mprInput = RequestInputUtils
-                                        .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), version);
-                                mprInput.setMultipartRequestBody(caseBuilder.build());
-                                MultipartRequestInput multipartRequestInput = mprInput.build();
-                                return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                            }
-                        });
-
+        return portStats.handleServiceCall(input);
     }
-
 }
index 702c2dd2906b23597476955b2b932a6e07f25f7f..adc97cf1332273b3096fa58caa0f81673f852525 100644 (file)
@@ -7,24 +7,9 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
@@ -34,107 +19,32 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-/**
- * @author joe
- */
-public class OpendaylightQueueStatisticsServiceImpl extends CommonService implements OpendaylightQueueStatisticsService {
+public class OpendaylightQueueStatisticsServiceImpl implements OpendaylightQueueStatisticsService {
+    private final AllQueuesAllPortsService allQueuesAllPorts;
+    private final AllQueuesOnePortService allQueuesOnePort;
+    private final OneQueueOnePortService oneQueueOnePort;
 
-    public OpendaylightQueueStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext);
+    public OpendaylightQueueStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        allQueuesAllPorts = new AllQueuesAllPortsService(requestContextStack, deviceContext);
+        allQueuesOnePort = new AllQueuesOnePortService(requestContextStack, deviceContext);
+        oneQueueOnePort = new OneQueueOnePortService(requestContextStack, deviceContext);
     }
 
     @Override
     public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
             final GetAllQueuesStatisticsFromAllPortsInput input) {
-        return handleServiceCall(
-                new Function<RequestContext<GetAllQueuesStatisticsFromAllPortsOutput>,
-                ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> apply(final RequestContext<GetAllQueuesStatisticsFromAllPortsOutput> requestContext) {
-
-
-                        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
-                        MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
-                        // Select all ports
-                        // Select all the ports
-                        mprQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
-                        mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
-                        caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
-
-                        // Set request body to main multipart request
-                        final Xid xid = requestContext.getXid();
-
-                        MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPQUEUE, xid.getValue(), getVersion());
-                        mprInput.setMultipartRequestBody(caseBuilder.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
-
+        return allQueuesAllPorts.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
             final GetAllQueuesStatisticsFromGivenPortInput input) {
-        return handleServiceCall(
-                new Function<RequestContext<GetAllQueuesStatisticsFromGivenPortOutput>, ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> apply(final RequestContext<GetAllQueuesStatisticsFromGivenPortOutput> requestContext) {
-
-                        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
-                        MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
-                        // Select all queues
-                        // Select specific port
-                        final short version = getVersion();
-                        mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
-                                OpenflowVersion.get(version), input.getNodeConnectorId()));
-
-                        mprQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
-                        caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
-
-                        // Set request body to main multipart request
-                        final Xid xid = requestContext.getXid();
-                        MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPQUEUE, xid.getValue(), version);
-                        mprInput.setMultipartRequestBody(caseBuilder.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
+        return allQueuesOnePort.handleServiceCall(input);
     }
 
     @Override
     public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
             final GetQueueStatisticsFromGivenPortInput input) {
-        return handleServiceCall(
-                new Function<RequestContext<GetQueueStatisticsFromGivenPortOutput>, ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> apply(final RequestContext<GetQueueStatisticsFromGivenPortOutput> requestContext) {
-
-                        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
-                        MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
-                        // Select specific queue
-                        mprQueueBuilder.setQueueId(input.getQueueId().getValue());
-                        // Select specific port
-                        final short version = getVersion();
-                        mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
-                                OpenflowVersion.get(version), input.getNodeConnectorId()));
-                        caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
-
-                        // Set request body to main multipart request
-                        final Xid xid = requestContext.getXid();
-                        MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPQUEUE, xid.getValue(), version);
-                        mprInput.setMultipartRequestBody(caseBuilder.build());
-                        MultipartRequestInput multipartRequestInput = mprInput.build();
-                        return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
-                    }
-                });
+        return oneQueueOnePort.handleServiceCall(input);
     }
-
 }
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsService.java
new file mode 100644 (file)
index 0000000..6803ba2
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
+
+final class PortStatsService extends AbstractSimpleService<GetNodeConnectorStatisticsInput, GetNodeConnectorStatisticsOutput> {
+
+    protected PortStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext, GetNodeConnectorStatisticsOutput.class);
+    }
+
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final GetNodeConnectorStatisticsInput input) {
+        MultipartRequestPortStatsCaseBuilder caseBuilder =
+                new MultipartRequestPortStatsCaseBuilder();
+        MultipartRequestPortStatsBuilder mprPortStatsBuilder =
+                new MultipartRequestPortStatsBuilder();
+        // Set specific port
+        final short version = getVersion();
+        mprPortStatsBuilder
+                .setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+                        OpenflowVersion.get(version),
+                        input.getNodeConnectorId()));
+        caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
+
+        MultipartRequestInputBuilder mprInput = RequestInputUtils
+                .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), version);
+        mprInput.setMultipartRequestBody(caseBuilder.build());
+
+        return mprInput.build();
+    }
+}
index 15f5650d5fffd7d1810771a4bf9ec2a4b54f24dd..deea2e4a749cfcde3b8910684761ba520ebbc31d 100644 (file)
@@ -8,88 +8,32 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.dedicated;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
 import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestContextUtil;
+import org.opendaylight.openflowplugin.impl.services.AbstractMultipartService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 4.4.2015.
  */
-public class StatisticsGatheringService extends CommonService {
-
-    private static final Logger LOG = LoggerFactory.getLogger(StatisticsGatheringService.class);
-
+public class StatisticsGatheringService extends AbstractMultipartService<MultipartType> {
     public StatisticsGatheringService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-
         super(requestContextStack, deviceContext);
     }
 
-
     public Future<RpcResult<List<MultipartReply>>> getStatisticsOfType(final MultipartType type) {
-        return handleServiceCall(new Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<List<MultipartReply>>>>() {
-                                     @Override
-                                     public ListenableFuture<RpcResult<List<MultipartReply>>> apply(final RequestContext<List<MultipartReply>> requestContext) {
-                                         final Xid xid = requestContext.getXid();
-                                         final DeviceContext deviceContext = getDeviceContext();
-                                         final MultiMsgCollector multiMsgCollector = deviceContext.getMultiMsgCollector();
-
-                                         multiMsgCollector.registerMultipartRequestContext(requestContext);
-                                         MultipartRequestInput multipartRequestInput = MultipartRequestInputFactory.
-                                                 makeMultipartRequestInput(xid.getValue(),
-                                                         getVersion(),
-                                                         type);
-                                         final OutboundQueue outboundQueue = deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider();
-                                         outboundQueue.commitEntry(xid.getValue(), multipartRequestInput, new FutureCallback<OfHeader>() {
-                                             @Override
-                                             public void onSuccess(final OfHeader ofHeader) {
-                                                 if (ofHeader instanceof MultipartReply) {
-                                                     final MultipartReply multipartReply = (MultipartReply) ofHeader;
-                                                     multiMsgCollector.addMultipartMsg(multipartReply);
-                                                 } else {
-                                                     if (null != ofHeader) {
-                                                         LOG.info("Unexpected response type received {}.", ofHeader.getClass());
-                                                         RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, String.format("Unexpected response type received %s.", ofHeader.getClass()));
-                                                         requestContext.setResult(rpcResultBuilder.build());
-                                                     } else {
-                                                         LOG.info("Ofheader was null.");
-                                                         RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, "OfHeader was null");
-                                                         requestContext.setResult(rpcResultBuilder.build());
-                                                     }
-                                                 }
-                                             }
-
-                                             @Override
-                                             public void onFailure(final Throwable throwable) {
-                                                 RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage());
-                                                 requestContext.setResult(rpcResultBuilder.build());
-                                                 RequestContextUtil.closeRequstContext(requestContext);
-                                             }
-                                         });
-                                         return requestContext.getFuture();
-                                     }
-                                 }
-
-        );
+        return handleServiceCall(type);
     }
 
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final MultipartType input) {
+        return MultipartRequestInputFactory.makeMultipartRequestInput(xid.getValue(), getVersion(), input);
+    }
 }
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/HashUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/HashUtil.java
deleted file mode 100644 (file)
index 03ed666..0000000
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.impl.util;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.CharMatcher;
-import java.math.BigInteger;
-import java.util.StringTokenizer;
-import java.util.regex.Pattern;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpVersion;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.Pbb;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 8.4.2015.
- */
-public final class HashUtil {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HashUtil.class);
-    private static final CharMatcher SLASH_MATCHER = CharMatcher.is('/');
-    private static final Pattern DOUBLE_COLON = Pattern.compile("::");
-    private static final int BASE_16 = 16;
-    private static final int BASE_10 = 10;
-    private static final long IPV6_TOKENS_COUNT = 8;
-    public static final String IPV6_TOKEN = ":0000";
-
-    private HashUtil() {
-
-        throw new IllegalStateException("This class should not be instantiated.");
-    }
-
-    public static long calculateEthernetMatchHash(final EthernetMatch ethernetMatch) {
-        long hash = 0;
-
-        EthernetType ethernetType = ethernetMatch.getEthernetType();
-        if (null != ethernetType) {
-            hash += ethernetType.getType().getValue();
-        }
-
-        EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
-        if (null != ethernetDestination) {
-            hash += calculateEthernetDestinationHash(ethernetDestination);
-        }
-
-        EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
-        if (null != ethernetSource) {
-            hash += calculateEthenetSourceHash(ethernetSource);
-        }
-
-        return hash;
-    }
-
-    public static long calculateEthenetSourceHash(final EthernetSource ethernetSource) {
-        long hash = calculateMacAddressHash(ethernetSource.getAddress());
-        hash += calculateMacAddressHash(ethernetSource.getMask());
-        return hash;
-    }
-
-    public static long calculateEthernetDestinationHash(final EthernetDestination ethernetDestination) {
-        long hash = calculateMacAddressHash(ethernetDestination.getAddress());
-        hash += calculateMacAddressHash(ethernetDestination.getMask());
-        return hash;
-    }
-
-    public static long calculateMacAddressHash(final MacAddress macAddress) {
-
-        long hash = 0;
-        if (null != macAddress) {
-            StringTokenizer stringTokenizer = new StringTokenizer(macAddress.getValue(), ":");
-            hash = parseTokens(stringTokenizer, BASE_16, 8);
-        }
-        return hash;
-    }
-
-    public static long calculateMatchHash(final Match match, final short version) {
-        long hash = 0;
-        long subHash = 0;
-        long base = 0;
-        if (null != match) {
-            if (null != match.getEthernetMatch()) {
-                hash = 1 << base;
-                subHash += calculateEthernetMatchHash(match.getEthernetMatch());
-            }
-            base++;
-            if (null != match.getIcmpv4Match()) {
-                hash = 1 << base;
-                subHash += calculateIcmpV4MatchHash(match.getIcmpv4Match());
-            }
-            base++;
-            if (null != match.getIcmpv6Match()) {
-                hash = 1 << base;
-                subHash += calculateIcmpV6MatchHash(match.getIcmpv6Match());
-            }
-            base++;
-            if (null != match.getInPhyPort()) {
-                hash = 1 << base;
-                subHash += calculateNodeConnectorIdHash(match.getInPhyPort(), version);
-            }
-            base++;
-            if (null != match.getInPort()) {
-                hash = 1 << base;
-                subHash += calculateNodeConnectorIdHash(match.getInPort(), version);
-            }
-            base++;
-            if (null != match.getIpMatch()) {
-                hash = 1 << base;
-                subHash += calculateIpMatchHash(match.getIpMatch());
-            }
-            base++;
-            if (null != match.getLayer3Match()) {
-                hash = 1 << base;
-                subHash += calculateLayer3MatchHash(match.getLayer3Match());
-            }
-            base++;
-            if (null != match.getLayer4Match()) {
-                hash = 1 << base;
-                subHash += calculateLayer4MatchHash(match.getLayer4Match());
-            }
-            base++;
-            if (null != match.getIcmpv6Match()) {
-                hash = 1 << base;
-                subHash += calculateIcmpv6MatchHash(match.getIcmpv6Match());
-            }
-            base++;
-            if (null != match.getMetadata()) {
-                hash = 1 << base;
-                subHash += calculateMetadataHash(match.getMetadata());
-            }
-            base++;
-            if (null != match.getProtocolMatchFields()) {
-                hash = 1 << base;
-                subHash += calculateProtocolMatchFieldsHash(match.getProtocolMatchFields());
-            }
-            base++;
-            if (null != match.getTcpFlagMatch()) {
-                hash = 1 << base;
-                subHash += calculateTcpFlagMatch(match.getTcpFlagMatch());
-            }
-            base++;
-            if (null != match.getVlanMatch()) {
-                hash = 1 << base;
-                subHash += calculateVlanMatchHash(match.getVlanMatch());
-            }
-            base++;
-            if (null != match.getTunnel()) {
-                hash = 1 << base;
-                subHash += calculateTunnelHash(match.getTunnel());
-            }
-        }
-        return hash + subHash;
-    }
-
-    private static long calculateTunnelHash(final Tunnel tunnel) {
-        long hash = 0;
-        BigInteger tunnelId = tunnel.getTunnelId();
-        if (null != tunnelId) {
-            hash += tunnelId.intValue();
-        }
-
-        BigInteger tunnelMask = tunnel.getTunnelMask();
-        if (null != tunnelMask) {
-            hash += tunnelMask.intValue();
-        }
-        return hash;
-    }
-
-    private static long calculateVlanMatchHash(final VlanMatch vlanMatch) {
-        long hash = 0;
-
-        VlanId vlanId = vlanMatch.getVlanId();
-        if (null != vlanId) {
-            hash += vlanId.getVlanId().getValue().intValue();
-        }
-
-        VlanPcp vlanPcp = vlanMatch.getVlanPcp();
-        if (null != vlanPcp) {
-            hash += vlanPcp.getValue().shortValue();
-        }
-
-        return hash;
-    }
-
-    private static long calculateTcpFlagMatch(final TcpFlagMatch tcpFlagMatch) {
-        long hash = tcpFlagMatch.getTcpFlag().intValue();
-        return hash;
-    }
-
-    private static long calculateProtocolMatchFieldsHash(final ProtocolMatchFields protocolMatchFields) {
-        long hash = 0;
-        Short mplsBos = protocolMatchFields.getMplsBos();
-        if (null != mplsBos) {
-            hash += mplsBos.intValue();
-        }
-        Short mplsTc = protocolMatchFields.getMplsTc();
-        if (null != mplsTc) {
-            hash += mplsTc.intValue();
-        }
-        Pbb pbb = protocolMatchFields.getPbb();
-        if (null != pbb) {
-            if (null != pbb.getPbbIsid()) {
-                hash += pbb.getPbbIsid().intValue();
-            }
-            if (null != pbb.getPbbMask()) {
-                hash += pbb.getPbbMask().intValue();
-            }
-        }
-        Long mplsLabel = protocolMatchFields.getMplsLabel();
-        if (null != mplsLabel) {
-            hash += mplsLabel.intValue();
-        }
-        return hash;
-    }
-
-    private static long calculateMetadataHash(final Metadata metadata) {
-        long hash = metadata.getMetadata().intValue();
-        if (null != metadata.getMetadataMask()) {
-            hash += metadata.getMetadataMask().intValue();
-        }
-        return hash;
-    }
-
-    private static long calculateIcmpv6MatchHash(final Icmpv6Match icmpv6Match) {
-        long hash = icmpv6Match.getIcmpv6Code().intValue();
-        hash += icmpv6Match.getIcmpv6Type().intValue();
-        return hash;
-    }
-
-    private static long calculateLayer4MatchHash(final Layer4Match layer4Match) {
-        long hash = 0;
-        if (layer4Match instanceof SctpMatch) {
-            hash += calculateSctpMatchHash((SctpMatch) layer4Match);
-        }
-
-        if (layer4Match instanceof TcpMatch) {
-            hash += calculateTcpMatchHash((TcpMatch) layer4Match);
-        }
-        if (layer4Match instanceof UdpMatch) {
-            hash += calculateUdpMatchHash((UdpMatch) layer4Match);
-        }
-        return hash;
-    }
-
-    private static long calculateUdpMatchHash(final UdpMatch layer4Match) {
-        long hash = 0;
-        return hash;
-    }
-
-    private static long calculateTcpMatchHash(final TcpMatch layer4Match) {
-        long hash = 0;
-        PortNumber sourcePort = layer4Match.getTcpSourcePort();
-        if (null != sourcePort) {
-            hash += sourcePort.getValue().intValue();
-        }
-
-        PortNumber destinationPort = layer4Match.getTcpDestinationPort();
-        if (null != destinationPort) {
-            hash += destinationPort.getValue().intValue();
-        }
-        return hash;
-    }
-
-    private static long calculateSctpMatchHash(final SctpMatch layer4Match) {
-        long hash = 0;
-
-        PortNumber portNumber = layer4Match.getSctpDestinationPort();
-        if (null != portNumber) {
-            hash += portNumber.getValue().intValue();
-        }
-
-        PortNumber sourcePort = layer4Match.getSctpSourcePort();
-        if (null != sourcePort) {
-            hash += sourcePort.getValue().intValue();
-        }
-        return hash;
-    }
-
-    private static long calculateLayer3MatchHash(final Layer3Match layer3Match) {
-        long hash = 0;
-        if (layer3Match instanceof ArpMatch) {
-            hash += calculateArpMatchHash((ArpMatch) layer3Match);
-        }
-        if (layer3Match instanceof Ipv4Match) {
-            hash += calculateIpv4MatchHash((Ipv4Match) layer3Match);
-        }
-        if (layer3Match instanceof Ipv6Match) {
-            hash += calculateIpv6MatchHash((Ipv6Match) layer3Match);
-
-        }
-        if (layer3Match instanceof TunnelIpv4Match) {
-            hash += calculateTunnelIpv4Hash((TunnelIpv4Match) layer3Match);
-        }
-        return hash;
-    }
-
-    private static long calculateTunnelIpv4Hash(final TunnelIpv4Match layer3Match) {
-        Ipv4Prefix tunnelIpv4Destination = layer3Match.getTunnelIpv4Destination();
-        long hash = calculateIpv4PrefixHash(tunnelIpv4Destination);
-        Ipv4Prefix tunnelIpv4Source = layer3Match.getTunnelIpv4Source();
-        hash += calculateIpv4PrefixHash(tunnelIpv4Source);
-        return hash;
-    }
-
-    private static long calculateIpv6MatchHash(final Ipv6Match layer3Match) {
-        long hash = 0;
-        Ipv6Prefix ipv6Destination = layer3Match.getIpv6Destination();
-        if (null != ipv6Destination) {
-            hash += calculateIpv6PrefixHash(ipv6Destination);
-        }
-
-        if (null != layer3Match.getIpv6Source()) {
-            hash += calculateIpv6PrefixHash(layer3Match.getIpv6Source());
-        }
-
-        if (null != layer3Match.getIpv6ExtHeader()) {
-            hash += layer3Match.getIpv6ExtHeader().getIpv6Exthdr();
-            hash += layer3Match.getIpv6ExtHeader().getIpv6ExthdrMask();
-        }
-
-        if (null != layer3Match.getIpv6NdSll()) {
-            hash += calculateMacAddressHash(layer3Match.getIpv6NdSll());
-        }
-        if (null != layer3Match.getIpv6NdTll()) {
-            hash += calculateMacAddressHash(layer3Match.getIpv6NdTll());
-        }
-        if (null != layer3Match.getIpv6NdTarget()) {
-            hash += calculateIpv6AddressHash(layer3Match.getIpv6NdTarget());
-        }
-        return hash;
-    }
-
-
-    public static long calculateIpv6PrefixHash(final Ipv6Prefix ipv6Prefix) {
-
-        StringTokenizer stringTokenizer = getStringTokenizerWithFullAddressString(ipv6Prefix.getValue());
-
-        long hash = parseTokens(stringTokenizer, BASE_16, 16);
-        return hash;
-    }
-
-    public static long calculateIpv6AddressHash(final Ipv6Address ipv6Address) {
-
-        StringTokenizer stringTokenizer = getStringTokenizerWithFullAddressString(ipv6Address.getValue());
-
-        long hash = parseTokens(stringTokenizer, BASE_16, 16);
-        return hash;
-    }
-
-    private static StringTokenizer getStringTokenizerWithFullAddressString(final String value) {
-        String ipv6Value = DOUBLE_COLON.matcher(value).replaceAll(":0000:");
-        StringTokenizer stringTokenizer = new StringTokenizer(ipv6Value, ":");
-
-        long delta = IPV6_TOKENS_COUNT - stringTokenizer.countTokens();
-
-        StringBuilder additions = new StringBuilder();
-
-        if (delta > 0) {
-            while (delta > 0) {
-                additions.append(IPV6_TOKEN);
-                delta--;
-            }
-            if (ipv6Value.indexOf('/') != -1) {
-                additions.append('/');
-                ipv6Value = SLASH_MATCHER.replaceFrom(ipv6Value, additions.toString());
-            } else {
-                ipv6Value += additions.toString();
-            }
-            stringTokenizer = new StringTokenizer(ipv6Value, ":");
-        }
-        return stringTokenizer;
-    }
-
-    private static long calculateStopperBasedOnMaskValue(final Ipv6Prefix ipv6Prefix, final long bitsBase) {
-        double maskValue = extractMask(ipv6Prefix);
-        double bitCount = maskValue / bitsBase;
-        return (int) Math.ceil(bitCount);
-    }
-
-    private static long extractMask(final Ipv6Prefix ipv6Prefix) {
-        StringTokenizer maskTokenizer = new StringTokenizer(ipv6Prefix.getValue(), "/");
-        long mask = 0;
-        if (maskTokenizer.countTokens() > 1) {
-            maskTokenizer.nextToken();
-            mask = Integer.parseInt(maskTokenizer.nextToken());
-        }
-        return mask;
-    }
-
-    private static long parseTokens(final StringTokenizer stringTokenizer, final int base, final int bitShift) {
-        return parseTokens(stringTokenizer, 0, base, bitShift);
-    }
-
-    private static long parseTokens(final StringTokenizer stringTokenizer, final long stopper, final int base, final int bitShift) {
-        long hash = 0;
-        if (stringTokenizer.countTokens() > 0) {
-            long step = 0;
-            while (stringTokenizer.hasMoreTokens()) {
-                String token = stringTokenizer.nextToken();
-                step++;
-
-                if (token.isEmpty()) {
-                    token = "0";
-                }
-
-                if (token.indexOf('/') != -1) {
-                    StringTokenizer tokenizer = new StringTokenizer(token, "/");
-                    hash += parseTokens(tokenizer, stopper, base, bitShift);
-                } else {
-                    hash += Long.parseLong(token, base) << (bitShift * step);
-                    if (stopper > 0 && step == stopper) {
-                        break;
-                    }
-                }
-            }
-        }
-        return hash;
-    }
-
-    private static long calculateIpv4MatchHash(final Ipv4Match layer3Match) {
-        long hash = 0;
-        Ipv4Prefix ipv4Destination = layer3Match.getIpv4Destination();
-        if (null != ipv4Destination) {
-            hash += calculateIpv4PrefixHash(ipv4Destination);
-        }
-
-        Ipv4Prefix ipv4Source = layer3Match.getIpv4Source();
-
-        if (null != ipv4Source) {
-            hash += calculateIpv4PrefixHash(ipv4Source);
-        }
-
-        //TODO : add calculation of hashes for augmentations
-        return hash;
-    }
-
-    private static long calculateArpMatchHash(final ArpMatch layer3Match) {
-        long hash = 0;
-        Integer arpOp = layer3Match.getArpOp();
-        if (null != arpOp) {
-            hash += arpOp.intValue();
-        }
-        ArpSourceHardwareAddress arpSourceHardwareAddress = layer3Match.getArpSourceHardwareAddress();
-        if (null != arpSourceHardwareAddress) {
-            hash += calculateMacAddressHash(arpSourceHardwareAddress.getAddress());
-            hash += calculateMacAddressHash(arpSourceHardwareAddress.getMask());
-        }
-
-        Ipv4Prefix sourceTransportAddress = layer3Match.getArpSourceTransportAddress();
-        if (null != sourceTransportAddress) {
-            hash += calculateIpv4PrefixHash(sourceTransportAddress);
-        }
-
-        ArpTargetHardwareAddress arpTargetHardwareAddress = layer3Match.getArpTargetHardwareAddress();
-        if (null != arpTargetHardwareAddress) {
-            hash += calculateMacAddressHash(arpTargetHardwareAddress.getAddress());
-            hash += calculateMacAddressHash(arpTargetHardwareAddress.getMask());
-        }
-
-        Ipv4Prefix targetTransportAddress = layer3Match.getArpTargetTransportAddress();
-        if (null != targetTransportAddress) {
-            hash += calculateIpv4PrefixHash(targetTransportAddress);
-        }
-
-        return hash;
-    }
-
-    public static long calculateIpv4PrefixHash(final Ipv4Prefix ipv4Prefix) {
-        long hash = 0;
-        StringTokenizer prefixAsArray = new StringTokenizer(ipv4Prefix.getValue(), "/");
-        if (prefixAsArray.countTokens() == 2) {
-            String address = prefixAsArray.nextToken();
-            Long mask = Long.parseLong(prefixAsArray.nextToken());
-            long numberOfAddressPartsToUse = (int) Math.ceil(mask.doubleValue() / 8);
-            hash += calculateIpAdressHash(address, numberOfAddressPartsToUse, BASE_10);
-            hash += mask.shortValue();
-        }
-        return hash;
-    }
-
-
-    private static long calculateIpAdressHash(final String address, final long numberOfParts, final int base) {
-        StringTokenizer stringTokenizer = new StringTokenizer(address, ".");
-        long hash = parseTokens(stringTokenizer, numberOfParts, base, 8);
-        return hash;
-    }
-
-    @VisibleForTesting
-    public static long calculateIpMatchHash(final IpMatch ipMatch) {
-        long hash = 0;
-        Short ipEcn = ipMatch.getIpEcn();
-        if (null != ipEcn) {
-            hash += ipEcn.shortValue();
-        }
-        Short ipProtocol = ipMatch.getIpProtocol();
-        if (null != ipProtocol) {
-            hash += ipProtocol;
-        }
-
-        if (null != ipMatch.getIpDscp()) {
-            Short ipDscp = ipMatch.getIpDscp().getValue();
-            if (null != ipDscp) {
-                hash += ipDscp;
-            }
-        }
-
-        IpVersion ipVersion = ipMatch.getIpProto();
-        if (null != ipVersion)
-
-        {
-            hash += ipVersion.getIntValue();
-        }
-
-        return hash;
-    }
-
-    private static long calculateNodeConnectorIdHash(final NodeConnectorId inPhyPort, final short version) {
-        long hash = 0;
-        Long portFromLogicalName = OpenflowPortsUtil.getPortFromLogicalName(OpenflowVersion.get(version), inPhyPort.getValue());
-        hash += portFromLogicalName.intValue();
-        return hash;
-    }
-
-    private static long calculateIcmpV6MatchHash(final Icmpv6Match icmpv6Match) {
-        long hash = 0;
-        if (null != icmpv6Match.getIcmpv6Code()) {
-            hash += icmpv6Match.getIcmpv6Code();
-        }
-        if (null != icmpv6Match.getIcmpv6Type()) {
-            hash += icmpv6Match.getIcmpv6Type();
-        }
-        return hash;
-    }
-
-    public static long calculateIcmpV4MatchHash(final Icmpv4Match icmpv4Match) {
-        long hash = 0;
-        if (null != icmpv4Match.getIcmpv4Code()) {
-            hash += icmpv4Match.getIcmpv4Code();
-        }
-        if (null != icmpv4Match.getIcmpv4Type()) {
-            hash += icmpv4Match.getIcmpv4Type();
-        }
-        return hash;
-    }
-
-
-}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/StatisticsServiceUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/StatisticsServiceUtil.java
deleted file mode 100644 (file)
index 59b48f4..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.impl.util;
-
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-/**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 18.5.2015.
- */
-public class StatisticsServiceUtil {
-
-    private StatisticsServiceUtil() {
-        throw new IllegalStateException("This class should not be instantiated");
-    }
-
-    public static <T> ListenableFuture<RpcResult<T>> getRpcResultListenableFuture(final Xid xid,
-                                                                                 final MultipartRequestInput multipartRequestInput,
-                                                                                 final DeviceContext deviceContext) {
-        final SettableFuture<RpcResult<T>> settableFuture = SettableFuture.create();
-        final OutboundQueue outboundQueue = deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider();
-        outboundQueue.commitEntry(xid.getValue(), multipartRequestInput, new FutureCallback<OfHeader>() {
-            @Override
-            public void onSuccess(final OfHeader ofHeader) {
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-            }
-        });
-        return settableFuture;
-    }
-
-}
index 008453528609db5c62be6cb2345a2d93a6b5c9f1..562f7de5a9e253acfe438c09a1d19a62edf2624c 100644 (file)
@@ -44,12 +44,9 @@ public class RpcManagerImplTest {
 
     private static final int AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC = 12;
 
-    private static final int AWAITED_NUM_OF_CALL_ADD_NEW_REQUEST = 1;
 
     final ProviderContext mockedProviderContext = mock(ProviderContext.class);
-    final RpcManagerImpl rpcManager = new RpcManagerImpl(mockedProviderContext, 500l);
-    final RpcContext mockedRpcContext = mock(RpcContext.class);
-    final AddFlowInput mockedFlowInput = prepareTestingAddFlow();
+    final RpcManagerImpl rpcManager = new RpcManagerImpl(mockedProviderContext, 500);
     final DeviceContext mockedDeviceContext = mock(DeviceContext.class);
     @Mock
     private MessageSpy messageSpy;
index 224bb65884df076e75ef2379525255ea6dfe34b8..b2257cf6dcd861f8569d240f5a35b881247781c8 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 @RunWith(MockitoJUnitRunner.class)
 public class ConnectionContextImplTest {
 
-    private ConnectionContextImpl conContext;
 
     @Mock
     private ConnectionAdapter conAdapter;
@@ -38,7 +37,6 @@ public class ConnectionContextImplTest {
     @Before
     public void initialization() {
         // place for mocking method's general behavior for ConnectorAdapter
-        conContext = new ConnectionContextImpl(conAdapter);
     }
 
     /**
index eada54c499ed7d69bea2803af67f8d0f1ce41683..556afe8efdf019d3382c78d66d6a761eba24be2d 100644 (file)
@@ -1,7 +1,6 @@
 package org.opendaylight.openflowplugin.impl.device;
 
 import static org.mockito.Matchers.any;
-
 import com.google.common.util.concurrent.SettableFuture;
 import io.netty.util.HashedWheelTimer;
 import java.util.ArrayList;
@@ -85,7 +84,7 @@ public class DeviceContextImplTest {
     @Before
     public void setUp() {
         Mockito.when(dataBroker.createTransactionChain(Mockito.any(TransactionChainManager.class))).thenReturn(txChainFactory);
-        txChainManager = new TransactionChainManager(dataBroker, timer, 5L, 5L);
+        txChainManager = new TransactionChainManager(dataBroker, deviceState);
         final SettableFuture<RpcResult<GetAsyncReply>> settableFuture = SettableFuture.create();
         final SettableFuture<RpcResult<MultipartReply>> settableFutureMultiReply = SettableFuture.create();
         Mockito.when(requestContext.getFuture()).thenReturn(settableFuture);
@@ -117,22 +116,22 @@ public class DeviceContextImplTest {
     }
 
     @Test(expected = NullPointerException.class)
-    public void testDeviceContextImplConstructorNullConnectionContext() {
+    public void testDeviceContextImplConstructorNullConnectionContext() throws Exception {
         new DeviceContextImpl(null, deviceState, dataBroker, timer, messageIntelligenceAgency).close();
     }
 
     @Test(expected = NullPointerException.class)
-    public void testDeviceContextImplConstructorNullDataBroker() {
+    public void testDeviceContextImplConstructorNullDataBroker() throws Exception {
         new DeviceContextImpl(connectionContext, deviceState, null, timer, messageIntelligenceAgency).close();
     }
 
     @Test(expected = NullPointerException.class)
-    public void testDeviceContextImplConstructorNullDeviceState() {
+    public void testDeviceContextImplConstructorNullDeviceState() throws Exception {
         new DeviceContextImpl(connectionContext, null, dataBroker, timer, messageIntelligenceAgency).close();
     }
 
     @Test(expected = NullPointerException.class)
-    public void testDeviceContextImplConstructorNullTimer() {
+    public void testDeviceContextImplConstructorNullTimer() throws Exception {
         new DeviceContextImpl(null, deviceState, dataBroker, null, messageIntelligenceAgency).close();
     }
 
@@ -150,42 +149,5 @@ public class DeviceContextImplTest {
         Assert.assertEquals(rTx, readTx);
     }
 
-    private static GetAsyncOutput createAsyncOutput(final Xid xid) {
-        final GetAsyncOutputBuilder asyncOutputBuilder = new GetAsyncOutputBuilder();
-        asyncOutputBuilder.setFlowRemovedMask(Collections.<FlowRemovedMask>emptyList());
-        asyncOutputBuilder.setPacketInMask(Collections.<PacketInMask>emptyList());
-        asyncOutputBuilder.setPortStatusMask(Collections.<PortStatusMask>emptyList());
-        asyncOutputBuilder.setVersion(OFConstants.OFP_VERSION_1_3);
-        asyncOutputBuilder.setXid(xid.getValue());
-        return asyncOutputBuilder.build();
-    }
-
-
-    private static Error createError(final Xid xid) {
-        final ErrorMessageBuilder errorMessageBuilder = new ErrorMessageBuilder();
-        errorMessageBuilder.setCode(42);
-        errorMessageBuilder.setCodeString("42");
-        errorMessageBuilder.setXid(xid.getValue());
-        return errorMessageBuilder.build();
-    }
-
-    private static List<MultipartReply> createMultipartReplyList(final Xid xid) {
-        final MultipartReplyDesc descValue = new MultipartReplyDescBuilder().setHwDesc("hw-test-value").build();
-        final MultipartReplyDescCase replyBody = new MultipartReplyDescCaseBuilder()
-                .setMultipartReplyDesc(descValue).build();
-        final List<MultipartReply> multipartReplies = new ArrayList<>();
-        multipartReplies.add(new MultipartReplyMessageBuilder()
-                .setMultipartReplyBody(replyBody)
-                .setXid(xid.getValue())
-                .setFlags(new MultipartRequestFlags(false))
-                .build());
-        multipartReplies.add(new MultipartReplyMessageBuilder()
-                .setMultipartReplyBody(replyBody)
-                .setXid(xid.getValue())
-                .setFlags(new MultipartRequestFlags(true))
-                .build());
-        return multipartReplies;
-    }
-
 
 }
index 8cddc66a856b06fd9fe198776914e1601ec4821b..ffce1921434d0e9d239ef5eac90e69a4bbab25a0 100644 (file)
@@ -90,26 +90,6 @@ public class DeviceManagerImplTest {
         //Assert.assertTrue(mpInputCaptor.getAllValues().get(1).getMultipartRequestBody() instanceof MultipartRequestGroupDescCase);
     }
 
-    /**
-     * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#sendMessage(org.opendaylight.yangtools.yang.binding.DataObject, org.opendaylight.openflowplugin.api.openflow.device.RequestContext)}.
-     */
-    @Test
-    public void testSendMessage() {
-    }
-
-    /**
-     * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#sendRequest(org.opendaylight.yangtools.yang.binding.DataObject, org.opendaylight.openflowplugin.api.openflow.device.RequestContext)}.
-     */
-    @Test
-    public void testSendRequest() {
-    }
-
-    /**
-     * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#addRequestContextReadyHandler(org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextReadyHandler)}.
-     */
-    @Test
-    public void testAddRequestContextReadyHandler() {
-    }
 
     @Test
     public void testHookRequest() {
index 88c6a6211887b64f8388e54c6513323784104948..18956b5892f51a50a48bfc3c672783d41550c83d 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.util.concurrent.Futures;
 import io.netty.util.HashedWheelTimer;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Matchers;
@@ -26,6 +27,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 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;
@@ -42,6 +44,8 @@ public class TransactionChainManagerTest {
     @Mock
     private DataBroker dataBroker;
     @Mock
+    private DeviceState deviceState;
+    @Mock
     private BindingTransactionChain txChain;
     @Mock
     private WriteTransaction writeTx;
@@ -58,7 +62,8 @@ public class TransactionChainManagerTest {
     public void setUp() throws Exception {
         Mockito.when(dataBroker.createTransactionChain(Matchers.any(TransactionChainListener.class)))
                 .thenReturn(txChain);
-        txChainManager = new TransactionChainManager(dataBroker, timer, 2, 2);
+        Mockito.when(deviceState.isValid()).thenReturn(Boolean.TRUE);
+        txChainManager = new TransactionChainManager(dataBroker, deviceState);
         Mockito.when(txChain.newWriteOnlyTransaction()).thenReturn(writeTx);
 
         nodeId = new NodeId("h2g2:42");
@@ -86,12 +91,11 @@ public class TransactionChainManagerTest {
         final Node data = new NodeBuilder().setId(nodeId).build();
         txChainManager.enableSubmit();
         txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data);
-        txChainManager.submitTransaction();
+        txChainManager.submitWriteTransaction();
 
         Mockito.verify(txChain).newWriteOnlyTransaction();
         Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
         Mockito.verify(writeTx).submit();
-        Mockito.verify(writeTx).getIdentifier();
     }
 
     /**
@@ -113,6 +117,7 @@ public class TransactionChainManagerTest {
      * @throws Exception
      */
     @Test
+    @Ignore  // FIXME : think about test -> we don't use submit by time and nrOfOperations
     public void testEnableCounter2() throws Exception {
         txChainManager.enableSubmit();
 
index 0df10537f4b5f6b9eeab07af737d8ca7f9078b00..f517c818f1d368f82c0510cf6cd1efc4f542f6cc 100644 (file)
@@ -19,15 +19,17 @@ import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.internal.verification.VerificationModeFactory;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.impl.connection.testutil.MsgGeneratorTestUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
 
 /**
  * openflowplugin-api
@@ -49,13 +51,13 @@ public class MultiMsgCollectorImplTest {
     @Mock
     DeviceReplyProcessor deviceProcessor;
     @Captor
-    ArgumentCaptor<DeviceDataException> ddeCaptor;
+    ArgumentCaptor<DeviceRequestFailedException> ddeCaptor;
     @Captor
     ArgumentCaptor<Xid> xidCaptor;
     @Captor
     ArgumentCaptor<List<MultipartReply>> mmCaptor;
     @Mock
-    RequestContext requestContext;
+    RequestContext<List<MultipartReply>> requestContext;
     final Long xid = 1L;
 
 
@@ -66,8 +68,7 @@ public class MultiMsgCollectorImplTest {
 
     @Before
     public void setUp() {
-        collector = new MultiMsgCollectorImpl(1);
-        collector.setDeviceReplyProcessor(deviceProcessor);
+        collector = new MultiMsgCollectorImpl(deviceProcessor, requestContext);
         cleanUpCheck = Runnables.doNothing();
         Mockito.when(requestContext.getXid()).thenReturn(new Xid(xid));
     }
@@ -77,7 +78,6 @@ public class MultiMsgCollectorImplTest {
         Thread.sleep(1100L);
 
         // flush cache action
-        collector.registerMultipartRequestContext(requestContext);
         cleanUpCheck.run();
         Mockito.verifyNoMoreInteractions(deviceProcessor);
     }
@@ -88,14 +88,12 @@ public class MultiMsgCollectorImplTest {
      */
     @Test
     public void testAddMultipartMsgOne() {
-        final Long xid = 1L;
-        collector.registerMultipartRequestContext(requestContext);
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
 
         Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
         Assert.assertEquals(xid, xidCaptor.getValue().getValue());
 
-        List<MultipartReply> multipartReplyList = mmCaptor.getValue();
+        final List<MultipartReply> multipartReplyList = mmCaptor.getValue();
         Assert.assertEquals(1, multipartReplyList.size());
         Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(0).getType());
     }
@@ -106,15 +104,13 @@ public class MultiMsgCollectorImplTest {
      */
     @Test
     public void testAddMultipartMsgTwo() {
-        final Long xid = 1L;
-        collector.registerMultipartRequestContext(requestContext);
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
 
         Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
         Assert.assertEquals(xid, xidCaptor.getValue().getValue());
 
-        List<MultipartReply> multipartReplyList = mmCaptor.getValue();
+        final List<MultipartReply> multipartReplyList = mmCaptor.getValue();
         Assert.assertEquals(2, multipartReplyList.size());
         Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(0).getType());
         Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(1).getType());
@@ -124,14 +120,11 @@ public class MultiMsgCollectorImplTest {
      * test of ${link MultiMsgCollector#addMultipartMsg} <br>
      * xid not registered before message
      */
-    @Test
+    @Test(expected=IllegalArgumentException.class)
     public void testAddMultipartMsgNotExpectedXid() {
-        final Long xid = 1L;
-        collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
-
-        Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
-        Assert.assertEquals(xid, xidCaptor.getValue().getValue());
-        Assert.assertEquals(expectedUnknownXidMsg, ddeCaptor.getValue().getMessage());
+        final Long dif_xid = 5L;
+        final MultipartReplyMessage mrMsg = MsgGeneratorTestUtils.makeMultipartDescReply(dif_xid, hwTestValue, true).build();
+        collector.addMultipartMsg(mrMsg);
     }
 
     /**
@@ -140,24 +133,21 @@ public class MultiMsgCollectorImplTest {
      */
     @Test
     public void testAddMultipartMsgWrongType1() {
-        collector.registerMultipartRequestContext(requestContext);
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false)
                 .setType(MultipartType.OFPMPPORTDESC).build());
 
-
-        Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+        Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
         Assert.assertEquals(xid, xidCaptor.getValue().getValue());
-        Assert.assertEquals(expectedTypMismatchMsg, ddeCaptor.getValue().getMessage());
 
         Mockito.reset(deviceProcessor);
 
         cleanUpCheck = new Runnable() {
             @Override
             public void run() {
-                Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+                Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions())
+                    .processReply(xidCaptor.capture(), mmCaptor.capture());
                 Assert.assertEquals(xid, xidCaptor.getValue().getValue());
-                Assert.assertEquals(expectedExpirationMsg, ddeCaptor.getValue().getMessage());
             }
         };
     }
@@ -168,24 +158,23 @@ public class MultiMsgCollectorImplTest {
      */
     @Test
     public void testAddMultipartMsgWrongType2() {
-        final Long xid = 1L;
-        collector.registerMultipartRequestContext(requestContext);
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true)
                 .setType(MultipartType.OFPMPPORTDESC).build());
+        collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
 
-        Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+        Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
+        Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
         Assert.assertEquals(xid, xidCaptor.getValue().getValue());
-        Assert.assertEquals(expectedTypMismatchMsg, ddeCaptor.getValue().getMessage());
 
         Mockito.reset(deviceProcessor);
 
         cleanUpCheck = new Runnable() {
             @Override
             public void run() {
-                Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+                Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions())
+                    .processReply(xidCaptor.capture(), mmCaptor.capture());
                 Assert.assertEquals(xid, xidCaptor.getValue().getValue());
-                Assert.assertEquals(expectedExpirationMsg, ddeCaptor.getValue().getMessage());
             }
         };
     }
@@ -196,44 +185,21 @@ public class MultiMsgCollectorImplTest {
      */
     @Test
     public void testAddMultipartMsgWrongType3() {
-        final Long xid = 1L;
-        collector.registerMultipartRequestContext(requestContext);
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true)
                 .setType(MultipartType.OFPMPPORTDESC).build());
         collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
 
-        Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+        Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
         Assert.assertEquals(xid, xidCaptor.getValue().getValue());
-        Assert.assertEquals(expectedTypMismatchMsg, ddeCaptor.getValue().getMessage());
 
         Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
         Assert.assertEquals(xid, xidCaptor.getValue().getValue());
 
-        List<MultipartReply> multipartReplyList = mmCaptor.getValue();
-        Assert.assertEquals(2, multipartReplyList.size());
+        final List<MultipartReply> multipartReplyList = mmCaptor.getValue();
+        Assert.assertEquals(3, multipartReplyList.size());
         Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(0).getType());
-        Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(1).getType());
+        Assert.assertEquals(MultipartType.OFPMPPORTDESC, multipartReplyList.get(1).getType());
+        Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(2).getType());
     }
-
-    /**
-     * test of ${link MultiMsgCollector#addMultipartMsg} <br>
-     * no second message arrived within expiration limit - first message should expire
-     */
-    @Test
-    public void testAddMultipartMsgExpiration() throws InterruptedException {
-        final Long xid = 1L;
-        collector.registerMultipartRequestContext(requestContext);
-        collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
-
-        cleanUpCheck = new Runnable() {
-            @Override
-            public void run() {
-                Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
-                Assert.assertEquals(xid, xidCaptor.getValue().getValue());
-                Assert.assertEquals(expectedExpirationMsg, ddeCaptor.getValue().getMessage());
-            }
-        };
-    }
-
 }
index 605440f4f1d8832b4973fee0dbdd5a168d9951c5..a0c77bf030bf85d698040cf7f1f035d910a20089 100644 (file)
@@ -56,7 +56,6 @@ public class OpenflowProtocolListenerFullImplTest {
     @Mock
     private ConnectionAdapter connectionAdapter;
 
-    private final String hwDescValue = "test-val";
     private final long xid = 42L;
 
     @Before
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.impl.registry.flow;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -24,7 +25,7 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
@@ -40,10 +41,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 @RunWith(MockitoJUnitRunner.class)
-public class FlowHashFactoryTest {
+public class FlowRegistryKeyFactoryTest {
 
-    private static final Logger LOG = LoggerFactory.getLogger(FlowHashFactoryTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(FlowRegistryKeyFactoryTest.class);
 
 
     private static final FlowsStatisticsUpdateBuilder FLOWS_STATISTICS_UPDATE_BUILDER = new FlowsStatisticsUpdateBuilder();
@@ -89,12 +91,12 @@ public class FlowHashFactoryTest {
     public void testEquals() throws Exception {
         FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build();
 
-        HashSet<FlowHash> flowHashs = new HashSet<>();
+        HashSet<FlowRegistryKey> flowRegistryKeys = new HashSet<>();
         for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) {
-            flowHashs.add(FlowHashFactory.create(item, OFConstants.OFP_VERSION_1_3));
-            flowHashs.add(FlowHashFactory.create(item, OFConstants.OFP_VERSION_1_3));
+            flowRegistryKeys.add(FlowRegistryKeyFactory.create(item));
+            flowRegistryKeys.add(FlowRegistryKeyFactory.create(item));
         }
-        assertEquals(3, flowHashs.size());
+        assertEquals(3, flowRegistryKeys.size());
     }
 
     @Test
@@ -107,7 +109,7 @@ public class FlowHashFactoryTest {
                 .setPriority(2)
                 .setTableId((short) 0);
 
-        FlowHash flow1Hash = FlowHashFactory.create(flow1Builder.build(), OFConstants.OFP_VERSION_1_3);
+        FlowRegistryKey flow1Hash = FlowRegistryKeyFactory.create(flow1Builder.build());
         LOG.info("flowHash1: {}", flow1Hash.hashCode());
 
 
@@ -117,7 +119,7 @@ public class FlowHashFactoryTest {
                 .setCookie(new FlowCookie(BigInteger.valueOf(148)))
                 .setMatch(match2Builder.build());
 
-        FlowHash flow2Hash = FlowHashFactory.create(flow2Builder.build(), OFConstants.OFP_VERSION_1_3);
+        FlowRegistryKey flow2Hash = FlowRegistryKeyFactory.create(flow2Builder.build());
         LOG.info("flowHash2: {}", flow2Hash.hashCode());
 
         Assert.assertNotSame(flow1Hash, flow2Hash);
@@ -136,7 +138,7 @@ public class FlowHashFactoryTest {
         FlowBuilder fb1 = new FlowBuilder(flow1Builder.build());
         fb1.setTableId(null);
         try {
-            FlowHashFactory.create(fb1.build(), OFConstants.OFP_VERSION_1_3);
+            FlowRegistryKeyFactory.create(fb1.build());
             Assert.fail("hash creation should have failed because of NPE");
         } catch (Exception e) {
             // expected
@@ -146,7 +148,7 @@ public class FlowHashFactoryTest {
         FlowBuilder fb2 = new FlowBuilder(flow1Builder.build());
         fb2.setPriority(null);
         try {
-            FlowHashFactory.create(fb2.build(), OFConstants.OFP_VERSION_1_3);
+            FlowRegistryKeyFactory.create(fb2.build());
             Assert.fail("hash creation should have failed because of NPE");
         } catch (Exception e) {
             // expected
@@ -155,9 +157,9 @@ public class FlowHashFactoryTest {
 
         FlowBuilder fb3 = new FlowBuilder(flow1Builder.build());
         fb3.setCookie(null);
-        FlowHash flowHash = FlowHashFactory.create(fb3.build(), OFConstants.OFP_VERSION_1_3);
-        Assert.assertNotNull(flowHash.getCookie());
-        Assert.assertEquals(OFConstants.DEFAULT_COOKIE, flowHash.getCookie());
+        FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(fb3.build());
+        Assert.assertNotNull(flowRegistryKey.getCookie());
+        Assert.assertEquals(OFConstants.DEFAULT_COOKIE, flowRegistryKey.getCookie());
     }
 
     @Test
@@ -165,12 +167,12 @@ public class FlowHashFactoryTest {
         FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build();
 
         for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) {
-            FlowHash flowHash = FlowHashFactory.create(item, OFConstants.OFP_VERSION_1_3);
-            FlowHash lastHash = null;
+            FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(item);
+            FlowRegistryKey lastHash = null;
             if (null != lastHash) {
-                assertNotEquals(lastHash, flowHash);
+                assertNotEquals(lastHash, flowRegistryKey);
             } else {
-                lastHash = flowHash;
+                lastHash = flowRegistryKey;
             }
         }
     }
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/HashUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/HashUtilTest.java
deleted file mode 100644 (file)
index 11c8220..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.impl.util;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HashUtilTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HashUtilTest.class);
-
-    private static final MacAddress[] MAC_ADDRESSES = {
-            new MacAddress("00:00:00:00:00:00"),
-            new MacAddress("AA:BB:CC:DD:EE:FF"),
-            new MacAddress("FF:EE:DD:CC:BB:AA"),
-            new MacAddress("0A:37:C1:00:AB:FF"),
-            new MacAddress("0A:37:C1:00:AB:FE"),
-            new MacAddress("0A:37:C1:00:FE:AB")
-    };
-
-    private static final Ipv4Prefix[] IPV_4_PREFIXES = {
-            new Ipv4Prefix("10.0.0.1/24"),
-            new Ipv4Prefix("10.0.1.0/24"),
-            new Ipv4Prefix("10.0.1.0/31"),
-            new Ipv4Prefix("0.0.0.0/32"),
-            new Ipv4Prefix("4.3.2.1/32"),
-            new Ipv4Prefix("1.2.3.4/32")
-    };
-
-    private static final Ipv6Prefix[] IPV_6_PREFIXES = {
-            new Ipv6Prefix("FFFF:0DB8:0000:0000:0000:0000:1428:57ab"),
-            new Ipv6Prefix("2001:0DB8:0000:0000:0000:0000:1428:57ab"),
-            new Ipv6Prefix("0DB8:2001:0000:0000:0000:0000:1428:57ab"),
-            new Ipv6Prefix("2001:0DB8:0000:0000:0000:0000:57ab:1428")
-    };
-
-    private static final Ipv6Prefix shortIpv6 = new Ipv6Prefix("fe80::2acf:e9ff:fe21:6431/128");
-    private static final Ipv6Prefix fullIpv6 = new Ipv6Prefix("fe80:0000:2acf:e9ff:fe21:6431:0000:0000/128");
-    private static final Ipv6Prefix[] IPV_6_PREFIXES_WITH_MASK = {
-            new Ipv6Prefix("FFFF:0DB8:0000:0000:0000:0000:1428:57ab/72"),
-            new Ipv6Prefix("2001:0DB8:0000:0000:0000:0000:1428:57ab/94"),
-            new Ipv6Prefix("0DB8:2001:0000:0000:0000:0000:1428:57ab/32"),
-            new Ipv6Prefix("2001:0DB8:0000:0000:0000:0000:57ab:1428/64")
-    };
-
-
-    @Test
-    public void trivialLongTest() {
-
-        Long longA = new Long(42);
-        Long longB = new Long(42);
-        Assert.assertNotSame(longA, longB);
-        Long longC = Long.valueOf(42);
-        Long longD = Long.valueOf(42);
-        Assert.assertSame(longC, longD);
-
-    }
-
-
-    @Test
-    public void testCalculateMatchHash() throws Exception {
-        long hashShort = HashUtil.calculateIpv6PrefixHash(shortIpv6);
-        long hashLong = HashUtil.calculateIpv6PrefixHash(fullIpv6);
-        Assert.assertEquals(hashShort, hashLong);
-    }
-
-    @Test
-    public void testCalculateMacAddressHash() {
-        for (int i = 0; i < MAC_ADDRESSES.length - 1; i++) {
-            long hash = HashUtil.calculateMacAddressHash(MAC_ADDRESSES[i]);
-            long otherHash = HashUtil.calculateMacAddressHash(MAC_ADDRESSES[i + 1]);
-            Assert.assertNotEquals(hash, otherHash);
-        }
-    }
-
-    @Test
-    public void testCalculateIpv4PrefixHash() {
-        for (int i = 0; i < IPV_4_PREFIXES.length - 1; i++) {
-            Ipv4Prefix prefixA = IPV_4_PREFIXES[i];
-            Ipv4Prefix prefixB = IPV_4_PREFIXES[i + 1];
-            long hash = HashUtil.calculateIpv4PrefixHash(prefixA);
-            long hash_n = HashUtil.calculateIpv4PrefixHash(prefixB);
-            LOG.info("Comparing {} vs. {} (hash {} vs. hash {})", prefixA, prefixB, hash, hash_n);
-            Assert.assertNotEquals(hash, hash_n);
-        }
-
-    }
-
-    @Test
-    public void testCalculateIpv6PrefixHash() {
-        for (int i = 0; i < IPV_6_PREFIXES.length - 1; i++) {
-            long hash_n = HashUtil.calculateIpv6PrefixHash(IPV_6_PREFIXES[i]);
-            long hash_n1 = HashUtil.calculateIpv6PrefixHash(IPV_6_PREFIXES[i + 1]);
-            Assert.assertNotNull(hash_n);
-            Assert.assertNotNull(hash_n1);
-            Assert.assertNotEquals(hash_n, hash_n1);
-        }
-    }
-
-    @Test
-    public void testCalculateIpv6PrefixHashWithMask() {
-        for (int i = 0; i < IPV_6_PREFIXES.length - 1; i++) {
-            long hash_n = HashUtil.calculateIpv6PrefixHash(IPV_6_PREFIXES_WITH_MASK[i]);
-            long hash_n1 = HashUtil.calculateIpv6PrefixHash(IPV_6_PREFIXES_WITH_MASK[i + 1]);
-            Assert.assertNotNull(hash_n);
-            Assert.assertNotNull(hash_n1);
-            Assert.assertNotEquals(hash_n, hash_n1);
-        }
-    }
-
-    @Test
-    public void calculateIpMatchHash() {
-        IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
-        ipMatchBuilder.setIpEcn((short) 42);
-        HashUtil.calculateIpMatchHash(ipMatchBuilder.build());
-    }
-
-}
\ No newline at end of file
index 929baab5e318224c1009e8b8e8b97449c468903e..d9c32f6b865177e6012b67cb6d520627786ff072 100644 (file)
@@ -7,9 +7,12 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.extension;
 
+import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase;
@@ -37,15 +40,20 @@ public final class ActionExtensionHelper {
      */
     public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
     processAlienAction(Action action, OpenflowVersion ofVersion, ActionPath actionPath) {
-        ExperimenterIdCase actionCase = (ExperimenterIdCase) action.getActionChoice();
-        /** TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL) */
-        ExperimenterActionSerializerKey key = new ExperimenterActionSerializerKey(
-                ofVersion.getVersion(),
-                actionCase.getExperimenter().getExperimenter().getValue(),
-                actionCase.getExperimenter().getSubType());
-
+        ConvertorActionFromOFJava<Action, ActionPath> convertor = null;
         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action alienAction = null;
-        ConvertorActionFromOFJava<Action, ActionPath> convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+        if(action.getActionChoice() instanceof ExperimenterIdCase) {
+            ExperimenterIdCase actionCase = (ExperimenterIdCase) action.getActionChoice();
+            /** TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL) */
+            ExperimenterActionSerializerKey key = new ExperimenterActionSerializerKey(
+                    ofVersion.getVersion(),
+                    actionCase.getExperimenter().getExperimenter().getValue(),
+                    actionCase.getExperimenter().getSubType());
+            convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+        } else if (action.getActionChoice() != null){
+            ActionSerializerKey<?> key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, action.getActionChoice().getImplementedInterface(), null);
+            convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+        }
         if (convertor != null) {
             alienAction = convertor.convert(
                     action, actionPath);
index 09d0f8e3fbc54b9543de4ce118097d1fa1a12a5a..17cf3546014d678caf701a20dae5c8e21c48c342 100644 (file)
@@ -197,6 +197,8 @@ import com.google.common.collect.Ordering;
 public final class ActionConvertor {
     private static final Logger LOG = LoggerFactory.getLogger(ActionConvertor.class);
     private static final String UNKNOWN_ACTION_TYPE_VERSION = "Unknown Action Type for the Version";
+    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> ACTION_ORDERING =
+            Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build());
 
     private ActionConvertor() {
         // NOOP
@@ -218,8 +220,7 @@ public final class ActionConvertor {
         Action ofAction;
 
         final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> sortedActions =
-                Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build())
-                        .sortedCopy(actions);
+                ACTION_ORDERING.sortedCopy(actions);
 
         for (int actionItem = 0; actionItem < sortedActions.size(); actionItem++) {
             ofAction = null;
@@ -290,7 +291,6 @@ public final class ActionConvertor {
             } else if (action instanceof SetNwTosActionCase) {
                 ofAction = salToOFSetNwTos(action, actionBuilder, version);
             } else if (action instanceof GeneralExtensionGrouping) {
-
                 /**
                  * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
                  * - we might need sessionContext as converter input
@@ -990,7 +990,7 @@ public final class ActionConvertor {
                 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder setNwDstActionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder();
                 bucketActions.add(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
 
-            } else if (action.getActionChoice() instanceof ExperimenterIdCase) {
+            } else {
                 /**
                  * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
                  * - we might also need a way on how to identify exact type of augmentation to be
index 6837255dc90b7b8c64e0a0ed40c077fa054705e5..aca8cd23537be4a91cf051d24983bc2690f9fbef 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
-
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag.FlowFlagReactor;
@@ -72,9 +72,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Ordering;
 
 /**
@@ -135,6 +135,30 @@ public class FlowConvertor {
      */
     public static final List<MatchEntry> DEFAULT_MATCH_ENTRIES = new ArrayList<MatchEntry>();
 
+    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> INSTRUCTION_ORDERING =
+            Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>build());
+
+    private static final VlanMatch VLAN_MATCH_FALSE;
+    private static final VlanMatch VLAN_MATCH_TRUE;
+
+    static {
+        final VlanId zeroVlan = new VlanId(0);
+        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+        VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+        vlanIdBuilder.setVlanIdPresent(false);
+        vlanIdBuilder.setVlanId(zeroVlan);
+        vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
+
+        VLAN_MATCH_FALSE = vlanMatchBuilder.build();
+
+        VlanMatchBuilder vlanMatchBuilder2 = new VlanMatchBuilder();
+        VlanIdBuilder vlanIdBuilder2 = new VlanIdBuilder();
+        vlanIdBuilder2.setVlanIdPresent(true);
+        vlanIdBuilder2.setVlanId(zeroVlan);
+        vlanMatchBuilder2.setVlanId(vlanIdBuilder2.build());
+
+        VLAN_MATCH_TRUE = vlanMatchBuilder2.build();
+    }
 
     private FlowConvertor() {
         //hiding implicit constructor
@@ -146,14 +170,11 @@ public class FlowConvertor {
      * If yes its handled separately
      */
     public static List<FlowModInputBuilder> toFlowModInputs(Flow srcFlow, short version, BigInteger datapathId) {
-        List<FlowModInputBuilder> list = new ArrayList<>();
-
         if (version >= OFConstants.OFP_VERSION_1_3 && isSetVlanIdActionCasePresent(srcFlow)) {
-            list.addAll(handleSetVlanIdForOF13(srcFlow, version, datapathId));
+            return handleSetVlanIdForOF13(srcFlow, version, datapathId);
         } else {
-            list.add(toFlowModInput(srcFlow, version, datapathId));
+            return Collections.singletonList(toFlowModInput(srcFlow, version, datapathId));
         }
-        return list;
     }
 
     public static FlowModInputBuilder toFlowModInput(Flow flow, short version, BigInteger datapathid) {
@@ -237,13 +258,13 @@ public class FlowConvertor {
         if (flow instanceof AddFlowInput) {
             flowMod.setCommand(FlowModCommand.OFPFCADD);
         } else if (flow instanceof RemoveFlowInput) {
-            if (Objects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
+            if (MoreObjects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
                 flowMod.setCommand(FlowModCommand.OFPFCDELETESTRICT);
             } else {
                 flowMod.setCommand(FlowModCommand.OFPFCDELETE);
             }
         } else if (flow instanceof UpdatedFlow) {
-            if (Objects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
+            if (MoreObjects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
                 flowMod.setCommand(FlowModCommand.OFPFCMODIFYSTRICT);
             } else {
                 flowMod.setCommand(FlowModCommand.OFPFCMODIFY);
@@ -298,7 +319,7 @@ public class FlowConvertor {
             } else if (curInstruction instanceof WriteMetadataCase) {
                 WriteMetadataCase writeMetadatacase = (WriteMetadataCase) curInstruction;
                 WriteMetadata writeMetadata = writeMetadatacase.getWriteMetadata();
-                
+
                 WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
                 WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
                 writeMetadataBuilder.setMetadata(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadata(),
@@ -320,16 +341,16 @@ public class FlowConvertor {
             } else if (curInstruction instanceof ApplyActionsCase) {
                 ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction;
                 ApplyActions applyActions = applyActionscase.getApplyActions();
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder applyActionsCaseBuilder = 
+                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder applyActionsCaseBuilder =
                         new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder();
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder applyActionsBuilder = 
+                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder applyActionsBuilder =
                         new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder();
                 applyActionsBuilder.setAction(ActionConvertor.getActions(applyActions.getAction(), version, datapathid, flow));
                 applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
                 instructionBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
                 instructionsList.add(instructionBuilder.build());
             } else if (curInstruction instanceof ClearActionsCase) {
-                ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();  
+                ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
                 instructionBuilder.setInstructionChoice(clearActionsCaseBuilder.build());
                 instructionsList.add(instructionBuilder.build());
             } else if (curInstruction instanceof MeterCase) {
@@ -351,8 +372,7 @@ public class FlowConvertor {
 
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions = flow.getInstructions();
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> sortedInstructions =
-                Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>build())
-                        .sortedCopy(instructions.getInstruction());
+                INSTRUCTION_ORDERING.sortedCopy(instructions.getInstruction());
 
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : sortedInstructions) {
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction
@@ -369,7 +389,6 @@ public class FlowConvertor {
 
     // check if set vlanid action is present in the flow
     private static boolean isSetVlanIdActionCasePresent(Flow flow) {
-        boolean isPresent = false;
         // we are trying to find if there is a set-vlan-id action (OF1.0) action present in the flow.
         // If yes,then we would need to two flows
         if (flow.getInstructions() != null) {
@@ -384,14 +403,13 @@ public class FlowConvertor {
                     for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action :
                             applyActions.getAction()) {
                         if (action.getAction() instanceof SetVlanIdActionCase) {
-                            isPresent = true;
-                            break;
+                            return true;
                         }
                     }
                 }
             }
         }
-        return isPresent;
+        return false;
     }
 
 
@@ -405,11 +423,11 @@ public class FlowConvertor {
      * Â  Â  2) Match on (OFPVID_PRESENT) with mask (OFPVID_PRESENT ) + action [ set_field]
      */
     private static List<FlowModInputBuilder> handleSetVlanIdForOF13(Flow srcFlow, short version, BigInteger datapathId) {
-        List<FlowModInputBuilder> list = new ArrayList<>();
+        List<FlowModInputBuilder> list = new ArrayList<>(2);
 
-        VlanMatch srcVlanMatch = srcFlow.getMatch().getVlanMatch();
-        boolean hasVlanMatch = (srcFlow.getMatch() != null && srcVlanMatch != null);
-        if (hasVlanMatch) {
+        final Match srcMatch = Preconditions.checkNotNull(srcFlow.getMatch());
+        final VlanMatch srcVlanMatch = srcMatch.getVlanMatch();
+        if (srcVlanMatch != null) {
             //create flow with setfield and match
             // match on vlan tag or vlanid with no mask
             VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder(srcVlanMatch);
@@ -417,7 +435,7 @@ public class FlowConvertor {
             vlanIdBuilder.setVlanIdPresent(srcVlanMatch.getVlanId().isVlanIdPresent());
             vlanIdBuilder.setVlanId(srcVlanMatch.getVlanId().getVlanId());
             vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
-            Match match = new MatchBuilder(srcFlow.getMatch()).setVlanMatch(vlanMatchBuilder.build()).build();
+            Match match = new MatchBuilder(srcMatch).setVlanMatch(vlanMatchBuilder.build()).build();
 
             Optional<? extends Flow> optional = injectMatchToFlow(srcFlow, match);
             if (optional.isPresent()) {
@@ -427,12 +445,7 @@ public class FlowConvertor {
             // create 2 flows
             //flow 1
             // match on no vlan tag with no mask
-            VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
-            VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
-            vlanIdBuilder.setVlanIdPresent(false);
-            vlanIdBuilder.setVlanId(new VlanId(0));
-            vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
-            Match match1 = new MatchBuilder(srcFlow.getMatch()).setVlanMatch(vlanMatchBuilder.build()).build();
+            Match match1 = new MatchBuilder(srcMatch).setVlanMatch(VLAN_MATCH_FALSE).build();
 
             Optional<? extends Flow> optional1 = injectMatchAndAction(srcFlow, match1);
             if (optional1.isPresent()) {
@@ -441,12 +454,7 @@ public class FlowConvertor {
 
             //flow2
             // match on vlan tag with mask
-            VlanMatchBuilder vlanMatchBuilder2 = new VlanMatchBuilder();
-            VlanIdBuilder vlanIdBuilder2 = new VlanIdBuilder();
-            vlanIdBuilder2.setVlanIdPresent(true);
-            vlanIdBuilder2.setVlanId(new VlanId(0));
-            vlanMatchBuilder2.setVlanId(vlanIdBuilder2.build());
-            Match match2 = new MatchBuilder(srcFlow.getMatch()).setVlanMatch(vlanMatchBuilder2.build()).build();
+            Match match2 = new MatchBuilder(srcMatch).setVlanMatch(VLAN_MATCH_TRUE).build();
             Optional<? extends Flow> optional2 = injectMatchToFlow(srcFlow, match2);
             if (optional2.isPresent()) {
                 list.add(toFlowModInput(optional2.get(), version, datapathId));
index fd04f8c67f6271a0aa2fe8b21c54da17256b4a90..2e6a386204ac377cd50f7bd471235f418ecf12b6 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
-import java.util.HashMap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 import java.util.Map;
 
 /**
  * @author tkubas
  *
  */
-
 //TODO make a model in YANG for protocols 
 public enum IPProtocols {
     ICMP((short) 1), 
@@ -24,12 +24,13 @@ public enum IPProtocols {
 
     private short protocol;
     
-    private static Map<Short, IPProtocols> valueMap;
+    private static final Map<Short, IPProtocols> VALUE_MAP;
     static {
-        valueMap = new HashMap<>();
+        Builder<Short, IPProtocols> builder = ImmutableMap.builder();
         for(IPProtocols protocols : IPProtocols.values()) {
-            valueMap.put(protocols.protocol, protocols);
+            builder.put(protocols.protocol, protocols);
         }
+        VALUE_MAP = builder.build();
     }
     
     private IPProtocols(short value) {
@@ -37,6 +38,6 @@ public enum IPProtocols {
     }
 
     public static IPProtocols fromProtocolNum(Short protocolNum) {
-        return valueMap.get(protocolNum);
+        return VALUE_MAP.get(protocolNum);
     }
 }
index d4b5f55358f53268f6c85b8135d9b7609ca61b23..552c49c2b485b0be27e36bf21ebf432fb48f7737 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2015 Brocade, Communications Systems, Inc
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -15,14 +16,27 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
 import java.util.Iterator;
+import com.google.common.collect.Iterators;
+import java.util.Arrays;
+import java.net.UnknownHostException;
+import java.net.Inet6Address;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import com.google.common.net.InetAddresses;
+import com.google.common.base.Preconditions;
+
 
 /**
  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 5.3.2015.
+ * v6 routines added by Anton Ivanov on 14.6.2015
  */
 public final class IpConversionUtil {
 
     public static final String PREFIX_SEPARATOR = "/";
     public static final Splitter PREFIX_SPLITTER = Splitter.on('/');
+    final private static int INADDR4SZ = 4;
+    final private static int INADDR6SZ = 16;
+    final private static int INT16SZ = 2;
 
     private IpConversionUtil() {
         throw new IllegalStateException("This class should not be instantiated.");
@@ -33,37 +47,92 @@ public final class IpConversionUtil {
     }
 
     public static Iterator<String> splitToParts(final Ipv4Address ipv4Address) {
-        return PREFIX_SPLITTER.split(ipv4Address.getValue()).iterator();
+        /* Invalid (Ab)use of ip address as prefix!!! */
+        String [] tempPrefix = {ipv4Address.getValue(), "32"};
+        return Iterators.forArray(tempPrefix);
+    }
+
+    public static Iterator<String> splitToParts(final Ipv6Prefix ipv6Prefix) {
+        return PREFIX_SPLITTER.split(ipv6Prefix.getValue()).iterator();
     }
 
     public static Iterator<String> splitToParts(final Ipv6Address ipv6Address) {
-        return PREFIX_SPLITTER.split(ipv6Address.getValue()).iterator();
+        /* Invalid (Ab)use of ip address as prefix!!! */
+        String [] tempPrefix = {ipv6Address.getValue(), "128"};
+        return Iterators.forArray(tempPrefix);
     }
 
+
+    /* This forest of functions has a purpose:
+     *
+     * 1. There are multiple coding styles around the plugin, this is necessary in order to have
+     *   one mechanism to convert them all, one mechanism to find them...
+     * 2. I hope that one day yangtools will actually deliver code fit for purpose in a packet
+     *   processing application (presently it is not. When this happens, these can be optimized
+     *   for "side-load" of pre-vetted data. Example. IP Address (v4 or v6) is prevetted left of the
+     *   prefix. It should be loadable into Prefix without _RERUNNING_ 100ms+ of regexps. When (and if)
+     *   that happens, it will be a simple fix here without chasing it across the whole plugin.
+    */
+
     public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address){
-        Iterator<String> addressParts = splitToParts(ipv4Address);
-        String address = addressParts.next();
-        Ipv4Prefix retval = null;
-        if (addressParts.hasNext()) {
-            retval = new Ipv4Prefix(address + PREFIX_SEPARATOR + Integer.parseInt(addressParts.next()));
+        return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + 32);
+    }
+
+    public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address, String mask){
+        /* 
+         * Ipv4Address has already validated the address part of the prefix,
+         * It is mandated to comply to the same regexp as the address
+         * There is absolutely no point rerunning additional checks vs this
+         * Note - there is no canonical form check here!!!
+         */
+        if (null != mask && !mask.equals("")) {
+            return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + mask);
         } else {
-            retval = new Ipv4Prefix(address + PREFIX_SEPARATOR + 32);
+            return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + "32");
         }
-        return retval;
     }
-    public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address, String mask){
-        Iterator<String> addressParts = splitToParts(ipv4Address);
-        String address = addressParts.next();
-        Ipv4Prefix retval = null;
+
+    public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address, int intmask){
+        return createPrefix(ipv4Address, "" + intmask); 
+    }
+
+    public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address, byte [] bytemask){
+        return createPrefix(ipv4Address, "" + countBits(bytemask)); 
+    }
+
+    public static Ipv6Prefix createPrefix(Ipv6Address ipv6Address){
+        return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + 128);
+    }
+
+    public static Ipv6Prefix createPrefix(Ipv6Address ipv6Address, String mask){
+        /* 
+         * Ipv6Address has already validated the address part of the prefix,
+         * It is mandated to comply to the same regexp as the address
+         * There is absolutely no point rerunning additional checks vs this
+         * Note - there is no canonical form check here!!!
+         */
         if (null != mask && !mask.equals("")) {
-            retval = new Ipv4Prefix(address + mask);
+            return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + mask);
         } else {
-            retval = new Ipv4Prefix(address + PREFIX_SEPARATOR + 32);
+            return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + "128");
         }
-        return retval;
     }
-    public static Integer extractPrefix(Ipv4Address ipv4Address) {
-        Iterator<String> addressParts = splitToParts(ipv4Address);
+
+    public static Ipv6Prefix createPrefix(Ipv6Address ipv6Address, int intmask){
+        return createPrefix(ipv6Address, "" + intmask); 
+    }
+
+    public static Ipv6Prefix createPrefix(Ipv6Address ipv6Address, byte [] bytemask){
+        /* 
+         * Ipv4Address has already validated the address part of the prefix,
+         * It is mandated to comply to the same regexp as the address
+         * There is absolutely no point rerunning additional checks vs this
+         * Note - there is no canonical form check here!!!
+         */
+         return createPrefix(ipv6Address, "" + countBits(bytemask)); 
+    }
+    public static Integer extractPrefix(Ipv4Prefix ipv4Prefix) {
+        Iterator<String> addressParts = splitToParts(ipv4Prefix);
         addressParts.next();
         Integer retval = null;
         if (addressParts.hasNext()) {
@@ -71,8 +140,9 @@ public final class IpConversionUtil {
         }
         return retval;
     }
-    public static Integer extractPrefix(Ipv6Address ipv6Address) {
-        Iterator<String> addressParts = splitToParts(ipv6Address);
+
+    public static Integer extractPrefix(Ipv6Prefix ipv6Prefix) {
+        Iterator<String> addressParts = splitToParts(ipv6Prefix);
         addressParts.next();
         Integer retval = null;
         if (addressParts.hasNext()) {
@@ -81,22 +151,412 @@ public final class IpConversionUtil {
         return retval;
     }
 
+    public static Integer extractPrefix(Ipv4Address ipv4Prefix) {
+        return 32;
+    }
 
-    public static byte[] convertIpv6PrefixToByteArray(final int prefix) {
-        // TODO: Temporary fix. Has performance impacts.
-        byte[] mask = new byte[16];
-        int oneCount = prefix;
-        for (int count = 0; count < 16; count++) {
-            int byteBits = 0;
-            if (oneCount >= 8) {
-                byteBits = 8;
-                oneCount = oneCount - 8;
-            } else {
-                byteBits = oneCount;
-                oneCount = 0;
+    public static Integer extractPrefix(Ipv6Address ipv6Prefix) {
+        return 128;
+    }
+
+    /*
+     * BIG FAT WARNING!!!
+     * Read all of the following before you touch any v6 code or decide to
+     * optimize it by invoking a "simple" Guava call
+     *
+     * Java IPv6 is fundamentally broken and Google libraries do not fix it.
+     * 1. Java will allways implicitly rewrite v4 mapped into v6 as a v4 address
+     *      and there is absolutely no way to override this behaviour
+     * 2. Guava libraries cannot parse non-canonical IPv6. They will throw an
+     *      exception. Even if they did, they re-use the same broken java code
+     *      underneath.
+     *
+     * This is why we have to parse v6 by ourselves.
+     *
+     * The following conversion code is based on inet_cidr_pton_ipv6 in NetBSD
+     *
+     * The original BSD code is licensed under standard BSD license. While we
+     * are not obliged to provide an attribution, credit where credit is due.
+     * As far as why it is similar to Sun's sun.net.util please ask Sun why
+     * their code has the same variable names, comments and code flow.
+     *
+     */
+
+
+     /**
+     * Convert Ipv6Address object to a valid Canonical v6 address in byte format
+     *
+     * @param ipv6Address - v6 Address object
+     * @return - byte array of size 16. Last byte contains netmask
+     */
+
+
+    public static byte[] canonicalBinaryV6Address(Ipv6Address ipv6Address) {
+        /* 
+         * Do not modify this routine to take direct strings input!!!
+         * Key checks have been removed based on the assumption that
+         * the input is validated via regexps in Ipv6Prefix()
+         */
+
+        String [] address =  (ipv6Address.getValue()).split("%");
+
+        int colonp;
+        char ch;
+        boolean saw_xdigit;
+
+        /* Isn't it fun - the above variable names are the same in BSD and Sun sources */
+
+        int val;
+
+        char[] src = address[0].toCharArray();
+
+        byte[] dst = new byte[INADDR6SZ];
+
+        int src_length = src.length;
+
+        colonp = -1;
+        int i = 0, j = 0;
+
+        /* Leading :: requires some special handling. */
+
+        /* Isn't it fun - the above comment is again the same in BSD and Sun sources,
+         * We will derive our code from BSD. Shakespear always sounds better
+         * in original Clingon. So does Dilbert.
+         */
+
+        if (src[i] == ':') {
+            Preconditions.checkArgument(src[++i] == ':', "Invalid v6 address");
+        }
+
+        int curtok = i;
+        saw_xdigit = false;
+
+
+        val = 0;
+        while (i < src_length) {
+            ch = src[i++];
+            int chval = Character.digit(ch, 16);
+
+            /* Business as usual - ipv6 address digit.
+             * We can remove all checks from the original BSD code because
+             * the regexp has already verified that we are not being fed
+             * anything bigger than 0xffff between the separators.
+             */
+
+            if (chval != -1) {
+                val <<= 4;
+                val |= chval;
+                saw_xdigit = true;
+                continue;
+            }
+
+            /* v6 separator */
+
+            if (ch == ':') {
+                curtok = i;
+                if (!saw_xdigit) {
+                    /* no need to check separator position validity - regexp does that */
+                    colonp = j;
+                    continue;
+                }
+
+                /* removed overrun check - the regexp checks for valid data */
+
+                dst[j++] = (byte) ((val >> 8) & 0xff);
+                dst[j++] = (byte) (val & 0xff);
+                saw_xdigit = false;
+                val = 0;
+                continue;
             }
 
-            mask[count] = (byte) (256 - Math.pow(2, 8 - byteBits));
+            /* frankenstein - v4 attached to v6, mixed notation */
+
+            if (ch == '.' && ((j + INADDR4SZ) <= INADDR6SZ)) {
+
+                /* this has passed the regexp so it is fairly safe to parse it
+                 * straight away. As v4 addresses do not suffer from the same
+                 * defficiencies as the java v6 implementation we can invoke it
+                 * straight away and be done with it
+                 */
+
+                Preconditions.checkArgument(j != (INADDR6SZ - INADDR4SZ - 1), "Invalid v4 in v6 mapping");
+
+                InetAddress _inet_form = InetAddresses.forString(address[0].substring(curtok, src_length));
+
+                Preconditions.checkArgument(_inet_form instanceof Inet4Address);
+
+                byte[] v4addr =  _inet_form.getAddress();
+
+                for (int k = 0; k < INADDR4SZ; k++) {
+                    dst[j++] = v4addr[k];
+                }
+                saw_xdigit = false;
+                break;
+            }
+            /* removed parser exit on ivalid char - no need to do it, regexp checks it */
+        }
+        if (saw_xdigit) {
+            Preconditions.checkArgument(j + INT16SZ <= INADDR6SZ, "Overrun in v6 parsing, should not occur");
+            dst[j++] = (byte) ((val >> 8) & 0xff);
+            dst[j++] = (byte) (val & 0xff);
+        }
+
+        if (colonp != -1) {
+            int n = j - colonp;
+
+            Preconditions.checkArgument(j != INADDR6SZ, "Overrun in v6 parsing, should not occur");
+            for (i = 1; i <= n; i++) {
+                dst[INADDR6SZ - i] = dst[colonp + n - i];
+                dst[colonp + n - i] = 0;
+            }
+            j = INADDR6SZ;
+        }
+
+        Preconditions.checkArgument(j == INADDR6SZ, "Overrun in v6 parsing, should not occur");
+
+        return dst;
+    }
+
+    static public String byteArrayV6AddressToString (byte [] _binary_form) throws UnknownHostException{
+        /* DO NOT DIY!!! - InetAddresses will actually print correct canonical
+         * zero compressed form. 
+         */
+        return InetAddresses.toAddrString(InetAddress.getByAddress(_binary_form));
+    }
+    
+
+    static private int nextNibble(int mask) {
+        if (mask <= 0) {
+            return 0;
+        }
+        if (mask > 8) {
+            return 0xff;
+        }
+        return 0xff << (8 - mask);
+    }
+
+     /**
+     * Convert Ipv6Prefix object to a valid Canonical v6 prefix in byte format
+     *
+     * @param ipv6Prefix - v6 prefix object
+     * @return - byte array of size 16 + 1. Last byte contains netmask
+     */
+
+
+    public static byte[] canonicalBinaryV6Prefix(Ipv6Prefix ipv6Prefix) {
+        /* 
+         * Do not modify this routine to take direct strings input!!!
+         * Key checks have been removed based on the assumption that
+         * the input is validated via regexps in Ipv6Prefix()
+         */
+
+        int mask = 128;
+
+        String [] address = null; 
+
+        boolean valid = true;
+
+        address =  (ipv6Prefix.getValue()).split("/");
+        try {
+            mask = Integer.parseInt(address[1]);
+            if (mask > 128) {
+                valid = false;
+            }
+        } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
+            valid = false;
+        }
+
+        Preconditions.checkArgument(valid, "Supplied netmask in %s is invalid", ipv6Prefix.getValue());
+
+    
+        int colonp;
+        char ch;
+        boolean saw_xdigit;
+
+        /* Isn't it fun - the above variable names are the same in BSD and Sun sources */
+
+        int val;
+
+        char[] src = address[0].toCharArray();
+
+        byte[] dst = new byte[INADDR6SZ + 1];
+
+        int m = mask;
+
+        int src_length = src.length;
+
+        colonp = -1;
+        int i = 0, j = 0;
+
+        /* Leading :: requires some special handling. */
+
+        /* Isn't it fun - the above comment is again the same in BSD and Sun sources,
+         * We will derive our code from BSD. Shakespear always sounds better
+         * in original Clingon. So does Dilbert.
+         */
+
+        if (src[i] == ':') {
+            Preconditions.checkArgument(src[++i] == ':', "Invalid v6 address");
+        }
+
+        int curtok = i;
+        saw_xdigit = false;
+
+
+        val = 0;
+        while (i < src_length) {
+            ch = src[i++];
+            int chval = Character.digit(ch, 16);
+
+            /* Business as usual - ipv6 address digit.
+             * We can remove all checks from the original BSD code because
+             * the regexp has already verified that we are not being fed
+             * anything bigger than 0xffff between the separators.
+             */
+
+            if (chval != -1) {
+                val <<= 4;
+                val |= chval;
+                saw_xdigit = true;
+                continue;
+            }
+
+            /* v6 separator */
+
+            if (ch == ':') {
+                curtok = i;
+                if (!saw_xdigit) {
+                    /* no need to check separator position validity - regexp does that */
+                    colonp = j;
+                    continue;
+                }
+
+                /* removed overrun check - the regexp checks for valid data */
+
+                saw_xdigit = false;
+
+                if (m < 0) {
+                    /* stop parsing if we are past the mask */
+                    break;
+                }
+
+                dst[j] = (byte) ((val >> 8) & nextNibble(m)); j++; m = m - 8;
+
+                if (m < 0) {
+                    /* stop parsing if we are past the mask */
+                    break;
+                }
+
+                dst[j] = (byte) (val & nextNibble(m)); j++; m = m - 8;
+
+                val = 0;
+                continue;
+            }
+
+            /* frankenstein - v4 attached to v6, mixed notation */
+
+            if (ch == '.' && ((j + INADDR4SZ) <= INADDR6SZ)) {
+
+                /* this has passed the regexp so it is fairly safe to parse it
+                 * straight away. As v4 addresses do not suffer from the same
+                 * defficiencies as the java v6 implementation we can invoke it
+                 * straight away and be done with it
+                 */
+
+                Preconditions.checkArgument(j != (INADDR6SZ - INADDR4SZ - 1), "Invalid v4 in v6 mapping");
+
+                InetAddress _inet_form = InetAddresses.forString(address[0].substring(curtok, src_length));
+
+                Preconditions.checkArgument(_inet_form instanceof Inet4Address);
+
+                byte[] v4addr =  _inet_form.getAddress();
+
+                for (int k = 0; k < INADDR4SZ; k++) {
+                    dst[j++] = v4addr[k];
+                }
+                saw_xdigit = false;
+                break;
+            }
+            /* removed parser exit on ivalid char - no need to do it, regexp checks it */
+        }
+        if (saw_xdigit) {
+            Preconditions.checkArgument(j + INT16SZ <= INADDR6SZ, "Overrun in v6 parsing, should not occur");
+            dst[j] = (byte) ((val >> 8) & nextNibble(m)) ; j++; m = m - 8;
+            dst[j] = (byte) (val & nextNibble(m)); j++; m = m - 8;
+        }
+
+        if ((j < INADDR6SZ) && (m < 0)) {
+            /* past the mask */
+            for (i = j; i < INADDR6SZ; i++) {
+                dst[i] = 0;
+            }
+        } else {
+            /* normal parsing */
+            if (colonp != -1) {
+                int n = j - colonp;
+
+                Preconditions.checkArgument(j != INADDR6SZ, "Overrun in v6 parsing, should not occur");
+                for (i = 1; i <= n; i++) {
+                    dst[INADDR6SZ - i] = dst[colonp + n - i];
+                    dst[colonp + n - i] = 0;
+                }
+                j = INADDR6SZ;
+            }
+            Preconditions.checkArgument(j == INADDR6SZ, "Overrun in v6 parsing, should not occur");
+        }
+
+        dst[INADDR6SZ] = (byte) mask;
+        return dst;
+    }
+
+     /**
+     * Print a v6 prefix in byte array + 1 notation
+     *
+     * @param _binary_form - prefix, in byte [] form, last byte is netmask
+     */
+
+
+    static public String byteArrayV6PrefixToString(byte [] _binary_form) throws UnknownHostException {
+        /* NO DIY!!! - InetAddresses will actually print correct canonical
+         * zero compressed form
+         */
+        StringBuilder sb = new java.lang.StringBuilder();
+        /* Yang RFC specifies that the normalized form is RFC 5952, note - java
+         * core type is not RFC compliant, guava is.
+         */
+        sb.append(
+            InetAddresses.toAddrString(
+                InetAddress.getByAddress(
+                    Arrays.copyOfRange(_binary_form, 0, INADDR6SZ)
+                )
+            )
+        );
+        sb.append("/");
+        sb.append(_binary_form[INADDR6SZ] & 0xff);
+        return sb.toString();
+    }
+
+
+     /**
+     * Canonicalize a v6 prefix while in binary form
+     *
+     * @param _prefix - prefix, in byte [] form
+     * @param mask - mask - number of bits
+     */
+
+    static public void canonicalizeIpv6Prefix(byte [] _prefix, int mask) {
+
+        for (int i=0; i < INADDR6SZ; i++) {
+            _prefix[i] = (byte) (_prefix[i] & nextNibble(mask));
+            mask = mask - 8;
+        }
+    }
+
+    public static byte[] convertIpv6PrefixToByteArray(int prefix) {
+        byte[] mask = new byte[16];
+        for (int count = 0; count < 16; count++) {
+            mask[count] = (byte) nextNibble(prefix);
+            prefix = prefix - 8;
         }
         return mask;
     }
@@ -117,5 +577,18 @@ public final class IpConversionUtil {
         return prefix;
     }
 
+    private static int toInt(byte b) {
+        return b < 0 ? b + 256 : b;
+    }
+
+    public static int countBits(byte[] mask) {
+        int netmask = 0;
+        for (byte b : mask) {
+            netmask += Integer.bitCount(toInt(b));
+        }
+        return netmask;
+    }
+
+
 
 }
index 264accc8da77029e5fdfc5e93517d8139e36c14f..40f95762f302ab316ac38ff8d8da9193cad567b4 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 import com.google.common.collect.Ordering;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
@@ -139,7 +141,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -149,6 +150,8 @@ import java.util.Map;
  */
 public class TableFeaturesConvertor {
     private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesConvertor.class);
+    private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> TABLE_FEATURE_PROPS_ORDERING =
+            Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>build());
 
     private TableFeaturesConvertor() {
         //hiding implicit construcotr
@@ -182,9 +185,7 @@ public class TableFeaturesConvertor {
         List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
 
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>
-                sortedTableProperties =
-                Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>build())
-                        .sortedCopy(tableProperties.getTableFeatureProperties());
+                sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(tableProperties.getTableFeatureProperties());
 
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties
                 property : sortedTableProperties) {
@@ -509,51 +510,53 @@ public class TableFeaturesConvertor {
         builder.addAugmentation(ActionRelatedTableFeatureProperty.class, propBuilder.build());
     }
 
-    private static Map<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES = new HashMap<>();
+    private static final Map<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES;
 
     static {
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class, ArpOp.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class, ArpSha.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class, ArpSpa.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class, ArpTha.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class, ArpTpa.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class, EthDst.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class, EthSrc.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class, EthType.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class, Icmpv4Code.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class, Icmpv4Type.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class, Icmpv6Code.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class, Icmpv6Type.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class, InPhyPort.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class, InPort.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class, IpDscp.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class, IpEcn.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class, IpProto.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class, Ipv4Dst.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class, Ipv4Src.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class, Ipv6Dst.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class, Ipv6Exthdr.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class, Ipv6Flabel.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class, Ipv6NdSll.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class, Ipv6NdTarget.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class, Ipv6NdTll.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class, Ipv6Src.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class, Metadata.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class, MplsBos.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class, MplsLabel.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class, MplsTc.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class, PbbIsid.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class, SctpDst.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class, SctpSrc.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class, TcpDst.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class, TcpSrc.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class, TunnelId.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpDst.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpSrc.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class, VlanPcp.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class, VlanVid.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class, Ipv4Dst.class);
-        SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class, Ipv4Src.class);
+        Builder<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> builder = ImmutableMap.builder();
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class, ArpOp.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class, ArpSha.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class, ArpSpa.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class, ArpTha.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class, ArpTpa.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class, EthDst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class, EthSrc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class, EthType.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class, Icmpv4Code.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class, Icmpv4Type.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class, Icmpv6Code.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class, Icmpv6Type.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class, InPhyPort.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class, InPort.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class, IpDscp.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class, IpEcn.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class, IpProto.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class, Ipv4Dst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class, Ipv4Src.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class, Ipv6Dst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class, Ipv6Exthdr.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class, Ipv6Flabel.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class, Ipv6NdSll.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class, Ipv6NdTarget.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class, Ipv6NdTll.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class, Ipv6Src.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class, Metadata.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class, MplsBos.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class, MplsLabel.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class, MplsTc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class, PbbIsid.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class, SctpDst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class, SctpSrc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class, TcpDst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class, TcpSrc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class, TunnelId.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpDst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class, UdpSrc.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class, VlanPcp.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class, VlanVid.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class, Ipv4Dst.class);
+        builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class, Ipv4Src.class);
+        SAL_TO_OF_TABLE_FEATURES = builder.build();
     }
 
     private static void setSetFieldTableFeatureProperty(
index f33a4a413814dc18604b6785cd6436a3660e4bf6..36e689a6474a544e29d2f36af78a7b4963b6989e 100644 (file)
@@ -8,10 +8,11 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.opendaylight.openflowplugin.api.OFConstants;
@@ -181,11 +182,12 @@ public class TableFeaturesReplyConvertor {
         return salTableFeaturesList;
     }
 
-    private static final Map<TableFeaturesPropType, ActionExecutor> TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION = new HashMap<>();
+    private static final Map<TableFeaturesPropType, ActionExecutor> TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION;
 
     static {
+        final Builder<TableFeaturesPropType, ActionExecutor> builder = ImmutableMap.builder();
 
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -196,7 +198,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(instructionBuilder.build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -207,7 +209,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTNEXTTABLES, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLES, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -218,7 +220,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(nextTableBuilder.build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -229,7 +231,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWRITEACTIONS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -240,7 +242,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -251,7 +253,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -262,7 +264,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -273,7 +275,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTMATCH, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTMATCH, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -283,7 +285,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(new MatchBuilder().setMatchSetfield(matchBuilder.build()).build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWILDCARDS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTWILDCARDS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -292,7 +294,7 @@ public class TableFeaturesReplyConvertor {
                 propBuilder.setTableFeaturePropType(new WildcardsBuilder().setWildcardSetfield(wildcardsBuilder.build()).build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWRITESETFIELD, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELD, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -302,7 +304,7 @@ public class TableFeaturesReplyConvertor {
                         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder().setWriteSetfield(writeSetfieldBuilder.build()).build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -312,7 +314,7 @@ public class TableFeaturesReplyConvertor {
                         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder().setWriteSetfieldMiss(writeSetfieldMissBuilder.build()).build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -322,7 +324,7 @@ public class TableFeaturesReplyConvertor {
                         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder().setApplySetfield(applySetfieldBuilder.build()).build());
             }
         });
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -333,7 +335,7 @@ public class TableFeaturesReplyConvertor {
             }
         });
 
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTEXPERIMENTER, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTER, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -341,7 +343,7 @@ public class TableFeaturesReplyConvertor {
             }
         });
 
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, new ActionExecutor() {
 
             @Override
             public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
@@ -349,6 +351,8 @@ public class TableFeaturesReplyConvertor {
             }
         });
 
+        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION = builder.build();
+
     }
 
     private static TableProperties toTableProperties(final List<TableFeatureProperties> ofTablePropertiesList) {
@@ -429,28 +433,31 @@ public class TableFeaturesReplyConvertor {
         return nextTableIdsList;
     }
 
-    private static final Map<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> OF_TO_SAL_ACTION = new HashMap<>();
+    private static final Map<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> OF_TO_SAL_ACTION;
 
     static {
-
-        OF_TO_SAL_ACTION.put(OutputActionCase.class, new OutputActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(GroupCase.class, new GroupActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(CopyTtlOutCase.class, new CopyTtlOutCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(CopyTtlInCase.class, new CopyTtlInCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(SetMplsTtlCase.class, new SetMplsTtlActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(DecMplsTtlCase.class, new DecMplsTtlCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(PushVlanCase.class, new PushVlanActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(PopVlanCase.class, new PopVlanActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(PushMplsCase.class, new PushMplsActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(PopMplsCase.class, new PopMplsActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(SetQueueCase.class, new SetQueueActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(SetNwTtlCase.class, new SetNwTtlActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(DecNwTtlCase.class, new DecNwTtlCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(SetFieldCase.class, new SetFieldCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(PushPbbCase.class, new PushPbbActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(PopPbbCase.class, new PopPbbActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(SetNwSrcCase.class, new SetNwSrcActionCaseBuilder().build());
-        OF_TO_SAL_ACTION.put(SetNwDstCase.class, new SetNwDstActionCaseBuilder().build());
+        Builder<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> builder = ImmutableMap.builder();
+
+        builder.put(OutputActionCase.class, new OutputActionCaseBuilder().build());
+        builder.put(GroupCase.class, new GroupActionCaseBuilder().build());
+        builder.put(CopyTtlOutCase.class, new CopyTtlOutCaseBuilder().build());
+        builder.put(CopyTtlInCase.class, new CopyTtlInCaseBuilder().build());
+        builder.put(SetMplsTtlCase.class, new SetMplsTtlActionCaseBuilder().build());
+        builder.put(DecMplsTtlCase.class, new DecMplsTtlCaseBuilder().build());
+        builder.put(PushVlanCase.class, new PushVlanActionCaseBuilder().build());
+        builder.put(PopVlanCase.class, new PopVlanActionCaseBuilder().build());
+        builder.put(PushMplsCase.class, new PushMplsActionCaseBuilder().build());
+        builder.put(PopMplsCase.class, new PopMplsActionCaseBuilder().build());
+        builder.put(SetQueueCase.class, new SetQueueActionCaseBuilder().build());
+        builder.put(SetNwTtlCase.class, new SetNwTtlActionCaseBuilder().build());
+        builder.put(DecNwTtlCase.class, new DecNwTtlCaseBuilder().build());
+        builder.put(SetFieldCase.class, new SetFieldCaseBuilder().build());
+        builder.put(PushPbbCase.class, new PushPbbActionCaseBuilder().build());
+        builder.put(PopPbbCase.class, new PopPbbActionCaseBuilder().build());
+        builder.put(SetNwSrcCase.class, new SetNwSrcActionCaseBuilder().build());
+        builder.put(SetNwDstCase.class, new SetNwDstActionCaseBuilder().build());
+
+        OF_TO_SAL_ACTION = builder.build();
     }
 
     private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> setActionTableFeatureProperty(
@@ -473,49 +480,53 @@ public class TableFeaturesReplyConvertor {
         return actionList;
     }
 
-    private static final Map<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> OF_TO_SAL_TABLE_FEATURE_PROPERTIES = new HashMap<>();
+    private static final Map<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> OF_TO_SAL_TABLE_FEATURE_PROPERTIES;
 
     static {
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpOp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpSha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpSpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpTha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpTpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(EthDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(EthSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(EthType.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Icmpv4Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Icmpv4Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Icmpv6Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Icmpv6Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(InPhyPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(InPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(IpDscp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(IpEcn.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(IpProto.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv4Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv4Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6Exthdr.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6Flabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6NdSll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6NdTarget.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6NdTll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Metadata.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(MplsBos.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(MplsLabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(MplsTc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(PbbIsid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(SctpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(SctpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(TcpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(TcpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(TunnelId.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(UdpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(UdpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(VlanPcp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(VlanVid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
+        final Builder<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> builder = ImmutableMap.builder();
+
+        builder.put(ArpOp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
+        builder.put(ArpSha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
+        builder.put(ArpSpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
+        builder.put(ArpTha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
+        builder.put(ArpTpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
+        builder.put(EthDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
+        builder.put(EthSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
+        builder.put(EthType.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
+        builder.put(Icmpv4Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
+        builder.put(Icmpv4Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
+        builder.put(Icmpv6Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
+        builder.put(Icmpv6Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
+        builder.put(InPhyPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
+        builder.put(InPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
+        builder.put(IpDscp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
+        builder.put(IpEcn.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
+        builder.put(IpProto.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
+        builder.put(Ipv4Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
+        builder.put(Ipv4Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
+        builder.put(Ipv6Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
+        builder.put(Ipv6Exthdr.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
+        builder.put(Ipv6Flabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
+        builder.put(Ipv6NdSll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
+        builder.put(Ipv6NdTarget.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
+        builder.put(Ipv6NdTll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
+        builder.put(Ipv6Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
+        builder.put(Metadata.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
+        builder.put(MplsBos.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
+        builder.put(MplsLabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
+        builder.put(MplsTc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
+        builder.put(PbbIsid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
+        builder.put(SctpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
+        builder.put(SctpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
+        builder.put(TcpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
+        builder.put(TcpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
+        builder.put(TunnelId.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
+        builder.put(UdpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
+        builder.put(UdpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
+        builder.put(VlanPcp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
+        builder.put(VlanVid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
+
+        OF_TO_SAL_TABLE_FEATURE_PROPERTIES = builder.build();
     }
 
     private static List<SetFieldMatch> setSetFieldTableFeatureProperty(final TableFeatureProperties properties,
@@ -540,4 +551,4 @@ public class TableFeaturesReplyConvertor {
         return setFieldMatchList;
     }
 
-}
\ No newline at end of file
+}
index 7b78bb320531c586530dc633a4ecb34050180b6f..297522943f3330a89bb1f395b6ca9094ba812370 100644 (file)
@@ -1,7 +1,6 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Ordered;
-
 import java.util.Comparator;
 
 /**
@@ -11,9 +10,12 @@ import java.util.Comparator;
  */
 public class OrderComparator<T extends Ordered> implements Comparator<T> {
 
-    private static OrderComparator instance = new OrderComparator();
-    public static OrderComparator build() {
-        return instance;
+    @SuppressWarnings("rawtypes")
+    private static final OrderComparator INSTANCE = new OrderComparator();
+
+    @SuppressWarnings("unchecked")
+    public static <T extends Ordered> OrderComparator<T> build() {
+        return INSTANCE;
     }
 
     @Override
index 442e94910a40d816c9d74cd31ec2f85f01122b12..ad03deda13ad5dd9af017d272f993025a69eb507 100644 (file)
@@ -1281,9 +1281,9 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
             } else if (ofMatch.getOxmMatchField().equals(ArpSpa.class)) {
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpa arpSpa = ((ArpSpaCase) ofMatch.getMatchEntryValue()).getArpSpa();
                 if (arpSpa != null) {
-                    String mask ="";
+                    int mask = 32;
                     if (null != arpSpa.getMask()){
-                        mask = MatchConvertorUtil.getIpv4Mask(arpSpa.getMask());
+                        mask = IpConversionUtil.countBits(arpSpa.getMask());
                     }
                     Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpSpa.getIpv4Address(), mask);
                     arpMatchBuilder.setArpSourceTransportAddress(ipv4Prefix);
@@ -1292,9 +1292,9 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
             } else if (ofMatch.getOxmMatchField().equals(ArpTpa.class)) {
                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpa arpTpa = ((ArpTpaCase) ofMatch.getMatchEntryValue()).getArpTpa();
                 if (arpTpa != null) {
-                    String mask ="";
+                    int mask = 32;
                     if (null != arpTpa.getMask()){
-                        mask = MatchConvertorUtil.getIpv4Mask(arpTpa.getMask());
+                        mask = IpConversionUtil.countBits(arpTpa.getMask());
                     }
                     Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpTpa.getIpv4Address(), mask);
 
@@ -1445,35 +1445,38 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
     }
 
     private static void setIpv6MatchBuilderFields(final Ipv6MatchBuilder ipv6MatchBuilder, final MatchEntry ofMatch, String ipv6PrefixStr, final byte[] mask) {
+        Ipv6Prefix ipv6Prefix;
+
         if (mask != null) {
-            ipv6PrefixStr += IpConversionUtil.PREFIX_SEPARATOR
-                    + MatchConvertorUtil.ipv6NetmaskArrayToCIDRValue(mask);
+            ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr), mask);
+        } else {
+            ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr));
         }
 
         if (ofMatch.getOxmMatchField().equals(Ipv6Src.class)) {
-            ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix(ipv6PrefixStr));
+            ipv6MatchBuilder.setIpv6Source(ipv6Prefix);
         }
         if (ofMatch.getOxmMatchField().equals(Ipv6Dst.class)) {
-            ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix(ipv6PrefixStr));
+            ipv6MatchBuilder.setIpv6Destination(ipv6Prefix);
         }
     }
 
     private static void setIpv4MatchBuilderFields(final Ipv4MatchBuilder ipv4MatchBuilder, final MatchEntry ofMatch, final byte[] mask, String ipv4PrefixStr) {
+        Ipv4Prefix ipv4Prefix;
         if (mask != null) {
-            ipv4PrefixStr += MatchConvertorUtil.getIpv4Mask(mask);
+            ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr), mask);
         } else {
             //Openflow Spec : 1.3.2
             //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
             // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
             // statistics response.
-
-            ipv4PrefixStr += IpConversionUtil.PREFIX_SEPARATOR + "32";
+            ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr));
         }
         if (ofMatch.getOxmMatchField().equals(Ipv4Src.class)) {
-            ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(ipv4PrefixStr));
+            ipv4MatchBuilder.setIpv4Source(ipv4Prefix);
         }
         if (ofMatch.getOxmMatchField().equals(Ipv4Dst.class)) {
-            ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(ipv4PrefixStr));
+            ipv4MatchBuilder.setIpv4Destination(ipv4Prefix);
         }
     }
 
index 19ce2c040846f0b49dfa6b0de360a752bb85a0fb..73c10b526a5a80d04ca451d556ddf04fb63b44a9 100644 (file)
@@ -18,28 +18,6 @@ public abstract class MatchConvertorUtil {
 
     private static final String PREFIX_SEPARATOR = "/";
 
-    /**
-     * @param maskEntry
-     * @return subnetwork suffix in form of "/"+&lt;mask value {0..32}&gt;
-     */
-    public static String getIpv4Mask(byte[] maskEntry) {
-        int receivedMask = ByteBuffer.wrap(maskEntry).getInt();
-        int shiftCount = 0;
-
-        if (receivedMask == 0) {
-            shiftCount = 32;
-        } else {
-            while (receivedMask != 0xffffffff) {
-                receivedMask = receivedMask >> 1;
-                shiftCount++;
-                if (shiftCount >= 32) {
-                    throw new IllegalArgumentException("given mask is invalid: " + Arrays.toString(maskEntry));
-                }
-            }
-        }
-        return PREFIX_SEPARATOR + (32 - shiftCount);
-    }
-
     /**
      * @param pField
      * @return integer containing lower 9 bits filled with corresponding flags
@@ -58,44 +36,4 @@ public abstract class MatchConvertorUtil {
         return bitmap;
     }
 
-    public static int ipv6NetmaskArrayToCIDRValue(byte[] rawMask) {
-
-        /*
-         * Openflow Spec : 1.3.2+
-         * An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
-         * So when user specify 128 as a mask, switch omit that mask and we get null as a mask in flow
-         * statistics response.
-         */
-
-        int maskValue = 128;
-
-        if (rawMask != null) {
-            maskValue = 0;
-            for (int subArrayCounter = 0; subArrayCounter < 4; subArrayCounter++) {
-                int copyFrom = subArrayCounter * 4;
-
-                byte[] subArray = Arrays.copyOfRange(rawMask, copyFrom, copyFrom + 4);
-
-                int receivedMask = ByteBuffer.wrap(subArray).getInt();
-
-                int shiftCount = 0;
-
-                if (receivedMask == 0) {
-                    break;
-                }
-
-                while (receivedMask != 0xffffffff) {
-                    receivedMask = receivedMask >> 1;
-                    shiftCount++;
-                }
-
-                maskValue = maskValue + (32 - shiftCount);
-                if (shiftCount != 0) {
-                    break;
-                }
-            }
-        }
-        return maskValue;
-    }
-
 }
index abb5ea0698ddb4fb5b30c57fbb590cfa18a6119f..9775d01afaab0279c020bfa1cbe5af5614efa397 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
  */
 public class MatchReactor extends ConvertReactor<Match> {
 
-    private static MatchReactor INSTANCE = new MatchReactor();
+    private static final MatchReactor INSTANCE = new MatchReactor();
 
     private MatchReactor() {
         //NOOP
index 0b7ee065cdbdc4ed8c040d65fac00e0d7bf9bdcd..aa7fdbf12f9c6bc0feac08530cb69c5c283bc9fe 100644 (file)
@@ -156,6 +156,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Tunne
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
 
 public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
 
@@ -371,29 +372,27 @@ public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, Lis
                 }
                 if (field.equals(Ipv4Src.class)) {
                     Ipv4SrcCase ipv4SrcCase = ((Ipv4SrcCase) entry.getMatchEntryValue());
-                    Ipv4Address ipv4Address = ipv4SrcCase.getIpv4Src().getIpv4Address();
-                    String ipAddressString = ipv4Address.getValue();
-                    String prefix = "";
+                    int prefix;
                     if (entry.isHasMask()) {
-                        byte[] mask = ipv4SrcCase.getIpv4Src().getMask();
-                        prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+                        prefix = IpConversionUtil.countBits(ipv4SrcCase.getIpv4Src().getMask());
                     } else {
-                        prefix += PREFIX_SEPARATOR + "32";
+                        prefix = 32;
                     }
-                    ipv4Match.setIpv4Source(createIpv4Prefix(ipAddressString, prefix));
+                    ipv4Match.setIpv4Source(
+                        IpConversionUtil.createPrefix(ipv4SrcCase.getIpv4Src().getIpv4Address(), prefix)
+                    );
 
                 } else if (field.equals(Ipv4Dst.class)) {
                     Ipv4DstCase ipv4DstCase = ((Ipv4DstCase) entry.getMatchEntryValue());
-                    Ipv4Address ipv4Address = ipv4DstCase.getIpv4Dst().getIpv4Address();
-                    String ipAddressString = ipv4Address.getValue();
-                    String prefix = "";
+                    int prefix;
                     if (entry.isHasMask()) {
-                        byte[] mask = ipv4DstCase.getIpv4Dst().getMask();
-                        prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+                        prefix = IpConversionUtil.countBits(ipv4DstCase.getIpv4Dst().getMask());
                     } else {
-                        prefix += PREFIX_SEPARATOR + "32";
+                        prefix = 32;
                     }
-                    ipv4Match.setIpv4Destination(createIpv4Prefix(ipAddressString, prefix));
+                    ipv4Match.setIpv4Destination(
+                        IpConversionUtil.createPrefix(ipv4DstCase.getIpv4Dst().getIpv4Address(), prefix)
+                    );
                 }
             } else if (field.equals(ArpOp.class) || field.equals(ArpSpa.class) || field.equals(ArpTpa.class)
                     || field.equals(ArpSha.class) || field.equals(ArpTha.class)) {
@@ -406,30 +405,27 @@ public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, Lis
                 } else if (field.equals(ArpSpa.class)) {
 
                     ArpSpaCase arpSpaCase = ((ArpSpaCase) entry.getMatchEntryValue());
-                    Ipv4Address ipv4Address = arpSpaCase.getArpSpa().getIpv4Address();
-                    String ipAddressString = ipv4Address.getValue();
-                    String prefix = "";
+                    int prefix;
                     if (entry.isHasMask()) {
-                        byte[] mask = arpSpaCase.getArpSpa().getMask();
-                        prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+                        prefix = IpConversionUtil.countBits(arpSpaCase.getArpSpa().getMask());
                     } else {
-                        prefix += PREFIX_SEPARATOR + "32";
+                        prefix = 32;
                     }
-
-                    arpMatch.setArpSourceTransportAddress(createIpv4Prefix(ipAddressString, prefix));
+                    arpMatch.setArpSourceTransportAddress(
+                        IpConversionUtil.createPrefix(arpSpaCase.getArpSpa().getIpv4Address(), prefix)
+                    );
                 } else if (field.equals(ArpTpa.class)) {
                     ArpTpaCase arpTpaCase = ((ArpTpaCase) entry.getMatchEntryValue());
-                    Ipv4Address ipv4Address = arpTpaCase.getArpTpa().getIpv4Address();
-                    String ipAddressString = ipv4Address.getValue();
-                    String prefix = "";
+                    int prefix;
                     if (entry.isHasMask()) {
-                        byte[] mask = arpTpaCase.getArpTpa().getMask();
-                        prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+                        prefix = IpConversionUtil.countBits(arpTpaCase.getArpTpa().getMask());
                     } else {
-                        prefix += PREFIX_SEPARATOR + "32";
+                        prefix = 32;
                     }
 
-                    arpMatch.setArpTargetTransportAddress(createIpv4Prefix(ipAddressString, prefix));
+                    arpMatch.setArpTargetTransportAddress(
+                        IpConversionUtil.createPrefix(arpTpaCase.getArpTpa().getIpv4Address(), prefix)
+                    );
                 } else if (field.equals(ArpSha.class)) {
                     ArpSourceHardwareAddressBuilder arpSha = new ArpSourceHardwareAddressBuilder();
                     ArpShaCase arpShaCase = ((ArpShaCase) entry.getMatchEntryValue());
@@ -453,32 +449,28 @@ public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, Lis
                 }
                 if (field.equals(TunnelIpv4Src.class)) {
                     Ipv4SrcCase ipv4SrcCase = ((Ipv4SrcCase) entry.getMatchEntryValue());
-                    Ipv4Address ipv4Address = ipv4SrcCase.getIpv4Src().getIpv4Address();
-                    String ipAddressString = ipv4Address.getValue();
-
-                    String prefix = "";
+                    int prefix;
                     if (entry.isHasMask()) {
-                        byte[] mask = ipv4SrcCase.getIpv4Src().getMask();
-                        prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+                        prefix = IpConversionUtil.countBits(ipv4SrcCase.getIpv4Src().getMask());
                     } else {
-                        prefix += PREFIX_SEPARATOR + "32";
+                        prefix = 32;
                     }
-
-                    ipv4Match.setIpv4Source(createIpv4Prefix(ipAddressString, prefix));
+                    
+                    ipv4Match.setIpv4Source(
+                        IpConversionUtil.createPrefix(ipv4SrcCase.getIpv4Src().getIpv4Address(), prefix)
+                    );
                 } else if (field.equals(TunnelIpv4Dst.class)) {
                     Ipv4DstCase ipv4DstCase = ((Ipv4DstCase) entry.getMatchEntryValue());
-                    Ipv4Address ipv4Address = ipv4DstCase.getIpv4Dst().getIpv4Address();
-                    String ipAddressString = ipv4Address.getValue();
-                    String prefix = "";
+                    int prefix;
                     if (entry.isHasMask()) {
-                        byte[] mask = ipv4DstCase.getIpv4Dst().getMask();
-                        prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+                        prefix = IpConversionUtil.countBits(ipv4DstCase.getIpv4Dst().getMask());
                     } else {
-                        prefix += PREFIX_SEPARATOR + "32";
+                        prefix = 32;
                     }
-
-                    ipv4Match.setIpv4Destination(createIpv4Prefix(ipAddressString, prefix));
-                }
+                    
+                    ipv4Match.setIpv4Destination(
+                        IpConversionUtil.createPrefix(ipv4DstCase.getIpv4Dst().getIpv4Address(), prefix)
+                    );               }
             } else if (field.equals(Ipv6Src.class) || field.equals(Ipv6Dst.class) || field.equals(Ipv6Flabel.class)
                     || field.equals(Ipv6NdTarget.class) || field.equals(Ipv6NdSll.class)
                     || field.equals(Ipv6NdTll.class) || field.equals(Ipv6Exthdr.class)) {
@@ -487,26 +479,26 @@ public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, Lis
                 }
                 if (field.equals(Ipv6Src.class)) {
                     Ipv6SrcCase ipv6SrcCase = ((Ipv6SrcCase) entry.getMatchEntryValue());
-                    Ipv6Address ipv6Address = ipv6SrcCase.getIpv6Src().getIpv6Address();
-                    String ipv6string = ipv6Address.getValue();
-                    String prefix = "";
+                    int prefix ;
                     if (entry.isHasMask()) {
-                        byte[] mask = ipv6SrcCase.getIpv6Src().getMask();
-                        prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+                        prefix = IpConversionUtil.countBits(ipv6SrcCase.getIpv6Src().getMask());
+                    } else {
+                        prefix = 128;
                     }
-
-                    ipv6Match.setIpv6Source(createIpv6Prefix(ipv6string, prefix));
+                    ipv6Match.setIpv6Source(
+                        IpConversionUtil.createPrefix(ipv6SrcCase.getIpv6Src().getIpv6Address(), prefix)
+                    );
                 } else if (field.equals(Ipv6Dst.class)) {
                     Ipv6DstCase ipv6DstCase = ((Ipv6DstCase) entry.getMatchEntryValue());
-                    Ipv6Address ipv6Address = ipv6DstCase.getIpv6Dst().getIpv6Address();
-                    String ipv6string = ipv6Address.getValue();
-                    String prefix = "";
+                    int prefix;
                     if (entry.isHasMask()) {
-                        byte[] mask = ipv6DstCase.getIpv6Dst().getMask();
-                        prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+                        prefix = IpConversionUtil.countBits(ipv6DstCase.getIpv6Dst().getMask());
+                    } else {
+                        prefix = 128;
                     }
-
-                    ipv6Match.setIpv6Destination(createIpv6Prefix(ipv6string, prefix));
+                    ipv6Match.setIpv6Destination(
+                        IpConversionUtil.createPrefix(ipv6DstCase.getIpv6Dst().getIpv6Address(), prefix)
+                    );
                 } else if (field.equals(Ipv6Flabel.class)) {
                     Ipv6LabelBuilder ipv6Label = new Ipv6LabelBuilder();
                     Ipv6FlabelCase ipv6FlabelCase = ((Ipv6FlabelCase) entry.getMatchEntryValue());
@@ -627,23 +619,4 @@ public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, Lis
         return matchBuilder.build();
     }
 
-    private Ipv6Prefix createIpv6Prefix(final String ipv6string, final String prefix) {
-        return new Ipv6Prefix(ipv6string + prefix);
-    }
-
-    private Ipv4Prefix createIpv4Prefix(final String ipAddressString, final String prefix) {
-        return new Ipv4Prefix(ipAddressString + prefix);
-    }
-
-    private int toInt(byte b) {
-        return b < 0 ? b + 256 : b;
-    }
-
-    private int countBits(byte[] mask) {
-        int netmask = 0;
-        for (byte b : mask) {
-            netmask += Integer.bitCount(toInt(b));
-        }
-        return netmask;
-    }
 }
index 869b3d22678ac458562384314374e29ef19b4d4e..52150e54833a1383f5a664284c7cc6b58e6af8f8 100644 (file)
@@ -457,7 +457,8 @@ public class ActionConvertorTest {
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
                 new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
         Address address;
-        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:0db8:85a3:0042:1000:8a2e:0370:7334")).build();
+        /* Use canonical form - no leading zeroes!!! */
+        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
         SetNwDstActionCase action = provisionNwDstActionBuilder(address);
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action ofAction = ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
         Assert.assertNull(ofAction);
@@ -496,7 +497,8 @@ public class ActionConvertorTest {
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
                 new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
         Address address;
-        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:0db8:85a3:0042:1000:8a2e:0370:7334")).build();
+        /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
+        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
         SetNwDstActionCase action = provisionNwDstActionBuilder(address);
         ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
         Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
@@ -504,7 +506,8 @@ public class ActionConvertorTest {
         MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
         Assert.assertEquals(Ipv6Dst.class.getName(), matchEntry.getOxmMatchField().getName());
         Ipv6DstCase ipv6DstCase = ((Ipv6DstCase) matchEntry.getMatchEntryValue());
-        Assert.assertEquals("2001:0db8:85a3:0042:1000:8a2e:0370:7334", ipv6DstCase.getIpv6Dst().getIpv6Address().getValue());
+        /* We check the IP only, the netmask should have gone into the wildcard field */
+        Assert.assertEquals("2001:db8:85a3:42:1000:8a2e:370:7334", ipv6DstCase.getIpv6Dst().getIpv6Address().getValue());
     }
 
 
@@ -536,7 +539,8 @@ public class ActionConvertorTest {
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
                 new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
         Address address;
-        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:0db8:85a3:0042:1000:8a2e:0370:7334")).build();
+        /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
+        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
         SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action ofAction = ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
         Assert.assertNull(ofAction);
@@ -573,7 +577,8 @@ public class ActionConvertorTest {
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
                 new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
         Address address;
-        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:0db8:85a3:0042:1000:8a2e:0370:7334")).build();
+        /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
+        address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
         SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
         ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
         Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
@@ -581,7 +586,8 @@ public class ActionConvertorTest {
         MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
         Ipv6SrcCase ipv6SrcCase = ((Ipv6SrcCase) matchEntry.getMatchEntryValue());
         Assert.assertEquals(Ipv6Src.class.getName(), matchEntry.getOxmMatchField().getName());
-        Assert.assertEquals("2001:0db8:85a3:0042:1000:8a2e:0370:7334", ipv6SrcCase.getIpv6Src().getIpv6Address().getValue());
+        /* We check the IP only, the netmask should have gone into the wildcard field */
+        Assert.assertEquals("2001:db8:85a3:42:1000:8a2e:370:7334", ipv6SrcCase.getIpv6Src().getIpv6Address().getValue());
     }
 
     /**
index 4445a07917c44cc76c4d4ea1338d8eb1430fa1f3..e46aed8e10d9fb2255e52663071be010c7ef5fd3 100644 (file)
@@ -111,7 +111,8 @@ public class ActionConvertorV10Test {
         SetNwSrcActionCaseBuilder nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();\r
         SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();\r
         Ipv4Builder ipv4Builder = new Ipv4Builder();\r
-        ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.1/24"));\r
+        /* Use prefix which is correct in canonical representation in test */\r
+        ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.0/24"));\r
         nwSrcBuilder.setAddress(ipv4Builder.build());\r
         nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());\r
         actionBuilder.setAction(nwSrcCaseBuilder.build());\r
@@ -194,7 +195,7 @@ public class ActionConvertorV10Test {
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
                 + ".action.rev150203.action.grouping.action.choice.SetNwSrcCase", action.getActionChoice().getImplementedInterface().getName());\r
         SetNwSrcCase setNwSrcCase = (SetNwSrcCase) action.getActionChoice();\r
-        Assert.assertEquals("Wrong nw src", "10.0.0.1", setNwSrcCase.getSetNwSrcAction().getIpAddress().getValue());\r
+        Assert.assertEquals("Wrong nw src", "10.0.0.0", setNwSrcCase.getSetNwSrcAction().getIpAddress().getValue());\r
         \r
         action = actions.get(5);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
@@ -266,4 +267,4 @@ public class ActionConvertorV10Test {
         Assert.assertEquals("Wrong output port", "14", outputAction.getOutputAction().getOutputNodeConnector().getValue());\r
         Assert.assertEquals("Wrong max length", 555, outputAction.getOutputAction().getMaxLength().intValue());\r
     }\r
-}
\ No newline at end of file
+}\r
index 0b3379f9f44b2150190e464512791a6613add584..b576afd63e161964e1d097c855c7c10a43c12523 100644 (file)
@@ -377,7 +377,8 @@ public class ActionConvertorV13Test {
         SetNwSrcActionCaseBuilder nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();\r
         SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();\r
         Ipv4Builder ipv4Builder = new Ipv4Builder();\r
-        ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.1/24"));\r
+        /* Correct canonical form for v4 prefix!!! */\r
+        ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.0/24"));\r
         nwSrcBuilder.setAddress(ipv4Builder.build());\r
         nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());\r
         actionBuilder.setAction(nwSrcCaseBuilder.build());\r
@@ -443,7 +444,8 @@ public class ActionConvertorV13Test {
         nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();\r
         nwSrcBuilder = new SetNwSrcActionBuilder();\r
         Ipv6Builder ipv6Builder = new Ipv6Builder();\r
-        ipv6Builder.setIpv6Address(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0005/128"));\r
+        /* Use canonical form, 00:00:0000 is not a valid v6 notation */\r
+        ipv6Builder.setIpv6Address(new Ipv6Prefix("::5/128"));\r
         nwSrcBuilder.setAddress(ipv6Builder.build());\r
         nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());\r
         actionBuilder.setAction(nwSrcCaseBuilder.build());\r
@@ -455,7 +457,8 @@ public class ActionConvertorV13Test {
         nwDstCaseBuilder = new SetNwDstActionCaseBuilder();\r
         nwDstBuilder = new SetNwDstActionBuilder();\r
         ipv6Builder = new Ipv6Builder();\r
-        ipv6Builder.setIpv6Address(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0008/64"));\r
+        /* Use canonical form, 00:00:0006/64 is not a valid v6 notation - this equates to ::/64 */\r
+        ipv6Builder.setIpv6Address(new Ipv6Prefix("::/64"));\r
         nwDstBuilder.setAddress(ipv6Builder.build());\r
         nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());\r
         actionBuilder.setAction(nwDstCaseBuilder.build());\r
@@ -517,7 +520,7 @@ public class ActionConvertorV13Test {
                 + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());\r
         entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);\r
         checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src.class, false);\r
-        Assert.assertEquals("Wrong ipv4 src", "10.0.0.1", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src()\r
+        Assert.assertEquals("Wrong ipv4 src", "10.0.0.0", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src()\r
                 .getIpv4Address().getValue());\r
 \r
         action = actions.get(5);\r
@@ -579,7 +582,7 @@ public class ActionConvertorV13Test {
                 + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());\r
         entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);\r
         checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src.class, false);\r
-        Assert.assertEquals("Wrong ipv4 src", "0000:0000:0000:0000:0000:0000:0000:0005",\r
+        Assert.assertEquals("Wrong ipv6 src", "::5",\r
                 ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());\r
 \r
         action = actions.get(11);\r
@@ -589,7 +592,7 @@ public class ActionConvertorV13Test {
                 + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());\r
         entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);\r
         checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst.class, false);\r
-        Assert.assertEquals("Wrong ipv4 dst", "0000:0000:0000:0000:0000:0000:0000:0008",\r
+        Assert.assertEquals("Wrong ipv6 dst", "::",\r
                 ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());\r
     }\r
 \r
@@ -598,4 +601,4 @@ public class ActionConvertorV13Test {
         Assert.assertEquals("Wrong oxm field", field, entry.getOxmMatchField());\r
         Assert.assertEquals("Wrong hasMask", hasMask, entry.isHasMask());\r
     }\r
-}
\ No newline at end of file
+}\r
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtilTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtilTest.java
new file mode 100644 (file)
index 0000000..fffe7dc
--- /dev/null
@@ -0,0 +1,116 @@
+/*\r
+ * Copyright (c) 2014 Brocade Communications Systems Inc and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;\r
+\r
+\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import java.util.Arrays;\r
+import java.math.BigInteger;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.opendaylight.openflowjava.util.ByteBufUtils;\r
+\r
+\r
+/**\r
+ * @author Anton Ivanov aivanov@brocade.com\r
+ *\r
+ */\r
+public class IpConversionUtilTest {\r
+\r
+    private static Logger LOG = LoggerFactory\r
+            .getLogger(IpConversionUtilTest.class);\r
+\r
+\r
+\r
+    /*\r
+     * Test canonicalBinaryV6Address\r
+     */\r
+    @Test\r
+    public void canonicalBinaryV6AddressTest() {\r
+\r
+        byte [] ipv6binary = IpConversionUtil.canonicalBinaryV6Address(new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0001"));\r
+        byte [] expected = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1};\r
+\r
+        Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));\r
+        try {\r
+            Assert.assertEquals("Incorrect canonicalization - string", "::1", IpConversionUtil.byteArrayV6AddressToString(ipv6binary));\r
+        } catch (java.net.UnknownHostException e) {\r
+            Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);\r
+        }\r
+    }\r
+\r
+    /*\r
+     * Test canonicalBinaryV6Prefix\r
+     */\r
+    @Test\r
+    public void canonicalBinaryV6AddressPrefixTest() {\r
+\r
+        byte [] ipv6binary = IpConversionUtil.canonicalBinaryV6Prefix(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001/64"));\r
+        byte [] expected = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 64};\r
+\r
+        Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));\r
+        try {\r
+            Assert.assertEquals("Incorrect canonicalization - string", "::/64", IpConversionUtil.byteArrayV6PrefixToString(ipv6binary));\r
+        } catch (java.net.UnknownHostException e){\r
+            Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testCountBitsAsCIDRReplacement() throws Exception {\r
+        BigInteger maskSeed = new BigInteger("1ffffffffffffffffffffffffffffffff", 16);\r
+        byte[] maskArray = new byte[16];\r
+        LOG.debug("maskSeed= {}", ByteBufUtils.bytesToHexString(maskSeed.toByteArray()));\r
+\r
+        for (int i = 0; i <= 128; i++) {\r
+            System.arraycopy(maskSeed.toByteArray(), 1, maskArray, 0, 16);\r
+            LOG.debug("maskHex[{}] = {}", i, ByteBufUtils.bytesToHexString(maskArray));\r
+            int cidr = IpConversionUtil.countBits(maskArray);\r
+            LOG.debug("cidr = {}", cidr);\r
+            Assert.assertEquals(128 - i, cidr);\r
+\r
+            maskSeed = maskSeed.clearBit(i);\r
+        }\r
+    }\r
+\r
+\r
+    /**\r
+     * Test method for {@link MatchConvertorUtil#getIpv4Mask(byte[])}.\r
+     *\r
+     * @throws Exception\r
+     */\r
+\r
+    @Test\r
+    public void testcountBitsAsGetIpv4Mask() {\r
+        byte[][] maskInputs = new byte[][]{\r
+                {(byte) 255, (byte) 255, (byte) 255, (byte) 255},\r
+                {(byte) 255, (byte) 255, (byte) 254, 0},\r
+                {(byte) 128, 0, 0, 0},\r
+                {0, 0, 0, 0},\r
+        };\r
+\r
+        int[] maskOutputs = new int[]{\r
+                32, 23, 1, 0\r
+        };\r
+\r
+        for (int i = 0; i < maskInputs.length; i++) {\r
+            int mask = IpConversionUtil.countBits(maskInputs[i]);\r
+            Assert.assertEquals(maskOutputs[i], mask);\r
+        }\r
+    }\r
+}\r
index 9913678e65e341a1a1dd902d558c98e32c0dbaec..a3b91ee4e035ef5359fcced7606d6237693c012b 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
 
+import java.math.BigInteger;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -21,7 +22,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.addr
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import java.math.BigInteger;
 
 /**
  * match conversion and injection test
@@ -38,7 +38,7 @@ public class ActionSetNwDstReactorTest {
         addresses = new Address[]{
                 new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/32")).build(),
                 new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/16")).build(),
-                new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12")).build(),
+                new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/128")).build(),
                 new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/42")).build(),
         };
     }
@@ -48,12 +48,12 @@ public class ActionSetNwDstReactorTest {
      */
     @Test
     public void testMatchConvertorV13_flow() {
-        ActionBuilder target = new ActionBuilder();
-        for (Address address : addresses) {
-            SetNwDstActionCase action = prepareSetNwDstActionCase(address);
+        final ActionBuilder target = new ActionBuilder();
+        for (final Address address : addresses) {
+            final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
             ActionSetNwDstReactor.getInstance().convert(action,
                     OFConstants.OFP_VERSION_1_3, target, BigInteger.ONE);
-            Object mEntry = target.getActionChoice();
+            final Object mEntry = target.getActionChoice();
 /*
             Assert.assertNotNull(mEntry);
             if (address instanceof Ipv4) {
@@ -73,7 +73,7 @@ public class ActionSetNwDstReactorTest {
      * @param address
      * @return
      */
-    private static SetNwDstActionCase prepareSetNwDstActionCase(Address address) {
+    private static SetNwDstActionCase prepareSetNwDstActionCase(final Address address) {
         return new SetNwDstActionCaseBuilder().setSetNwDstAction(
                 new SetNwDstActionBuilder().setAddress(address).build()).build();
     }
@@ -83,9 +83,9 @@ public class ActionSetNwDstReactorTest {
      */
     @Test
     public void testMatchConvertorV10_flow() {
-        ActionBuilder target = new ActionBuilder();
-        for (Address address : addresses) {
-            SetNwDstActionCase action = prepareSetNwDstActionCase(address);
+        final ActionBuilder target = new ActionBuilder();
+        for (final Address address : addresses) {
+            final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
 
             if (address instanceof Ipv4) {
                 ActionSetNwDstReactor.getInstance().convert(action,
@@ -96,7 +96,7 @@ public class ActionSetNwDstReactorTest {
                     ActionSetNwDstReactor.getInstance().convert(action,
                             OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
                     Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     //expected
                     Assert.assertEquals(IllegalArgumentException.class, e.getClass());
                 }
index e68e781ff3820725e3360785efa4bf430e53362d..8790af7cbd305a4c8459d96292683ffc739588bd 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
 
+import java.math.BigInteger;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -21,7 +22,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.addr
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import java.math.BigInteger;
 
 /**
  * match conversion and injection test
@@ -38,7 +38,7 @@ public class ActionSetNwSrcReactorTest {
         addresses = new Address[]{
                 new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/32")).build(),
                 new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/16")).build(),
-                new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12")).build(),
+                new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/128")).build(),
                 new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/42")).build(),
         };
     }
@@ -49,9 +49,9 @@ public class ActionSetNwSrcReactorTest {
 
     @Test
     public void testMatchConvertorV13_flow() {
-        ActionBuilder target = new ActionBuilder();
-        for (Address address : addresses) {
-            SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
+        final ActionBuilder target = new ActionBuilder();
+        for (final Address address : addresses) {
+            final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
             ActionSetNwSrcReactor.getInstance().convert(action,
                     OFConstants.OFP_VERSION_1_3, target, BigInteger.ONE);
 /*
@@ -74,7 +74,7 @@ public class ActionSetNwSrcReactorTest {
      * @param address
      * @return
      */
-    private static SetNwSrcActionCase prepareSetNwSrcActionCase(Address address) {
+    private static SetNwSrcActionCase prepareSetNwSrcActionCase(final Address address) {
         return new SetNwSrcActionCaseBuilder().setSetNwSrcAction(
                 new SetNwSrcActionBuilder().setAddress(address).build()).build();
     }
@@ -84,9 +84,9 @@ public class ActionSetNwSrcReactorTest {
      */
     @Test
     public void testMatchConvertorV10_flow() {
-        ActionBuilder target = new ActionBuilder();
-        for (Address address : addresses) {
-            SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
+        final ActionBuilder target = new ActionBuilder();
+        for (final Address address : addresses) {
+            final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
 
             if (address instanceof Ipv4) {
                 ActionSetNwSrcReactor.getInstance().convert(action,
@@ -96,7 +96,7 @@ public class ActionSetNwSrcReactorTest {
                     ActionSetNwSrcReactor.getInstance().convert(action,
                             OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
                     Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     //expected
                     Assert.assertEquals(IllegalArgumentException.class, e.getClass());
                 }
index 06545234033bc8bb9576cae168736016a5f32514..d352b37990d7a1470fbda1714d01ddd10484df09 100644 (file)
@@ -434,7 +434,8 @@ public class MatchConvertorImpl2Test {
     public void testArpMatchConversionWithMasks() {\r
         MatchBuilder builder = new MatchBuilder();\r
         ArpMatchBuilder arpBuilder = new ArpMatchBuilder();\r
-        arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.3/8"));\r
+        /* Use canonnical prefixes !!! */\r
+        arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/8"));\r
         arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/31"));\r
         ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();\r
         srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));\r
@@ -452,7 +453,7 @@ public class MatchConvertorImpl2Test {
         MatchEntry entry = entries.get(0);\r
         entry = entries.get(0);\r
         checkEntryHeader(entry, ArpSpa.class, true);\r
-        Assert.assertEquals("Wrong arp spa", "10.0.0.3", ((ArpSpaCase) entry.getMatchEntryValue())\r
+        Assert.assertEquals("Wrong arp spa", "10.0.0.0", ((ArpSpaCase) entry.getMatchEntryValue())\r
                 .getArpSpa().getIpv4Address().getValue());\r
         Assert.assertArrayEquals("Wrong arp spa mask", new byte[]{(byte) 255, 0, 0, 0},\r
                 ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getMask());\r
@@ -483,12 +484,12 @@ public class MatchConvertorImpl2Test {
     public void testIpv6MatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
         Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();\r
-        ipv6Builder.setIpv6Source(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001"));\r
-        ipv6Builder.setIpv6Destination(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0002"));\r
+        ipv6Builder.setIpv6Source(new Ipv6Prefix("::1/128"));\r
+        ipv6Builder.setIpv6Destination(new Ipv6Prefix("::2/128"));\r
         Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();\r
         ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(3L));\r
         ipv6Builder.setIpv6Label(ipv6LabelBuilder.build());\r
-        ipv6Builder.setIpv6NdTarget(new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0004"));\r
+        ipv6Builder.setIpv6NdTarget(new Ipv6Address("::4"));\r
         ipv6Builder.setIpv6NdSll(new MacAddress("00:00:00:00:00:05"));\r
         ipv6Builder.setIpv6NdTll(new MacAddress("00:00:00:00:00:06"));\r
         Ipv6ExtHeaderBuilder extHdrBuilder = new Ipv6ExtHeaderBuilder();\r
@@ -500,12 +501,15 @@ public class MatchConvertorImpl2Test {
         List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
         Assert.assertEquals("Wrong entries size", 7, entries.size());\r
         MatchEntry entry = entries.get(0);\r
-        checkEntryHeader(entry, Ipv6Src.class, false);\r
-        Assert.assertEquals("Wrong ipv6 src", "0000:0000:0000:0000:0000:0000:0000:0001",\r
+        /* Due to conversion ambiguities, we always get "has mask" because \r
+         * an ip with no mask and prefix with /128 (or 32 in v4) cannot \r
+         * be distinguished */\r
+        checkEntryHeader(entry, Ipv6Src.class, true);\r
+        Assert.assertEquals("Wrong ipv6 src", "::1",\r
                 ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());\r
         entry = entries.get(1);\r
-        checkEntryHeader(entry, Ipv6Dst.class, false);\r
-        Assert.assertEquals("Wrong ipv6 dst", "0000:0000:0000:0000:0000:0000:0000:0002",\r
+        checkEntryHeader(entry, Ipv6Dst.class, true);\r
+        Assert.assertEquals("Wrong ipv6 dst", "::2",\r
                 ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());\r
         entry = entries.get(2);\r
         checkEntryHeader(entry, Ipv6Flabel.class, false);\r
@@ -513,7 +517,7 @@ public class MatchConvertorImpl2Test {
                 ((Ipv6FlabelCase) entry.getMatchEntryValue()).getIpv6Flabel().getIpv6Flabel().getValue().intValue());\r
         entry = entries.get(3);\r
         checkEntryHeader(entry, Ipv6NdTarget.class, false);\r
-        Assert.assertEquals("Wrong ipv6 nd target", "0000:0000:0000:0000:0000:0000:0000:0004",\r
+        Assert.assertEquals("Wrong ipv6 nd target", "::4",\r
                 ((Ipv6NdTargetCase) entry.getMatchEntryValue()).getIpv6NdTarget().getIpv6Address().getValue());\r
         entry = entries.get(4);\r
         checkEntryHeader(entry, Ipv6NdSll.class, false);\r
@@ -536,8 +540,8 @@ public class MatchConvertorImpl2Test {
     public void testIpv6MatchConversionWithMasks() {\r
         MatchBuilder builder = new MatchBuilder();\r
         Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();\r
-        ipv6Builder.setIpv6Source(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001/24"));\r
-        ipv6Builder.setIpv6Destination(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0002/64"));\r
+        ipv6Builder.setIpv6Source(new Ipv6Prefix("::/24"));\r
+        ipv6Builder.setIpv6Destination(new Ipv6Prefix("::/64"));\r
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
@@ -545,13 +549,13 @@ public class MatchConvertorImpl2Test {
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Ipv6Src.class, true);\r
-        Assert.assertEquals("Wrong ipv6 src", "0000:0000:0000:0000:0000:0000:0000:0001",\r
+        Assert.assertEquals("Wrong ipv6 src", "::",\r
                 ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());\r
         Assert.assertArrayEquals("Wrong ipv6 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0,\r
                 0, 0, 0, 0, 0, 0, 0, 0, 0}, ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getMask());\r
         entry = entries.get(1);\r
         checkEntryHeader(entry, Ipv6Dst.class, true);\r
-        Assert.assertEquals("Wrong ipv6 dst", "0000:0000:0000:0000:0000:0000:0000:0002",\r
+        Assert.assertEquals("Wrong ipv6 dst", "::",\r
                 ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());\r
         Assert.assertArrayEquals("Wrong ipv6 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255,\r
                         (byte) 255, (byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0},\r
@@ -619,8 +623,8 @@ public class MatchConvertorImpl2Test {
         tunnelBuilder.setTunnelMask(new BigInteger("14"));\r
         builder.setTunnel(tunnelBuilder.build());\r
         Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();\r
-        ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.1/24"));\r
-        ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.2/8"));\r
+        ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.0/24"));\r
+        ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.0/8"));\r
         builder.setLayer3Match(ipv4MatchBuilder.build());\r
         Match match = builder.build();\r
 \r
@@ -654,13 +658,13 @@ public class MatchConvertorImpl2Test {
                 ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getMask());\r
         entry = entries.get(4);\r
         checkEntryHeader(entry, Ipv4Src.class, true);\r
-        Assert.assertEquals("Wrong ipv4 src", "10.0.0.1", ((Ipv4SrcCase) entry.getMatchEntryValue())\r
+        Assert.assertEquals("Wrong ipv4 src", "10.0.0.0", ((Ipv4SrcCase) entry.getMatchEntryValue())\r
                 .getIpv4Src().getIpv4Address().getValue());\r
         Assert.assertArrayEquals("Wrong ipv4 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, 0},\r
                 ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getMask());\r
         entry = entries.get(5);\r
         checkEntryHeader(entry, Ipv4Dst.class, true);\r
-        Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue())\r
+        Assert.assertEquals("Wrong ipv4 dst", "10.0.0.0", ((Ipv4DstCase) entry.getMatchEntryValue())\r
                 .getIpv4Dst().getIpv4Address().getValue());\r
         Assert.assertArrayEquals("Wrong ipv4 dst mask", new byte[]{(byte) 255, 0, 0, 0},\r
                 ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getMask());\r
@@ -677,4 +681,4 @@ public class MatchConvertorImpl2Test {
         Assert.assertArrayEquals("Wrong tunnel id mask", new byte[]{0, 0, 0, 0, 0, 0, 0, 14},\r
                 ((TunnelIdCase) entry.getMatchEntryValue()).getTunnelId().getMask());\r
     }\r
-}
\ No newline at end of file
+}\r
index 71f971f0150604f7b1fab30f09e998d0fb74660e..f709c9be2f03d2a569bb990c8ee48a6921121057 100644 (file)
@@ -8,6 +8,9 @@
 \r
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;\r
 \r
+import java.math.BigInteger;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
@@ -147,9 +150,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
 \r
 /**\r
  * @author michal.polkorab\r
@@ -169,7 +169,7 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test(expected = NullPointerException.class)\r
     public void testEmptyMatch() {\r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
 \r
         MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF10);\r
     }\r
@@ -180,15 +180,15 @@ public class MatchConvertorImplV13Test {
     @Test\r
     public void testEmptyMatchEntry() {\r
 \r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setType(OxmMatchType.class);\r
-        List<MatchEntry> entries = new ArrayList<>();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
         builder.setMatchEntry(entries);\r
-        Match match = builder.build();\r
+        final Match match = builder.build();\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         Assert.assertEquals("Wrong match entries", null, builtMatch.getEthernetMatch());\r
         Assert.assertEquals("Wrong match entries", null, builtMatch.getIcmpv4Match());\r
@@ -210,24 +210,24 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test\r
     public void testWithMatchEntryNoMasks() {\r
-        List<MatchEntry> entries = new ArrayList<>();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
         MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort.class);\r
         entriesBuilder.setHasMask(false);\r
-        InPortCaseBuilder caseBuilder = new InPortCaseBuilder();\r
-        InPortBuilder portBuilder = new InPortBuilder();\r
+        final InPortCaseBuilder caseBuilder = new InPortCaseBuilder();\r
+        final InPortBuilder portBuilder = new InPortBuilder();\r
         portBuilder.setPortNumber(new PortNumber(1L));\r
         caseBuilder.setInPort(portBuilder.build());\r
         entriesBuilder.setMatchEntryValue(caseBuilder.build());\r
         entries.add(entriesBuilder.build());\r
 \r
-        InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();\r
+        final InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();\r
         entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort.class);\r
         entriesBuilder.setHasMask(false);\r
-        InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();\r
+        final InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();\r
         inPhyPortBuilder.setPortNumber(new PortNumber(2L));\r
         inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());\r
         entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());\r
@@ -237,8 +237,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
         entriesBuilder.setHasMask(false);\r
-        MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
+        final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
         metadataBuilder.setMetadata(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});\r
         metadataCaseBuilder.setMetadata(metadataBuilder.build());\r
         entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());\r
@@ -248,8 +248,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(EthDst.class);\r
         entriesBuilder.setHasMask(false);\r
-        EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
-        EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
+        final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
+        final EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
         ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
         ethDstCaseBuilder.setEthDst(ethDstBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());\r
@@ -259,8 +259,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(EthSrc.class);\r
         entriesBuilder.setHasMask(false);\r
-        EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
-        EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
+        final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
+        final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
         ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
         ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());\r
@@ -271,9 +271,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(EthType.class);\r
         entriesBuilder.setHasMask(false);\r
-        EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();\r
+        final EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();\r
 \r
-        EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();\r
+        final EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();\r
         ethTypeBuilder.setEthType(new EtherType(3));\r
         ethTypeCaseBuilder.setEthType(ethTypeBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ethTypeCaseBuilder.build());\r
@@ -283,9 +283,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(VlanVid.class);\r
-        VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
+        final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
         entriesBuilder.setHasMask(false);\r
-        VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
+        final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
         vlanVidBuilder.setVlanVid(4);\r
         vlanVidBuilder.setCfiBit(true);\r
         vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());\r
@@ -295,9 +295,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(VlanPcp.class);\r
-        VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();\r
+        final VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();\r
         entriesBuilder.setHasMask(false);\r
-        VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();\r
+        final VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();\r
         vlanPcpBuilder.setVlanPcp((short) 5);\r
         vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());\r
         entriesBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());\r
@@ -308,8 +308,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(IpDscp.class);\r
         entriesBuilder.setHasMask(false);\r
-        IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();\r
-        IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();\r
+        final IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();\r
+        final IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();\r
         ipDscpBuilder.setDscp(new Dscp((short) 6));\r
         ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());\r
@@ -320,8 +320,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(IpEcn.class);\r
         entriesBuilder.setHasMask(false);\r
-        IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();\r
-        IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();\r
+        final IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();\r
+        final IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();\r
         ipEcnBuilder.setEcn((short) 7);\r
         ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());\r
@@ -331,9 +331,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(IpProto.class);\r
-        IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();\r
+        final IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();\r
         entriesBuilder.setHasMask(false);\r
-        IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();\r
+        final IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();\r
         ipProtoBuilder.setProtocolNumber((short) 8);\r
         ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipProtoCaseBuilder.build());\r
@@ -344,8 +344,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv4SrcCaseBuilder ipv4AddressBuilder = new Ipv4SrcCaseBuilder();\r
-        Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
+        final Ipv4SrcCaseBuilder ipv4AddressBuilder = new Ipv4SrcCaseBuilder();\r
+        final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
         ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));\r
         ipv4AddressBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv4AddressBuilder.build());\r
@@ -355,8 +355,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
-        Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();\r
+        final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
+        final Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();\r
         ipv4DstBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));\r
         ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
@@ -366,8 +366,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(TcpSrc.class);\r
         entriesBuilder.setHasMask(false);\r
-        TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();\r
-        TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();\r
+        final TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();\r
+        final TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();\r
         tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
                 .inet.types.rev100924.PortNumber(9));\r
         tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());\r
@@ -378,8 +378,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(TcpDst.class);\r
         entriesBuilder.setHasMask(false);\r
-        TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();\r
-        TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();\r
+        final TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();\r
+        final TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();\r
         tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
                 .inet.types.rev100924.PortNumber(10));\r
         tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());\r
@@ -390,8 +390,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Icmpv4Type.class);\r
         entriesBuilder.setHasMask(false);\r
-        Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();\r
-        Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();\r
+        final Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();\r
+        final Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();\r
         icmpv4TypeBuilder.setIcmpv4Type((short) 15);\r
         icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());\r
         entriesBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());\r
@@ -401,8 +401,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Icmpv4Code.class);\r
         entriesBuilder.setHasMask(false);\r
-        Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();\r
-        Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();\r
+        final Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();\r
+        final Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();\r
         icmpv4CodeBuilder.setIcmpv4Code((short) 16);\r
         icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());\r
         entriesBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());\r
@@ -412,8 +412,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Icmpv6Type.class);\r
         entriesBuilder.setHasMask(false);\r
-        Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();\r
-        Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();\r
+        final Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();\r
+        final Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();\r
         icmpv6TypeBuilder.setIcmpv6Type((short) 19);\r
         icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());\r
         entriesBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());\r
@@ -423,8 +423,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Icmpv6Code.class);\r
         entriesBuilder.setHasMask(false);\r
-        Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();\r
-        Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();\r
+        final Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();\r
+        final Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();\r
         icmpv6CodeBuilder.setIcmpv6Code((short) 20);\r
         icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());\r
         entriesBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());\r
@@ -434,9 +434,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(MplsLabel.class);\r
         entriesBuilder.setHasMask(false);\r
-        MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();\r
+        final MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();\r
 \r
-        MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();\r
+        final MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();\r
         mplsLabelBuilder.setMplsLabel(21L);\r
         mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build());\r
         entriesBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build());\r
@@ -446,8 +446,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(MplsTc.class);\r
         entriesBuilder.setHasMask(false);\r
-        MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();\r
-        MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();\r
+        final MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();\r
+        final MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();\r
         mplsTcBuilder.setTc((short) 22);\r
         mplsTcCaseBuilder.setMplsTc(mplsTcBuilder.build());\r
         entriesBuilder.setMatchEntryValue(mplsTcCaseBuilder.build());\r
@@ -457,8 +457,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(MplsBos.class);\r
         entriesBuilder.setHasMask(false);\r
-        MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();\r
-        MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();\r
+        final MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();\r
+        final MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();\r
         mplsBosBuilder.setBos(true);\r
         mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());\r
         entriesBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());\r
@@ -468,8 +468,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(PbbIsid.class);\r
         entriesBuilder.setHasMask(false);\r
-        PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
-        PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
+        final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
+        final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
         pbbIsidBuilder.setIsid(23L);\r
         pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());\r
         entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());\r
@@ -479,21 +479,21 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(TunnelId.class);\r
         entriesBuilder.setHasMask(false);\r
-        TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
-        TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
+        final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
+        final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
         tunnelIdBuilder.setTunnelId(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});\r
         tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());\r
         entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());\r
         entries.add(entriesBuilder.build());\r
 \r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setMatchEntry(entries);\r
 \r
-        Match match = builder.build();\r
+        final Match match = builder.build();\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         Assert.assertEquals("Wrong in port", "openflow:42:1", builtMatch.getInPort().getValue());\r
         Assert.assertEquals("Wrong in phy port", "openflow:42:2", builtMatch.getInPhyPort().getValue());\r
@@ -509,7 +509,7 @@ public class MatchConvertorImplV13Test {
         Assert.assertEquals("Wrong ip proto", null, builtMatch.getIpMatch().getIpProto());\r
         Assert.assertEquals("Wrong ip protocol", 8, builtMatch.getIpMatch().getIpProtocol().intValue());\r
 \r
-        TcpMatch tcpMatch = (TcpMatch) builtMatch.getLayer4Match();\r
+        final TcpMatch tcpMatch = (TcpMatch) builtMatch.getLayer4Match();\r
         Assert.assertEquals("Wrong tcp src port", 9, tcpMatch.getTcpSourcePort().getValue().intValue());\r
         Assert.assertEquals("Wrong tcp dst port", 10, tcpMatch.getTcpDestinationPort().getValue().intValue());\r
         Assert.assertEquals("Wrong icmpv4 type", 15, builtMatch.getIcmpv4Match().getIcmpv4Type().intValue());\r
@@ -517,7 +517,7 @@ public class MatchConvertorImplV13Test {
         Assert.assertEquals("Wrong icmpv6 type", 19, builtMatch.getIcmpv6Match().getIcmpv6Type().intValue());\r
         Assert.assertEquals("Wrong icmpv6 code", 20, builtMatch.getIcmpv6Match().getIcmpv6Code().intValue());\r
 \r
-        Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
+        final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong ipv4 src address", "10.0.0.1/32", ipv4Match.getIpv4Source().getValue());\r
         Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.2/32", ipv4Match.getIpv4Destination().getValue());\r
         Assert.assertEquals("Wrong mpls label", 21, builtMatch.getProtocolMatchFields().getMplsLabel().intValue());\r
@@ -533,17 +533,17 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test\r
     public void testWithMatchEntryWithMasks() {\r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setType(OxmMatchType.class);\r
-        List<MatchEntry> entries = new ArrayList<>();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
         MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
         entriesBuilder.setHasMask(true);\r
 \r
 \r
-        MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
+        final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
         metadataBuilder.setMetadata(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});\r
         metadataBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 0, 0, 1});\r
         metadataCaseBuilder.setMetadata(metadataBuilder.build());\r
@@ -554,8 +554,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(EthDst.class);\r
         entriesBuilder.setHasMask(true);\r
-        EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
-        EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
+        final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
+        final EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
         ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
         ethDstBuilder.setMask(new byte[]{0, 0, 0, 0, 1, 1});\r
         ethDstCaseBuilder.setEthDst(ethDstBuilder.build());\r
@@ -566,8 +566,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(EthSrc.class);\r
         entriesBuilder.setHasMask(true);\r
-        EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
-        EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
+        final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
+        final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
         ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
         ethSrcBuilder.setMask(new byte[]{0, 0, 0, 0, 2, 2});\r
         ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());\r
@@ -578,8 +578,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(VlanVid.class);\r
         entriesBuilder.setHasMask(true);\r
-        VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
-        VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
+        final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
+        final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
         vlanVidBuilder.setVlanVid(4);\r
         vlanVidBuilder.setCfiBit(true);\r
         vlanVidBuilder.setMask(new byte[]{0, 4});\r
@@ -591,9 +591,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
         entriesBuilder.setHasMask(true);\r
-        Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
-        Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
-        ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));\r
+        final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
+        final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
+        ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
         ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});\r
         ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());\r
@@ -603,9 +603,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
         entriesBuilder.setHasMask(true);\r
-        Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
-        Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
-        ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));\r
+        final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
+        final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
+        ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
         ipv4AddressBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 240, 0});\r
         ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
@@ -615,9 +615,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(PbbIsid.class);\r
         entriesBuilder.setHasMask(true);\r
-        PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
+        final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
 \r
-        PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
+        final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
         pbbIsidBuilder.setIsid(23L);\r
         pbbIsidBuilder.setMask(new byte[]{0, 0, 7});\r
         pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());\r
@@ -628,19 +628,19 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(TunnelId.class);\r
         entriesBuilder.setHasMask(true);\r
-        TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
-        TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
+        final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
+        final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
         tunnelIdBuilder.setTunnelId(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});\r
         tunnelIdBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 0, 0, 8});\r
         tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());\r
         entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());\r
         entries.add(entriesBuilder.build());\r
         builder.setMatchEntry(entries);\r
-        Match match = builder.build();\r
+        final Match match = builder.build();\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
 \r
         Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}), builtMatch.getMetadata().getMetadata());\r
         Assert.assertEquals("Wrong metadata mask", new BigInteger(1, new byte[]{0, 0, 0, 0, 0, 0, 0, 1}),\r
@@ -651,9 +651,9 @@ public class MatchConvertorImplV13Test {
         Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:02:02"), builtMatch.getEthernetMatch().getEthernetSource().getMask());\r
         Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());\r
         Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());\r
-        Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
-        Assert.assertEquals("Wrong ipv4 src address", "10.0.0.1/24", ipv4Match.getIpv4Source().getValue());\r
-        Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.2/20", ipv4Match.getIpv4Destination().getValue());\r
+        final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
+        Assert.assertEquals("Wrong ipv4 src address", "10.0.0.0/24", ipv4Match.getIpv4Source().getValue());\r
+        Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.0/20", ipv4Match.getIpv4Destination().getValue());\r
         Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());\r
         Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[]{1, 2, 3, 4, 5, 6, 7, 8}),\r
                 builtMatch.getTunnel().getTunnelId());\r
@@ -664,15 +664,15 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test\r
     public void testLayer4MatchUdp() {\r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setType(OxmMatchType.class);\r
-        List<MatchEntry> entries = new ArrayList<>();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
         MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc.class);\r
         entriesBuilder.setHasMask(false);\r
-        UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();\r
-        UdpSrcBuilder portBuilder = new UdpSrcBuilder();\r
+        final UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();\r
+        final UdpSrcBuilder portBuilder = new UdpSrcBuilder();\r
         portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
                 .inet.types.rev100924.PortNumber(11));\r
         udpSrcCaseBuilder.setUdpSrc(portBuilder.build());\r
@@ -684,8 +684,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(UdpDst.class);\r
         entriesBuilder.setHasMask(false);\r
-        UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();\r
-        UdpDstBuilder udpDstBuilder = new UdpDstBuilder();\r
+        final UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();\r
+        final UdpDstBuilder udpDstBuilder = new UdpDstBuilder();\r
         udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
                 .inet.types.rev100924.PortNumber(12));\r
         udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());\r
@@ -694,10 +694,10 @@ public class MatchConvertorImplV13Test {
 \r
         builder.setMatchEntry(entries);\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder builtMatch = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
 \r
-        UdpMatch udpMatch = (UdpMatch) builtMatch.getLayer4Match();\r
+        final UdpMatch udpMatch = (UdpMatch) builtMatch.getLayer4Match();\r
         Assert.assertEquals("Wrong udp src port", 11, udpMatch.getUdpSourcePort().getValue().intValue());\r
         Assert.assertEquals("Wrong udp dst port", 12, udpMatch.getUdpDestinationPort().getValue().intValue());\r
     }\r
@@ -707,15 +707,15 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test\r
     public void testLayer4MatchSctp() {\r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setType(OxmMatchType.class);\r
-        List<MatchEntry> entries = new ArrayList<>();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
         MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(SctpSrc.class);\r
         entriesBuilder.setHasMask(false);\r
-        SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();\r
-        SctpSrcBuilder portBuilder = new SctpSrcBuilder();\r
+        final SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();\r
+        final SctpSrcBuilder portBuilder = new SctpSrcBuilder();\r
         portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
                 .inet.types.rev100924.PortNumber(13));\r
         sctpSrcCaseBuilder.setSctpSrc(portBuilder.build());\r
@@ -727,8 +727,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(SctpDst.class);\r
         entriesBuilder.setHasMask(false);\r
-        SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();\r
-        SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();\r
+        final SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();\r
+        final SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();\r
         sctpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
                 .inet.types.rev100924.PortNumber(14));\r
         sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build());\r
@@ -736,11 +736,11 @@ public class MatchConvertorImplV13Test {
         entries.add(entriesBuilder.build());\r
         builder.setMatchEntry(entries);\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
-        SctpMatch udpMatch = (SctpMatch) builtMatch.getLayer4Match();\r
+        final SctpMatch udpMatch = (SctpMatch) builtMatch.getLayer4Match();\r
         Assert.assertEquals("Wrong sctp src port", 13, udpMatch.getSctpSourcePort().getValue().intValue());\r
         Assert.assertEquals("Wrong sctp dst port", 14, udpMatch.getSctpDestinationPort().getValue().intValue());\r
     }\r
@@ -750,16 +750,16 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test\r
     public void testLayer3MatchIpv6() {\r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setType(OxmMatchType.class);\r
-        List<MatchEntry> entries = new ArrayList<>();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
         MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
-        Ipv6SrcBuilder ipv6AddressBuilder = new Ipv6SrcBuilder();\r
-        ipv6AddressBuilder.setIpv6Address(new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0007"));\r
+        final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
+        final Ipv6SrcBuilder ipv6AddressBuilder = new Ipv6SrcBuilder();\r
+        ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9657"));\r
         ipv6SrcCaseBuilder.setIpv6Src(ipv6AddressBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());\r
         entries.add(entriesBuilder.build());\r
@@ -768,9 +768,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
-        Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();\r
-        ipv6DstBuilder.setIpv6Address(new Ipv6Address("0001:0002:0003:0004:0005:0006:0007:0008"));\r
+        final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
+        final Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();\r
+        ipv6DstBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9658"));\r
         ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());\r
         entries.add(entriesBuilder.build());\r
@@ -779,8 +779,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv6Flabel.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();\r
-        Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();\r
+        final Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();\r
+        final Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();\r
         ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(18L));\r
         ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());\r
@@ -790,9 +790,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();\r
-        Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();\r
-        ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("0002:0003:0004:0005:0006:0007:0008:0009"));\r
+        final Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();\r
+        final Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();\r
+        ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9659"));\r
         ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());\r
         entries.add(entriesBuilder.build());\r
@@ -801,8 +801,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv6NdSll.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();\r
-        Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();\r
+        final Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();\r
+        final Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();\r
         ipv6NdSllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:05"));\r
         ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());\r
@@ -812,8 +812,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv6NdTll.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();\r
-        Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();\r
+        final Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();\r
+        final Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();\r
         ipv6NdTllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:06"));\r
         ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());\r
@@ -823,24 +823,24 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);\r
         entriesBuilder.setHasMask(false);\r
-        Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
-        Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
+        final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
+        final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
         ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true));\r
         ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());\r
         entriesBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());\r
         builder.setMatchEntry(entries);\r
         entries.add(entriesBuilder.build());\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
-        Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
-        Assert.assertEquals("Wrong ipv6 src address", "0000:0001:0002:0003:0004:0005:0006:0007",\r
+        final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
+        Assert.assertEquals("Wrong ipv6 src address", "2001:cdba:0000:0000:0000:0000:3257:9657/128",\r
                 ipv6Match.getIpv6Source().getValue());\r
-        Assert.assertEquals("Wrong ipv6 dst address", "0001:0002:0003:0004:0005:0006:0007:0008",\r
+        Assert.assertEquals("Wrong ipv6 dst address", "2001:cdba:0000:0000:0000:0000:3257:9658/128",\r
                 ipv6Match.getIpv6Destination().getValue());\r
-        Assert.assertEquals("Wrong ipv6 nd target", "0002:0003:0004:0005:0006:0007:0008:0009",\r
+        Assert.assertEquals("Wrong ipv6 nd target", "2001:cdba:0000:0000:0000:0000:3257:9659",\r
                 ipv6Match.getIpv6NdTarget().getValue());\r
         Assert.assertEquals("Wrong ipv6 flabel", 18, ipv6Match.getIpv6Label().getIpv6Flabel().getValue().intValue());\r
         Assert.assertEquals("Wrong ipv6 nd sll", new MacAddress("00:00:00:00:00:05"), ipv6Match.getIpv6NdSll());\r
@@ -853,15 +853,15 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test\r
     public void testLayer3MatchIpv6ExtHeader2() {\r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setType(OxmMatchType.class);\r
-        List<MatchEntry> entries = new ArrayList<>();\r
-        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
+        final MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);\r
         entriesBuilder.setHasMask(true);\r
-        Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
-        Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
+        final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
+        final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
         ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false));\r
         ipv6ExthdrBuilder.setMask(new byte[]{1, 2});\r
         ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());\r
@@ -869,11 +869,11 @@ public class MatchConvertorImplV13Test {
         entries.add(entriesBuilder.build());\r
         builder.setMatchEntry(entries);\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
-        Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
+        final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong ipv6 ext header", 153, ipv6Match.getIpv6ExtHeader().getIpv6Exthdr().intValue());\r
         Assert.assertEquals("Wrong ipv6 ext header mask", 258, ipv6Match.getIpv6ExtHeader().getIpv6ExthdrMask().intValue());\r
     }\r
@@ -883,15 +883,15 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test\r
     public void testLayer3MatchArp() {\r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setType(OxmMatchType.class);\r
-        List<MatchEntry> entries = new ArrayList<>();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
         MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(ArpOp.class);\r
         entriesBuilder.setHasMask(false);\r
-        ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();\r
-        ArpOpBuilder arpOpBuilder = new ArpOpBuilder();\r
+        final ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();\r
+        final ArpOpBuilder arpOpBuilder = new ArpOpBuilder();\r
         arpOpBuilder.setOpCode(17);\r
         arpOpCaseBuilder.setArpOp(arpOpBuilder.build());\r
         entriesBuilder.setMatchEntryValue(arpOpCaseBuilder.build());\r
@@ -901,8 +901,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(ArpSpa.class);\r
         entriesBuilder.setHasMask(false);\r
-        ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
-        ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
+        final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
+        final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
         arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));\r
         arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());\r
         entriesBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());\r
@@ -912,8 +912,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(ArpTpa.class);\r
         entriesBuilder.setHasMask(false);\r
-        ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
-        ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
+        final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
+        final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
         arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4"));\r
         arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());\r
         entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());\r
@@ -923,8 +923,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(ArpSha.class);\r
         entriesBuilder.setHasMask(false);\r
-        ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
-        ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
+        final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
+        final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
         arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));\r
         arpShaCaseBuilder.setArpSha(arpShaBuilder.build());\r
         entriesBuilder.setMatchEntryValue(arpShaCaseBuilder.build());\r
@@ -934,19 +934,19 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);\r
         entriesBuilder.setHasMask(false);\r
-        ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
-        ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
+        final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
+        final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
         arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));\r
         arpThaCaseBuilder.setArpTha(arpThaBuilder.build());\r
         entriesBuilder.setMatchEntryValue(arpThaCaseBuilder.build());\r
         entries.add(entriesBuilder.build());\r
         builder.setMatchEntry(entries);\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
-        ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
+        final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong arp op", 17, arpMatch.getArpOp().intValue());\r
         Assert.assertEquals("Wrong arp spa", "10.0.0.3/32", arpMatch.getArpSourceTransportAddress().getValue());\r
         Assert.assertEquals("Wrong arp tpa", "10.0.0.4/32", arpMatch.getArpTargetTransportAddress().getValue());\r
@@ -959,15 +959,15 @@ public class MatchConvertorImplV13Test {
      */\r
     @Test\r
     public void testLayer3MatchArpWithMasks() {\r
-        MatchBuilder builder = new MatchBuilder();\r
+        final MatchBuilder builder = new MatchBuilder();\r
         builder.setType(OxmMatchType.class);\r
-        List<MatchEntry> entries = new ArrayList<>();\r
+        final List<MatchEntry> entries = new ArrayList<>();\r
         MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(ArpSpa.class);\r
         entriesBuilder.setHasMask(true);\r
-        ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
-        ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
+        final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
+        final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
         arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));\r
         arpSpaBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});\r
         arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());\r
@@ -978,9 +978,9 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(ArpTpa.class);\r
         entriesBuilder.setHasMask(true);\r
-        ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
-        ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
-        arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4"));\r
+        final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
+        final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
+        arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
         arpTpaBuilder.setMask(new byte[]{(byte) 255, (byte) 128, 0, 0});\r
         arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());\r
         entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());\r
@@ -990,8 +990,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(ArpSha.class);\r
         entriesBuilder.setHasMask(true);\r
-        ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
-        ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
+        final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
+        final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
         arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));\r
         arpShaBuilder.setMask(new byte[]{0, 0, 1, 0, 4, 0});\r
         arpShaCaseBuilder.setArpSha(arpShaBuilder.build());\r
@@ -1002,8 +1002,8 @@ public class MatchConvertorImplV13Test {
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
         entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);\r
         entriesBuilder.setHasMask(true);\r
-        ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
-        ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
+        final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
+        final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
         arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));\r
         arpThaBuilder.setMask(new byte[]{1, 1, 1, 2, 2, 2});\r
         arpThaCaseBuilder.setArpTha(arpThaBuilder.build());\r
@@ -1012,16 +1012,16 @@ public class MatchConvertorImplV13Test {
 \r
         builder.setMatchEntry(entries);\r
 \r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
                 .MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+        final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
 \r
-        ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
+        final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
         Assert.assertEquals("Wrong arp spa", "10.0.0.3/24", arpMatch.getArpSourceTransportAddress().getValue());\r
-        Assert.assertEquals("Wrong arp tpa", "10.0.0.4/9", arpMatch.getArpTargetTransportAddress().getValue());\r
+        Assert.assertEquals("Wrong arp tpa", "10.0.0.0/9", arpMatch.getArpTargetTransportAddress().getValue());\r
         Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:03", arpMatch.getArpSourceHardwareAddress().getAddress().getValue());\r
         Assert.assertEquals("Wrong arp sha mask", "00:00:01:00:04:00", arpMatch.getArpSourceHardwareAddress().getMask().getValue());\r
         Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:04", arpMatch.getArpTargetHardwareAddress().getAddress().getValue());\r
         Assert.assertEquals("Wrong arp tha mask", "01:01:01:02:02:02", arpMatch.getArpTargetHardwareAddress().getMask().getValue());\r
     }\r
-}
\ No newline at end of file
+}\r
index e0692c63e39682e41dcd13149e12281693c4e56a..b1200b1b4c4fb712784db583ecee9fdd5a21c98f 100644 (file)
@@ -68,75 +68,4 @@ public class MatchConvertorUtilTest {
         return flags;
     }
 
-    /**
-     * Test method for {@link MatchConvertorUtil#ipv6NetmaskArrayToCIDRValue(byte[])} (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MatchEntry)}.
-     *
-     * @throws Exception
-     */
-
-    @Test
-    public void testIpv6NetmaskArrayToCIDRValue() throws Exception {
-        BigInteger maskSeed = new BigInteger("1ffffffffffffffffffffffffffffffff", 16);
-        byte[] maskArray = new byte[16];
-        LOG.debug("maskSeed= {}", ByteBufUtils.bytesToHexString(maskSeed.toByteArray()));
-
-        for (int i = 0; i <= 128; i++) {
-            System.arraycopy(maskSeed.toByteArray(), 1, maskArray, 0, 16);
-            LOG.debug("maskHex[{}] = {}", i, ByteBufUtils.bytesToHexString(maskArray));
-            int cidr = MatchConvertorUtil.ipv6NetmaskArrayToCIDRValue(maskArray);
-            LOG.debug("cidr = {}", cidr);
-            Assert.assertEquals(128 - i, cidr);
-
-            maskSeed = maskSeed.clearBit(i);
-        }
-    }
-
-    /**
-     * Test method for {@link MatchConvertorUtil#getIpv4Mask(byte[])}.
-     *
-     * @throws Exception
-     */
-
-    @Test
-    public void testGetIpv4Mask() {
-        byte[][] maskInputs = new byte[][]{
-                {(byte) 255, (byte) 255, (byte) 255, (byte) 255},
-                {(byte) 255, (byte) 255, (byte) 254, 0},
-                {(byte) 128, 0, 0, 0},
-                {0, 0, 0, 0},
-        };
-
-        String[] maskOutputs = new String[]{
-                "/32", "/23", "/1", "/0"
-        };
-
-        for (int i = 0; i < maskInputs.length; i++) {
-            String mask = MatchConvertorUtil.getIpv4Mask(maskInputs[i]);
-            Assert.assertEquals(maskOutputs[i], mask);
-        }
-    }
-
-    /**
-     * Test method for {@link MatchConvertorUtil#getIpv4Mask(byte[])}.
-     *
-     * @throws Exception
-     */
-
-    @Test
-    public void testGetIpv4MaskNegative() {
-        byte[][] maskInputs = new byte[][]{
-                {(byte) 127, 0, 0, 0},
-                {(byte) 127, 0, 0},
-        };
-
-        for (int i = 0; i < maskInputs.length; i++) {
-            try {
-                String mask = MatchConvertorUtil.getIpv4Mask(maskInputs[i]);
-                Assert.fail("invalid mask should not have passed: " + Arrays.toString(maskInputs[i]));
-            } catch (Exception e) {
-                // expected
-                LOG.info("ipv4 mask excepted exception: {}", e.getMessage(), e);
-            }
-        }
-    }
 }
index 13b27393c8b718bf2f839f5025096d39943e3830..6d06a9a00a608774ce04d7a2d4794b07f3e792e1 100644 (file)
@@ -9,12 +9,16 @@ package org.opendaylight.openflowplugin.testcommon;
 
 import static org.opendaylight.openflowjava.util.ByteBufUtils.macAddressToString;
 
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
@@ -52,8 +56,10 @@ abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseab
 
     static final long STARTUP_LOOP_TICK = 500L;
     static final int STARTUP_LOOP_MAX_RETRIES = 8;
+    private static final int PROCESSING_POOL_SIZE = 10000;
 
-    private final ExecutorService executorService = Executors.newFixedThreadPool(8);
+    private final int POOL_THREAD_AMOUNT = 8;
+    private final ExecutorService executorService;
 
 
     private static final AtomicIntegerFieldUpdater<AbstractDropTest> SENT_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "sent");
@@ -81,18 +87,40 @@ abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseab
         return new DropTestStats(this.sent, this.rcvd, this.excs, this.ftrFailed, this.ftrSuccess, this.runablesExecuted, this.runablesRejected);
     }
 
+    public AbstractDropTest() {
+        final ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(PROCESSING_POOL_SIZE);
+        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(POOL_THREAD_AMOUNT, POOL_THREAD_AMOUNT, 0,
+                TimeUnit.MILLISECONDS,
+                workQueue);
+        threadPool.setThreadFactory(new ThreadFactoryBuilder().setNameFormat("dropTest-%d").build());
+        threadPool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
+            @Override
+            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+                try {
+                    workQueue.put(r);
+                } catch (InterruptedException e) {
+                    throw new RejectedExecutionException("Interrupted while waiting on queue", e);
+                }
+            }
+        });
+
+        executorService = threadPool;
+    }
+
     public final void clearStats() {
         this.sent = 0;
         this.rcvd = 0;
         this.excs = 0;
         this.ftrSuccess = 0;
         this.ftrFailed = 0;
-
+        this.runablesExecuted = 0;
+        this.runablesRejected = 0;
     }
 
     private final void incrementRunableExecuted() {
         RUNABLES_EXECUTED.incrementAndGet(this);
     }
+
     private final void incrementRunableRejected() {
         RUNABLES_REJECTED.incrementAndGet(this);
     }
@@ -111,7 +139,7 @@ abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseab
                     processPacket(notification);
                 }
             });
-        } catch (RejectedExecutionException e){
+        } catch (Exception e) {
             incrementRunableRejected();
         }
         LOG.debug("onPacketReceived - Leaving", notification);
index 725c6cb957392698d6fa37cf669c49118c69fec9..a46aee82e286d56d20b84195ce2fadd4a3135b35 100644 (file)
@@ -38,7 +38,6 @@ public class DropTestStats {
         this.message = null;
         this.runablesExecuted = runablesExecuted;
         this.runablesRejected = runablesRejected;
-        runablesRejected = 0;
     }
 
     public DropTestStats(String message) {
@@ -79,6 +78,8 @@ public class DropTestStats {
             result.append(this.ftrFailed);
             result.append("\n run() executions :");
             result.append(this.runablesExecuted);
+            result.append("\n run() rejected :");
+            result.append(this.runablesRejected);
 
         } else {
             result.append(this.message);
index 0edbd7defecb940022fbb9af576103a8d78c8e67..906ebd94ba5a8f68cbf7bdd6b1cff89e1c0a1af5 100644 (file)
@@ -175,7 +175,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
-import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -197,11 +196,11 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
     private static NotificationService notificationService;
 
-    public OpenflowpluginTestCommandProvider(BundleContext ctx) {
+    public OpenflowpluginTestCommandProvider(final BundleContext ctx) {
         this.ctx = ctx;
     }
 
-    public void onSessionInitiated(ProviderContext session) {
+    public void onSessionInitiated(final ProviderContext session) {
         notificationService = session.getSALService(NotificationService.class);
         // For switch events
         notificationService.registerNotificationListener(flowEventListener);
@@ -211,7 +210,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         createTestFlow(createTestNode(null), null, null);
     }
 
-    private NodeBuilder createTestNode(String nodeId) {
+    private NodeBuilder createTestNode(final String nodeId) {
         String localNodeId;
 
         if (nodeId == null) {
@@ -220,20 +219,20 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
             localNodeId = nodeId;
         }
 
-        NodeBuilder builder = new NodeBuilder();
+        final NodeBuilder builder = new NodeBuilder();
         builder.setId(new NodeId(localNodeId));
         builder.setKey(new NodeKey(builder.getId()));
         return builder;
     }
 
-    private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
+    private InstanceIdentifier<Node> nodeBuilderToInstanceId(final NodeBuilder node) {
         return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
     }
 
-    private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
+    private FlowBuilder createTestFlow(final NodeBuilder nodeBuilder, final String flowTypeArg, final String tableId) {
         final long TEST_ID = 123;
 
-        FlowBuilder flow = new FlowBuilder();
+        final FlowBuilder flow = new FlowBuilder();
         long id = TEST_ID;
 
         String flowType = flowTypeArg;
@@ -688,11 +687,11 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
                 LOG.warn("flow type not understood: {}", flowType);
         }
 
-        FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
+        final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
         if (null == flow.isBarrier()) {
             flow.setBarrier(Boolean.FALSE);
         }
-        BigInteger value = BigInteger.valueOf(10);
+        final BigInteger value = BigInteger.valueOf(10);
         flow.setCookie(new FlowCookie(value));
         flow.setCookieMask(new FlowCookie(value));
         flow.setHardTimeout(0);
@@ -711,8 +710,8 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     }
 
 
-    private FlowBuilder createTestFlowPerfTest(String flowTypeArg, String tableId, int id) {
-        FlowBuilder flow = new FlowBuilder();
+    private FlowBuilder createTestFlowPerfTest(final String flowTypeArg, final String tableId, final int id) {
+        final FlowBuilder flow = new FlowBuilder();
         String flowType = flowTypeArg;
         int flowId = id;
 
@@ -732,11 +731,11 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
                 LOG.warn("flow type not understood: {}", flowType);
         }
 
-        FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
+        final FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
         if (null == flow.isBarrier()) {
             flow.setBarrier(Boolean.FALSE);
         }
-        BigInteger value = BigInteger.valueOf(10);
+        final BigInteger value = BigInteger.valueOf(10);
         flow.setCookie(new FlowCookie(value));
         flow.setCookieMask(new FlowCookie(value));
         flow.setHardTimeout(0);
@@ -755,25 +754,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     }
 
     private FlowBuilder createtablemiss() {
-        FlowBuilder flow = new FlowBuilder();
-        long id = 456;
-        MatchBuilder matchBuilder = new MatchBuilder();
+        final FlowBuilder flow = new FlowBuilder();
+        final long id = 456;
+        final MatchBuilder matchBuilder = new MatchBuilder();
         flow.setMatch(matchBuilder.build());
         flow.setInstructions(createSentToControllerInstructions().build());
         flow.setPriority(0);
         flow.setTableId((short) 0);
-        FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
+        final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
         flow.setKey(key);
         testFlow = flow;
         return flow;
     }
 
-    private short getTableId(String tableId) {
+    private short getTableId(final String tableId) {
         final short TABLE_ID = 2;
         short table = TABLE_ID;
         try {
             table = Short.parseShort(tableId);
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             LOG.info("Parsing String tableId {} failed. Continuing with default tableId {}.",
                     tableId, table);
         }
@@ -784,28 +783,28 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static InstructionsBuilder createDecNwTtlInstructions() {
-        DecNwTtlBuilder ta = new DecNwTtlBuilder();
-        DecNwTtl decNwTtl = ta.build();
-        ActionBuilder ab = new ActionBuilder();
+        final DecNwTtlBuilder ta = new DecNwTtlBuilder();
+        final DecNwTtl decNwTtl = ta.build();
+        final ActionBuilder ab = new ActionBuilder();
         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
         ab.setKey(new ActionKey(0));
         // Add our drop action to a list
-        List<Action> actionList = new ArrayList<Action>();
+        final List<Action> actionList = new ArrayList<Action>();
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         ib.setKey(new InstructionKey(0));
         ib.setOrder(0);
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         ib.setKey(new InstructionKey(0));
         isb.setInstruction(instructions);
@@ -817,15 +816,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      */
     private static InstructionsBuilder createMeterInstructions() {
 
-        MeterBuilder aab = new MeterBuilder();
+        final MeterBuilder aab = new MeterBuilder();
         aab.setMeterId(new MeterId(1L));
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -834,16 +833,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createMetadataInstructions() {
 
-        WriteMetadataBuilder aab = new WriteMetadataBuilder();
+        final WriteMetadataBuilder aab = new WriteMetadataBuilder();
         aab.setMetadata(BigInteger.valueOf(10));
         aab.setMetadataMask(BigInteger.valueOf(10));
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -852,15 +851,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createGotoTableInstructions() {
 
-        GoToTableBuilder aab = new GoToTableBuilder();
+        final GoToTableBuilder aab = new GoToTableBuilder();
         aab.setTableId((short) 5);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -868,26 +867,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     }
 
     private static InstructionsBuilder createDropInstructions() {
-        DropActionBuilder dab = new DropActionBuilder();
-        DropAction dropAction = dab.build();
-        ActionBuilder ab = new ActionBuilder();
+        final DropActionBuilder dab = new DropActionBuilder();
+        final DropAction dropAction = dab.build();
+        final ActionBuilder ab = new ActionBuilder();
         ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
         ab.setKey(new ActionKey(0));
         // Add our drop action to a list
-        List<Action> actionList = new ArrayList<Action>();
+        final List<Action> actionList = new ArrayList<Action>();
         actionList.add(ab.build());
         ab.setKey(new ActionKey(0));
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -896,24 +895,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ControllerActionBuilder controller = new ControllerActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ControllerActionBuilder controller = new ControllerActionBuilder();
         controller.setMaxLength(5);
         ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -922,27 +921,27 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction1() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        OutputActionBuilder output = new OutputActionBuilder();
+        final OutputActionBuilder output = new OutputActionBuilder();
         output.setMaxLength(56);
-        Uri value = new Uri("PCEP");
+        final Uri value = new Uri("PCEP");
         output.setOutputNodeConnector(value);
         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -954,116 +953,116 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         // test case for Output Port works if the particular port exists
         // this particular test-case is for Port : 1
         // tested as (addMDFlow openflow:<dpid> f82)
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        OutputActionBuilder output = new OutputActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final OutputActionBuilder output = new OutputActionBuilder();
 
-        Uri value = new Uri("1");
+        final Uri value = new Uri("1");
         output.setOutputNodeConnector(value);
         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
         ab.setOrder(0);
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
     }
 
     private static InstructionsBuilder createSentToControllerInstructions() {
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        OutputActionBuilder output = new OutputActionBuilder();
+        final OutputActionBuilder output = new OutputActionBuilder();
         output.setMaxLength(Integer.valueOf(0xffff));
-        Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
+        final Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
         output.setOutputNodeConnector(value);
         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
         ab.setOrder(0);
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
     }
 
-    private static InstructionsBuilder createOutputInstructions(String outputType, int outputValue) {
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+    private static InstructionsBuilder createOutputInstructions(final String outputType, final int outputValue) {
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        OutputActionBuilder output = new OutputActionBuilder();
+        final OutputActionBuilder output = new OutputActionBuilder();
         output.setMaxLength(outputValue);
-        Uri value = new Uri(outputType);
+        final Uri value = new Uri(outputType);
         output.setOutputNodeConnector(value);
         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
         ab.setOrder(0);
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
     }
 
     private static InstructionsBuilder createStripVlanInstructions() {
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
+        final StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
         ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
         ab.setOrder(0);
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -1071,25 +1070,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction2() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        PushMplsActionBuilder push = new PushMplsActionBuilder();
+        final PushMplsActionBuilder push = new PushMplsActionBuilder();
         push.setEthernetType(Integer.valueOf(0x8847));
         ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1098,25 +1097,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction3() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        PushPbbActionBuilder pbb = new PushPbbActionBuilder();
+        final PushPbbActionBuilder pbb = new PushPbbActionBuilder();
         pbb.setEthernetType(Integer.valueOf(0x88E7));
         ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1125,26 +1124,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction4() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        PushVlanActionBuilder vlan = new PushVlanActionBuilder();
+        final PushVlanActionBuilder vlan = new PushVlanActionBuilder();
         vlan.setEthernetType(Integer.valueOf(0x8100));
         ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1153,25 +1152,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction5() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
+        final SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
         setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
         ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1180,26 +1179,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction6() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
+        final SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
         src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
         ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1208,26 +1207,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction7() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
-        VlanId a = new VlanId(4000);
+        final SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
+        final VlanId a = new VlanId(4000);
         vl.setVlanId(a);
         ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1236,26 +1235,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction8() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
-        VlanPcp pcp1 = new VlanPcp((short) 2);
+        final SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
+        final VlanPcp pcp1 = new VlanPcp((short) 2);
         pcp.setVlanPcp(pcp1);
         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1264,27 +1263,27 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction88() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
+        final SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
         // the code point is a 3-bit(0-7) field representing the frame priority level
-        VlanPcp pcp1 = new VlanPcp((short) 4);
+        final VlanPcp pcp1 = new VlanPcp((short) 4);
         pcp.setVlanPcp(pcp1);
         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1293,24 +1292,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction9() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
+        final CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
         ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1319,24 +1318,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction10() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
+        final CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
         ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1345,26 +1344,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction11() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
+        final DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
         ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         ib.setKey(new InstructionKey(0));
         ib.setOrder(0);
 
         // Put our Instruction in a list of Instruction
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -1372,25 +1371,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction12() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
+        final DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1399,25 +1398,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction13() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        DropActionBuilder drop = new DropActionBuilder();
+        final DropActionBuilder drop = new DropActionBuilder();
         ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1426,24 +1425,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction14() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        FloodActionBuilder fld = new FloodActionBuilder();
+        final FloodActionBuilder fld = new FloodActionBuilder();
         ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1452,24 +1451,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction15() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        FloodAllActionBuilder fldall = new FloodAllActionBuilder();
+        final FloodAllActionBuilder fldall = new FloodAllActionBuilder();
         ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1478,10 +1477,10 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction16() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        GroupActionBuilder groupActionB = new GroupActionBuilder();
+        final GroupActionBuilder groupActionB = new GroupActionBuilder();
         groupActionB.setGroupId(1L);
         groupActionB.setGroup("0");
         ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
@@ -1489,16 +1488,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1507,24 +1506,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction17() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        HwPathActionBuilder hwPathB = new HwPathActionBuilder();
+        final HwPathActionBuilder hwPathB = new HwPathActionBuilder();
         ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1533,25 +1532,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction18() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
+        final LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
         ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1560,25 +1559,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction19() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
+        final PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
         popMplsActionBuilder.setEthernetType(0XB);
         ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1587,24 +1586,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction20() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
+        final PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
         ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1613,25 +1612,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction21() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
+        final PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
         ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1640,53 +1639,53 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction22() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
+        final SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
         setDlTypeActionBuilder.setDlType(new EtherType(8L));
         ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
     }
 
-    private static InstructionsBuilder createAppyActionInstruction23(NodeId nodeId) {
+    private static InstructionsBuilder createAppyActionInstruction23(final NodeId nodeId) {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
         setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1695,26 +1694,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction24() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
+        final SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
         setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
         ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1723,12 +1722,12 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction25() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
-        Ipv4Builder ipnext = new Ipv4Builder();
-        Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
+        final SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
+        final Ipv4Builder ipnext = new Ipv4Builder();
+        final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
         ipnext.setIpv4Address(prefix);
         setNextHopActionBuilder.setAddress(ipnext.build());
         ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
@@ -1736,16 +1735,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1754,12 +1753,12 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction26() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
-        Ipv4Builder ipdst = new Ipv4Builder();
-        Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
+        final SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+        final Ipv4Builder ipdst = new Ipv4Builder();
+        final Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
         ipdst.setIpv4Address(prefixdst);
         setNwDstActionBuilder.setAddress(ipdst.build());
         ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
@@ -1767,16 +1766,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1785,12 +1784,12 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction27() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
-        Ipv4Builder ipsrc = new Ipv4Builder();
-        Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
+        final SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
+        final Ipv4Builder ipsrc = new Ipv4Builder();
+        final Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
         ipsrc.setIpv4Address(prefixsrc);
         setNwsrcActionBuilder.setAddress(ipsrc.build());
         ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
@@ -1798,16 +1797,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1816,25 +1815,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction28() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
+        final SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
         setNwTosActionBuilder.setTos(8);
         ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1843,26 +1842,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction29() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
+        final SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
         setNwTtlActionBuilder.setNwTtl((short) 1);
         ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1871,25 +1870,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction30() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
+        final SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
         setQueueActionBuilder.setQueueId(1L);
         ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1898,26 +1897,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction31() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
+        final SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
         setTpDstActionBuilder.setPort(new PortNumber(109));
 
         ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1926,26 +1925,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction32() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
+        final SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
         setTpSrcActionBuilder.setPort(new PortNumber(109));
         ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1954,26 +1953,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction33() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
+        final SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
         setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
         ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -1982,25 +1981,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction34() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
 
-        SwPathActionBuilder swPathAction = new SwPathActionBuilder();
+        final SwPathActionBuilder swPathAction = new SwPathActionBuilder();
         ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
         // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
         // Wrap our Apply Action in an Instruction
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -2009,24 +2008,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction35() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
-        ActionBuilder ab2 = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
+        final ActionBuilder ab2 = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
 
         // Ethernet
-        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
-        EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+        final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+        final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
-        EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
-        EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
+        final EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
+        final EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
         ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
-        EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x86ddL));
 
         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
@@ -2047,16 +2046,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab2.setKey(new ActionKey(2));
         actionList.add(ab2.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
         isb.setInstruction(instructions);
@@ -2065,19 +2064,19 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction36() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
 
         // Vlan
-        VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
-        VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
-        VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
-        VlanId vlanId = new VlanId(10);
-        VlanPcp vpcp = new VlanPcp((short) 3);
+        final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
+        final VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
+        final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+        final VlanId vlanId = new VlanId(10);
+        final VlanPcp vpcp = new VlanPcp((short) 3);
         vlanBuilder.setVlanPcp(vpcp);
         vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
         setFieldBuilder.setVlanMatch(vlanBuilder.build());
@@ -2089,16 +2088,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab1.setKey(new ActionKey(1));
         actionList.add(ab1.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2106,19 +2105,19 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction37() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
-        ActionBuilder ab2 = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
+        final ActionBuilder ab2 = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
         // Ip
-        IpMatchBuilder ipmatch = new IpMatchBuilder();
-        IpMatchBuilder ipmatch1 = new IpMatchBuilder();
-        IpMatchBuilder ipmatch2 = new IpMatchBuilder();
-        Dscp dscp = new Dscp((short) 3);
+        final IpMatchBuilder ipmatch = new IpMatchBuilder();
+        final IpMatchBuilder ipmatch1 = new IpMatchBuilder();
+        final IpMatchBuilder ipmatch2 = new IpMatchBuilder();
+        final Dscp dscp = new Dscp((short) 3);
         ipmatch.setIpDscp(dscp);
         ipmatch1.setIpEcn((short) 2);
         ipmatch2.setIpProtocol((short) 120);
@@ -2137,16 +2136,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab2.setKey(new ActionKey(2));
         actionList.add(ab2.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2154,17 +2153,17 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction38() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
         // IPv4
-        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
-        Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
-        Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
-        Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
+        final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        final Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
+        final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
+        final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
         ipv4Match1.setIpv4Destination(dstip);
         ipv4Match.setIpv4Source(srcip);
         setFieldBuilder.setLayer3Match(ipv4Match.build());
@@ -2177,16 +2176,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab1.setKey(new ActionKey(1));
         actionList.add(ab1.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2194,18 +2193,18 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction39() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
 
         // Tcp
-        PortNumber tcpsrcport = new PortNumber(1213);
-        PortNumber tcpdstport = new PortNumber(646);
-        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
-        TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
+        final PortNumber tcpsrcport = new PortNumber(1213);
+        final PortNumber tcpdstport = new PortNumber(646);
+        final TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
+        final TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
         tcpmatch.setTcpSourcePort(tcpsrcport);
         tcpmatch1.setTcpDestinationPort(tcpdstport);
         setFieldBuilder.setLayer4Match(tcpmatch.build());
@@ -2218,16 +2217,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab1.setKey(new ActionKey(1));
         actionList.add(ab.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2235,18 +2234,18 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction40() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
 
         // Udp
-        PortNumber udpsrcport = new PortNumber(1325);
-        PortNumber udpdstport = new PortNumber(42);
-        UdpMatchBuilder udpmatch = new UdpMatchBuilder();
-        UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
+        final PortNumber udpsrcport = new PortNumber(1325);
+        final PortNumber udpdstport = new PortNumber(42);
+        final UdpMatchBuilder udpmatch = new UdpMatchBuilder();
+        final UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
         udpmatch.setUdpDestinationPort(udpdstport);
         udpmatch1.setUdpSourcePort(udpsrcport);
         setFieldBuilder.setLayer4Match(udpmatch.build());
@@ -2259,16 +2258,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab1.setKey(new ActionKey(1));
         actionList.add(ab1.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2276,18 +2275,18 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction41() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
 
         // Sctp
-        SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
-        SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
-        PortNumber srcport = new PortNumber(1435);
-        PortNumber dstport = new PortNumber(22);
+        final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
+        final SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
+        final PortNumber srcport = new PortNumber(1435);
+        final PortNumber dstport = new PortNumber(22);
         sctpmatch.setSctpSourcePort(srcport);
         sctpmatch1.setSctpDestinationPort(dstport);
         setFieldBuilder.setLayer4Match(sctpmatch.build());
@@ -2300,16 +2299,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab1.setKey(new ActionKey(1));
         actionList.add(ab1.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2317,15 +2316,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction42() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
 
         // Icmpv4
-        Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
-        Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
+        final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
+        final Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
         icmpv4match.setIcmpv4Type((short) 8);
         icmpv4match1.setIcmpv4Code((short) 0);
         setFieldBuilder.setIcmpv4Match(icmpv4match.build());
@@ -2338,16 +2337,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab1.setKey(new ActionKey(1));
         actionList.add(ab1.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2355,33 +2354,33 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction43() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
-        ActionBuilder ab2 = new ActionBuilder();
-        ActionBuilder ab3 = new ActionBuilder();
-        ActionBuilder ab4 = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
+        final ActionBuilder ab2 = new ActionBuilder();
+        final ActionBuilder ab3 = new ActionBuilder();
+        final ActionBuilder ab4 = new ActionBuilder();
 
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
-        SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
+        final SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
 
         // setting the values of ARP
-        MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
-        MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
-        Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
-        Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
+        final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
+        final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
+        final Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
+        final Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
         // create ARP match action
-        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
-        ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
-        ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
-        ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
-        ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
-        ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
+        final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
+        final ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
+        final ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
+        final ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
+        final ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
+        final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
         arpsrc.setAddress(macsrc);
-        ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
+        final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
         arpdst.setAddress(macdest);
         arpmatch.setArpOp(2);
         arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
@@ -2413,16 +2412,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab4.setKey(new ActionKey(4));
         actionList.add(ab4.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2430,28 +2429,28 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction44() {
 
-        List<Action> actionLists = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
-        ActionBuilder ab5 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
-        ActionBuilder ab6 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
+        final List<Action> actionLists = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final ActionBuilder ab5 = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
+        final ActionBuilder ab6 = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
 
         // IPv6
-        Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
-        Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
-        Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
-        Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
-
-        Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
-        Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
-        Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
+        final Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
+        final Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
+        final Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
+        final Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
+
+        final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/128");
+        final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/128");
+        final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
         nextheader.setIpv6Exthdr(58);
-        Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
-        Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
+        final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
+        final Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
         ipv6label.setIpv6Flabel(label);
 
         ipv6Builder.setIpv6Source(srcip6);
@@ -2479,16 +2478,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab6.setKey(new ActionKey(6));
         actionLists.add(ab6.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionLists);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2496,15 +2495,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction45() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
 
         // Icmpv6
-        Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
-        Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
+        final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
+        final Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
         icmpv6match.setIcmpv6Type((short) 135);
         icmpv6match1.setIcmpv6Code((short) 0);
         setFieldBuilder.setIcmpv6Match(icmpv6match.build());
@@ -2517,16 +2516,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab1.setKey(new ActionKey(1));
         actionList.add(ab1.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2534,18 +2533,18 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction46() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        ActionBuilder ab1 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
-        ActionBuilder ab2 = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final ActionBuilder ab1 = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+        final ActionBuilder ab2 = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
 
         // MPLS
-        ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
-        ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
-        ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
+        final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
+        final ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
+        final ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
         protomatch.setMplsLabel((long) 36008);
         protomatch1.setMplsTc((short) 4);
         protomatch2.setMplsBos((short) 1);
@@ -2564,16 +2563,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab2.setKey(new ActionKey(2));
         actionList.add(ab2.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2581,26 +2580,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction47() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
         // PBB
-        ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
+        final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask((new BigInteger(new byte[]{0, 1, 0, 0}).longValue())).build());
         setFieldBuilder.setProtocolMatchFields(protomatch.build());
         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
         actionList.add(ab.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2608,27 +2607,27 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createAppyActionInstruction48() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
         // Tunnel
-        TunnelBuilder tunnel = new TunnelBuilder();
+        final TunnelBuilder tunnel = new TunnelBuilder();
         tunnel.setTunnelId(BigInteger.valueOf(10668));
         setFieldBuilder.setTunnel(tunnel.build());
         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
 
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
 
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
 
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2636,13 +2635,13 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createTunnelIpv4DstInstructions() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
         // Build the tunnel endpoint destination IPv4 address
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.100");
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.100");
         // Add the mew IPv4 object as the tunnel destination
-        TunnelIpv4MatchBuilder tunnelIpv4DstMatchBuilder = new TunnelIpv4MatchBuilder();
+        final TunnelIpv4MatchBuilder tunnelIpv4DstMatchBuilder = new TunnelIpv4MatchBuilder();
         tunnelIpv4DstMatchBuilder.setTunnelIpv4Destination(dstIp);
         setFieldBuilder.setLayer3Match(tunnelIpv4DstMatchBuilder.build());
         // Add the IPv4 tunnel dst to the set_field value
@@ -2651,16 +2650,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_dst)
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
         // Add the action to the ordered list of Instructions
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         // Add the Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
@@ -2668,13 +2667,13 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static InstructionsBuilder createTunnelIpv4SrcInstructions() {
 
-        List<Action> actionList = new ArrayList<Action>();
-        ActionBuilder ab = new ActionBuilder();
+        final List<Action> actionList = new ArrayList<Action>();
+        final ActionBuilder ab = new ActionBuilder();
         // Build the tunnel endpoint source IPv4 address
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.200");
+        final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        final Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.200");
         // Add the new IPv4 object as the tunnel destination
-        TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
+        final TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
         tunnelIpv4MatchBuilder.setTunnelIpv4Source(dstIp);
         setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
         // Add the IPv4 tunnel src to the set_field value
@@ -2683,25 +2682,25 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         ab.setKey(new ActionKey(0));
         actionList.add(ab.build());
         // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
         aab.setAction(actionList);
         // Add the action to the ordered list of Instructions
-        InstructionBuilder ib = new InstructionBuilder();
+        final InstructionBuilder ib = new InstructionBuilder();
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
         // Put our Instruction in a list of Instructions
-        InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        final InstructionsBuilder isb = new InstructionsBuilder();
+        final List<Instruction> instructions = new ArrayList<Instruction>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
         return isb;
     }
 
     private static MatchBuilder createLLDPMatch() {
-        MatchBuilder match = new MatchBuilder();
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final MatchBuilder match = new MatchBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x88ccL));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
@@ -2712,15 +2711,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createMatch1() {
-        MatchBuilder match = new MatchBuilder();
-        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
-        Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);;
+        final MatchBuilder match = new MatchBuilder();
+        final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);;
         ipv4Match.setIpv4Destination(prefix);
-        Ipv4Match i4m = ipv4Match.build();
+        final Ipv4Match i4m = ipv4Match.build();
         match.setLayer3Match(i4m);
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x0800L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
@@ -2732,15 +2731,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createMatch2() {
-        MatchBuilder match = new MatchBuilder();
-        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
-        Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
+        final MatchBuilder match = new MatchBuilder();
+        final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
         ipv4Match.setIpv4Source(prefix);
-        Ipv4Match i4m = ipv4Match.build();
+        final Ipv4Match i4m = ipv4Match.build();
         match.setLayer3Match(i4m);
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x0800L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
@@ -2751,9 +2750,9 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createMatch3() {
-        MatchBuilder match = new MatchBuilder();
-        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
-        EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+        final MatchBuilder match = new MatchBuilder();
+        final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+        final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
         match.setEthernetMatch(ethernetMatch.build());
@@ -2766,20 +2765,20 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      */
     private static MatchBuilder createICMPv6Match1() {
 
-        MatchBuilder match = new MatchBuilder();
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final MatchBuilder match = new MatchBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x86ddL));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
         // ipv4 version
-        IpMatchBuilder ipmatch = new IpMatchBuilder();
+        final IpMatchBuilder ipmatch = new IpMatchBuilder();
         ipmatch.setIpProtocol((short) 256);
         match.setIpMatch(ipmatch.build());
 
         // icmpv6
-        Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
+        final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
 
         // match
         icmpv6match.setIcmpv6Type((short) 135);
@@ -2791,47 +2790,47 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     private static MatchBuilder createMatch33() {
 
-        MatchBuilder match = new MatchBuilder();
-        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
-        Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
+        final MatchBuilder match = new MatchBuilder();
+        final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
         ipv4Match.setIpv4Source(prefix);
-        Ipv4Match i4m = ipv4Match.build();
+        final Ipv4Match i4m = ipv4Match.build();
         match.setLayer3Match(i4m);
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0xfffeL));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
         return match;
     }
 
-    private static MatchBuilder createInphyportMatch(NodeId nodeId) {
-        MatchBuilder match = new MatchBuilder();
+    private static MatchBuilder createInphyportMatch(final NodeId nodeId) {
+        final MatchBuilder match = new MatchBuilder();
         match.setInPort(new NodeConnectorId(nodeId + ":202"));
         match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
         return match;
     }
 
     private static MatchBuilder createEthernetMatch() {
-        MatchBuilder match = new MatchBuilder();
-        EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
+        final MatchBuilder match = new MatchBuilder();
+        final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
         // match
-        EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
-        EtherType type = new EtherType(0x0800L);
+        final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+        final EtherType type = new EtherType(0x0800L);
         ethmatch.setEthernetType(ethtype.setType(type).build());
 
-        EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
+        final EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
         // macaddress
         // match
-        MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
+        final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
         ethdest.setAddress(macdest);
         ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
 
         ethmatch.setEthernetDestination(ethdest.build());
 
-        EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
-        MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
+        final EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
+        final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
         ethsrc.setAddress(macsrc);
         ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
 
@@ -2846,12 +2845,12 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      */
 
     private static MatchBuilder createVlanMatch() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
         // vlan match
-        VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
-        VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
-        VlanId vlanId = new VlanId(10);
-        VlanPcp vpcp = new VlanPcp((short) 3);
+        final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
+        final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+        final VlanId vlanId = new VlanId(10);
+        final VlanPcp vpcp = new VlanPcp((short) 3);
         vlanBuilder.setVlanPcp(vpcp);
         vlanIdBuilder.setVlanId(vlanId);
         vlanIdBuilder.setVlanIdPresent(true);
@@ -2864,26 +2863,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createArpMatch() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
-        EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
-        MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
-        MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
+        final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
+        final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
+        final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
 
-        EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
-        EtherType type = new EtherType(0x0806L);
+        final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+        final EtherType type = new EtherType(0x0806L);
         ethmatch.setEthernetType(ethtype.setType(type).build());
 
         // ipv4 match
-        Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
-        Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
+        final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
+        final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
 
         // arp match
-        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
-        ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
+        final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
+        final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
         arpsrc.setAddress(macsrc);
         arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
-        ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
+        final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
         arpdst.setAddress(macdest);
         arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
         arpmatch.setArpOp(2);
@@ -2903,19 +2902,19 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createL3IPv4Match() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x0800L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
         // ipv4 match
-        Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
-        Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
-        Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
+        final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
+        final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
+        final Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
         ipv4match.setIpv4Destination(dstip);
         ipv4match.setIpv4Source(srcip);
         match.setLayer3Match(ipv4match.build());
@@ -2928,33 +2927,33 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createL3IPv6Match() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x86ddL));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
-        Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
-        Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
-        MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
-        MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
-        Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
+        final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
+        final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
+        final Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
+        final MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
+        final MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
+        final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
         nextheader.setIpv6Exthdr(58);
-        Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
-        Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
+        final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
+        final Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
         ipv6label.setIpv6Flabel(label);
         ipv6label.setFlabelMask(new Ipv6FlowLabel(1L));
 
-        Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
+        final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
         // match
         icmpv6match.setIcmpv6Type((short) 135);
         icmpv6match.setIcmpv6Code((short) 0);
         match.setIcmpv6Match(icmpv6match.build());
 
-        Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
+        final Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
         // ipv6match.setIpv6Source(srcip6);
         // ipv6match.setIpv6Destination(dstip6);
         // ipv6match.setIpv6ExtHeader(nextheader.build());
@@ -2973,18 +2972,18 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      */
 
     private static MatchBuilder createICMPv4Match() {
-        MatchBuilder match = new MatchBuilder();
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final MatchBuilder match = new MatchBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x0800L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+        final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
         ipmatch.setIpProtocol((short) 1);
         match.setIpMatch(ipmatch.build());
 
-        Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
+        final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
         // match
         icmpv4match.setIcmpv4Type((short) 8);
         icmpv4match.setIcmpv4Code((short) 0);
@@ -2997,18 +2996,18 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      */
     private static MatchBuilder createICMPv6Match() {
 
-        MatchBuilder match = new MatchBuilder();
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final MatchBuilder match = new MatchBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x86ddL));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+        final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
         ipmatch.setIpProtocol((short) 58);
         match.setIpMatch(ipmatch.build());
 
-        Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
+        final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
         // match
         icmpv6match.setIcmpv6Type((short) 135);
         icmpv6match.setIcmpv6Code((short) 1);
@@ -3021,16 +3020,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createToSMatch() {
-        MatchBuilder match = new MatchBuilder();
-        EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
-        EtherType type = new EtherType(0x0800L);
+        final MatchBuilder match = new MatchBuilder();
+        final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+        final EtherType type = new EtherType(0x0800L);
         ethmatch.setEthernetType(ethtype.setType(type).build());
         match.setEthernetMatch(ethmatch.build());
 
-        IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+        final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
         ipmatch.setIpProtocol((short) 6);
-        Dscp dscp = new Dscp((short) 8);
+        final Dscp dscp = new Dscp((short) 8);
         ipmatch.setIpDscp(dscp);
         match.setIpMatch(ipmatch.build());
         return match;
@@ -3041,21 +3040,21 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      */
 
     private static MatchBuilder createL4TCPMatch() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x0800L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+        final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
         ipmatch.setIpProtocol((short) 6);
         match.setIpMatch(ipmatch.build());
 
-        PortNumber srcport = new PortNumber(1213);
-        PortNumber dstport = new PortNumber(646);
-        TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
+        final PortNumber srcport = new PortNumber(1213);
+        final PortNumber dstport = new PortNumber(646);
+        final TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
         tcpmatch.setTcpSourcePort(srcport);
         tcpmatch.setTcpDestinationPort(dstport);
         match.setLayer4Match(tcpmatch.build());
@@ -3067,21 +3066,21 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createL4UDPMatch() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x0800L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+        final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
         ipmatch.setIpProtocol((short) 17);
         match.setIpMatch(ipmatch.build());
 
-        PortNumber srcport = new PortNumber(1325);
-        PortNumber dstport = new PortNumber(42);
-        UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
+        final PortNumber srcport = new PortNumber(1325);
+        final PortNumber dstport = new PortNumber(42);
+        final UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
         udpmatch.setUdpDestinationPort(dstport);
         udpmatch.setUdpSourcePort(srcport);
         match.setLayer4Match(udpmatch.build());
@@ -3093,21 +3092,21 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createL4SCTPMatch() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x0800L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+        final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
         ipmatch.setIpProtocol((short) 132);
         match.setIpMatch(ipmatch.build());
 
-        SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
-        PortNumber srcport = new PortNumber(1435);
-        PortNumber dstport = new PortNumber(22);
+        final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
+        final PortNumber srcport = new PortNumber(1435);
+        final PortNumber dstport = new PortNumber(22);
         sctpmatch.setSctpSourcePort(srcport);
         sctpmatch.setSctpDestinationPort(dstport);
         match.setLayer4Match(sctpmatch.build());
@@ -3119,9 +3118,9 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createMetadataMatch() {
-        MatchBuilder match = new MatchBuilder();
-        byte[] metamask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
-        MetadataBuilder metadata = new MetadataBuilder(); // metadata match
+        final MatchBuilder match = new MatchBuilder();
+        final byte[] metamask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
+        final MetadataBuilder metadata = new MetadataBuilder(); // metadata match
         metadata.setMetadata(BigInteger.valueOf(500L));
         metadata.setMetadataMask(new BigInteger(1, metamask));
         match.setMetadata(metadata.build());
@@ -3133,15 +3132,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createMplsMatch() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x8847L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
+        final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
         // match
         protomatch.setMplsLabel((long) 36008);
         protomatch.setMplsTc((short) 4);
@@ -3156,15 +3155,15 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createPbbMatch() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x88E7L));
         eth.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(eth.build());
 
-        ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
+        final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
         // match
         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new BigInteger(new byte[]{0, 1, 0, 0}).longValue()).build());
         match.setProtocolMatchFields(protomatch.build());
@@ -3177,10 +3176,10 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * @return
      */
     private static MatchBuilder createTunnelIDMatch() {
-        MatchBuilder match = new MatchBuilder();
-        TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
+        final MatchBuilder match = new MatchBuilder();
+        final TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
         tunnel.setTunnelId(BigInteger.valueOf(10668));
-        byte[] mask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
+        final byte[] mask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
         tunnel.setTunnelMask(new BigInteger(1, mask));
         match.setTunnel(tunnel.build());
 
@@ -3194,23 +3193,23 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      */
     //FIXME: move to extensible support
     private static MatchBuilder createTcpFlagMatch() {
-        MatchBuilder match = new MatchBuilder();
+        final MatchBuilder match = new MatchBuilder();
 
         // Ethertype match
-        EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        final EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
+        final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
         ethTypeBuilder.setType(new EtherType(0x0800L));
         ethernetType.setEthernetType(ethTypeBuilder.build());
         match.setEthernetMatch(ethernetType.build());
 
         // TCP Protocol Match
-        IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
+        final IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
         ipMatch.setIpProtocol((short) 6);
         match.setIpMatch(ipMatch.build());
 
         // TCP Port Match
-        PortNumber dstPort = new PortNumber(80);
-        TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
+        final PortNumber dstPort = new PortNumber(80);
+        final TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
         tcpMatch.setTcpDestinationPort(dstPort);
         match.setLayer4Match(tcpMatch.build());
         /**
@@ -3219,7 +3218,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
          * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
          * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS  0x100
          */
-        TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
+        final TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
         tcpFlagMatch.setTcpFlag(0x002);
         match.setTcpFlagMatch(tcpFlagMatch.build());
 
@@ -3227,28 +3226,28 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     }
 
     public void _removeMDFlow(final CommandInterpreter ci) {
-        ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
-        NodeBuilder tn = createTestNode(ci.nextArgument());
-        String flowtype = ci.nextArgument();
+        final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
+        final NodeBuilder tn = createTestNode(ci.nextArgument());
+        final String flowtype = ci.nextArgument();
         FlowBuilder tf;
         if (flowtype.equals("fTM")) {
             tf = createtablemiss();
         } else {
             tf = createTestFlow(tn, flowtype, ci.nextArgument());
         }
-        InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
+        final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
                 .child(Flow.class, tf.getKey());
         modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
-        CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
+        final CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
         Futures.addCallback(commitFuture, new FutureCallback<Void>() {
             @Override
-            public void onSuccess(Void aVoid) {
+            public void onSuccess(final Void aVoid) {
                 ci.println("Status of Group Data Loaded Transaction: success.");
             }
 
             @Override
-            public void onFailure(Throwable throwable) {
+            public void onFailure(final Throwable throwable) {
                 LOG.error(throwable.getMessage(), throwable);
                 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
             }
@@ -3262,9 +3261,9 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      *                     e.g.: addMDFlow openflow:1 f1 42
      *                     </pre>
      */
-    public void _addMDFlow(CommandInterpreter ci) {
-        NodeBuilder tn = createTestNode(ci.nextArgument());
-        String flowtype = ci.nextArgument();
+    public void _addMDFlow(final CommandInterpreter ci) {
+        final NodeBuilder tn = createTestNode(ci.nextArgument());
+        final String flowtype = ci.nextArgument();
         FlowBuilder tf;
         if (flowtype.equals("fTM")) {
             tf = createtablemiss();
@@ -3274,40 +3273,40 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         writeFlow(ci, tf, tn);
     }
 
-    private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
-        ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
-        InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
+    private void writeFlow(final CommandInterpreter ci, final FlowBuilder flow, final NodeBuilder nodeBuilder) {
+        final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
+        final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
         modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
         modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
-        CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
+        final CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
         Futures.addCallback(commitFuture, new FutureCallback<Void>() {
             @Override
-            public void onSuccess(Void aVoid) {
+            public void onSuccess(final Void aVoid) {
                 ci.println("Status of Group Data Loaded Transaction: success.");
             }
 
             @Override
-            public void onFailure(Throwable throwable) {
+            public void onFailure(final Throwable throwable) {
                 LOG.error(throwable.getMessage(), throwable);
                 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
             }
         });
     }
 
-    public void _modifyMDFlow(CommandInterpreter ci) {
-        NodeBuilder tn = createTestNode(ci.nextArgument());
-        FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
+    public void _modifyMDFlow(final CommandInterpreter ci) {
+        final NodeBuilder tn = createTestNode(ci.nextArgument());
+        final FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
         tf.setFlowName(UPDATED_FLOW_NAME);
         writeFlow(ci, tf, tn);
         tf.setFlowName(ORIGINAL_FLOW_NAME);
         writeFlow(ci, tf, tn);
     }
 
-    private static NodeRef createNodeRef(String string) {
-        NodeKey key = new NodeKey(new NodeId(string));
-        InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
+    private static NodeRef createNodeRef(final String string) {
+        final NodeKey key = new NodeKey(new NodeId(string));
+        final InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
 
         return new NodeRef(path);
     }
@@ -3321,13 +3320,13 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
      * ex: _perfFlowTest 10 5 1 2
      */
-    public void _perfFlowTest(CommandInterpreter ci) {
+    public void _perfFlowTest(final CommandInterpreter ci) {
 
-        String numberOfSwtichesStr = ci.nextArgument();
-        String numberOfFlowsStr = ci.nextArgument();
-        String warmupIterationsStr = ci.nextArgument();
-        String threadCountStr = ci.nextArgument();
-        String warmUpStr = ci.nextArgument();
+        final String numberOfSwtichesStr = ci.nextArgument();
+        final String numberOfFlowsStr = ci.nextArgument();
+        final String warmupIterationsStr = ci.nextArgument();
+        final String threadCountStr = ci.nextArgument();
+        final String warmUpStr = ci.nextArgument();
 
         Collection<String> testResults = null;
         if (testResults == null) {
@@ -3378,7 +3377,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         String dataPath = "openflow:1";
         NodeBuilder tn;
         FlowBuilder tf;
-        String tableId = "0";
+        final String tableId = "0";
         if (warmUpIterations) {
             ci.println("----Warmup Started-----");
             for (int j = 1; j <= warmupIterations; j++) {
@@ -3395,16 +3394,16 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
             ci.println("----Warmup Done-----");
         }
         try {
-            ExecutorService executor = Executors.newFixedThreadPool(threadCount);
+            final ExecutorService executor = Executors.newFixedThreadPool(threadCount);
             int tableID = 0;
             for (int t = 0; t < threadCount; t++) {
                 tableID = t + 1;
-                Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
+                final Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
                 executor.execute(tRunnable);
             }
             executor.shutdown();
             executor.awaitTermination(1, TimeUnit.SECONDS);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             ci.println("Exception:" + e.getMessage());
         }
     }
@@ -3420,7 +3419,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         Collection<String> testResults = null;
         int tableID = 0;
 
-        TestFlowThread(int numberOfSwtiches, int numberOfFlows, CommandInterpreter ci, int t, int tableID) {
+        TestFlowThread(final int numberOfSwtiches, final int numberOfFlows, final CommandInterpreter ci, final int t, final int tableID) {
             this.numberOfSwitches = numberOfSwtiches;
             this.numberOfFlows = numberOfFlows;
             this.ci = ci;
@@ -3443,7 +3442,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
             ci.println("New Thread started with id:  ID_"
                     + this.theadNumber);
             int totalNumberOfFlows = 0;
-            long startTime = System.currentTimeMillis();
+            final long startTime = System.currentTimeMillis();
 
             for (int i = 1; i <= this.numberOfSwitches; i++) {
                 dataPath = "openflow:" + i;
@@ -3454,8 +3453,8 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
                     totalNumberOfFlows++;
                 }
             }
-            long endTime = System.currentTimeMillis();
-            long timeInSeconds = Math.round((endTime - startTime) / 1000);
+            final long endTime = System.currentTimeMillis();
+            final long timeInSeconds = Math.round((endTime - startTime) / 1000);
             if (timeInSeconds > 0) {
                 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + Math.round(totalNumberOfFlows / timeInSeconds));
             } else {
@@ -3469,24 +3468,24 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
      * usage testAllFlows <dp>
      * ex: _perfFlowTest 1
      */
-    public void _testAllFlows(CommandInterpreter ci) {
+    public void _testAllFlows(final CommandInterpreter ci) {
         String dataPathID = ci.nextArgument();
-        int numberOfFlows = 82;
+        final int numberOfFlows = 82;
         if (dataPathID == null || dataPathID.trim().equals("")) {
             dataPathID = "1";
         }
         ci.println("*     Test All Flows       *");
         ci.println("*     dataPathID:::" + dataPathID + "");
-        String dataPath = "openflow:" + dataPathID;
-        String tableId = "0";
-        NodeBuilder tn = createTestNode(dataPath);
+        final String dataPath = "openflow:" + dataPathID;
+        final String tableId = "0";
+        final NodeBuilder tn = createTestNode(dataPath);
         FlowBuilder tf;
         for (int flow = 1; flow < numberOfFlows; flow++) {
-            String flowID = "f" + flow;
+            final String flowID = "f" + flow;
             try {
                 tf = createTestFlow(tn, flowID, tableId);
                 writeFlow(ci, tf, tn);
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 ci.println("--Test Failed--Issue found while adding flow" + flow);
                 break;
             }