BUG-4118: Li:backward compatibility - rpcs - stats services 68/26668/6
authorMichal Rehak <mirehak@cisco.com>
Tue, 8 Sep 2015 19:19:32 +0000 (21:19 +0200)
committerMichal Rehak <mirehak@cisco.com>
Fri, 27 Nov 2015 13:41:02 +0000 (14:41 +0100)
 - added flow statistics services with notification emitting feature
 - added group statistics services with notification emitting feature
 - added meter statistics services with notification emitting feature
 - added port statistics services with notification emitting feature
 - added queue statistics services with notification emitting feature
 - added tests

Change-Id: Iffc6637e6f1a81be11cb9ef9479557837195c678
Signed-off-by: Michal Rehak <mirehak@cisco.com>
38 files changed:
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInAllTablesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllGroupsStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllPortStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesAllPortsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesOnePortService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/FlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OneQueueOnePortService.java
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
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/FlowStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImpl.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractStatsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl1Test.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl3Test.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/PortStatsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java [new file with mode: 0644]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java [new file with mode: 0644]

index baaedcbd7b949b10b8cab3175dd1521dd7114c09..e71017b4780b049c2b5ed0dba7c91a0e96966476 100644 (file)
@@ -7,24 +7,39 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import com.google.common.base.Preconditions;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
 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.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
+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.flow.transaction.rev150304.TransactionId;
 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.OfHeader;
+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.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);
+public final class AggregateFlowsInTableService extends AbstractCompatibleStatService<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput,
+        GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput, AggregateFlowStatisticsUpdate> {
+
+    public AggregateFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -50,4 +65,28 @@ final class AggregateFlowsInTableService extends AbstractSimpleService<GetAggreg
 
         return mprInput.build();
     }
+
+    @Override
+    public GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public AggregateFlowStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        final int mpSize = result.size();
+        Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
+
+        TranslatorLibrary translatorLibrary = getDeviceContext().oook();
+        MultipartReply mpReply = result.get(0);
+        final TranslatorKey translatorKey = new TranslatorKey(mpReply.getVersion(), MultipartReplyAggregateCase.class.getName());
+        final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
+
+        final AggregatedFlowStatistics flowStatistics = messageTranslator.translate(mpReply, getDeviceContext(), null);
+        final AggregateFlowStatisticsUpdateBuilder notification = new AggregateFlowStatisticsUpdateBuilder(flowStatistics)
+                .setId(getDeviceContext().getDeviceState().getNodeId())
+                .setMoreReplies(Boolean.FALSE)
+                .setTransactionId(emulatedTxId);
+
+        return notification.build();
+    }
 }
index d8b1f15bdd0053c63d8aaa5dc4007802db6fae1b..6122156efa4b82b293147ab9d89888401e29eea5 100644 (file)
@@ -7,27 +7,36 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 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.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.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> {
+public final class AllFlowsInAllTablesService extends AbstractCompatibleStatService<GetAllFlowsStatisticsFromAllFlowTablesInput,
+        GetAllFlowsStatisticsFromAllFlowTablesOutput, FlowsStatisticsUpdate> {
     private final MultipartRequestFlowCase flowCase;
 
-    AllFlowsInAllTablesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetAllFlowsStatisticsFromAllFlowTablesOutput.class);
+    public AllFlowsInAllTablesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
+                                      final AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
 
         final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
         final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
@@ -50,4 +59,14 @@ final class AllFlowsInAllTablesService extends AbstractSimpleService<GetAllFlows
 
         return mprInput.build();
     }
+
+    @Override
+    public GetAllFlowsStatisticsFromAllFlowTablesOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 9ce0f89fed5cc3cf5a6db14f0280c77f22fe1a18..86e7208c07f3884617d0d94ca6ad57a4a9803a4b 100644 (file)
@@ -7,25 +7,37 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import com.google.common.base.Function;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 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.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.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;
+import org.opendaylight.yangtools.yang.common.RpcResult;
 
-public class AllFlowsInTableService extends AbstractSimpleService<GetAllFlowStatisticsFromFlowTableInput, GetAllFlowStatisticsFromFlowTableOutput> {
+public class AllFlowsInTableService extends AbstractCompatibleStatService<GetAllFlowStatisticsFromFlowTableInput,
+        GetAllFlowStatisticsFromFlowTableOutput, FlowsStatisticsUpdate> {
 
-    public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetAllFlowStatisticsFromFlowTableOutput.class);
+    private Function<? super RpcResult<List<MultipartReply>>, FlowsStatisticsUpdate> transformer;
+
+    public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -50,4 +62,16 @@ public class AllFlowsInTableService extends AbstractSimpleService<GetAllFlowStat
 
         return mprInput.build();
     }
+
+    @Override
+    public GetAllFlowStatisticsFromFlowTableOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAllFlowStatisticsFromFlowTableOutputBuilder()
+                .setTransactionId(emulatedTxId)
+                .build();
+    }
+
+    @Override
+    public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> mpResult, TransactionId emulatedTxId) {
+        return FlowStatisticsToNotificationTransformer.transformToNotification(mpResult, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 756dc24d6fa5b287ab6b7c29ed4d564b9435cd21..03658c2c4e3b810b1ffc54c02d83c235eded1d20 100644 (file)
@@ -7,24 +7,33 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.GroupStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.GetAllGroupStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
 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.MultipartReply;
 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> {
+final class AllGroupsStatsService extends
+        AbstractCompatibleStatService<GetAllGroupStatisticsInput, GetAllGroupStatisticsOutput, GroupStatisticsUpdated> {
+
     private static final MultipartRequestGroupCase GROUP_CASE;
 
     static {
@@ -36,10 +45,12 @@ final class AllGroupsStatsService extends AbstractSimpleService<GetAllGroupStati
         GROUP_CASE = caseBuilder.build();
     }
 
-    AllGroupsStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetAllGroupStatisticsOutput.class);
+
+    public AllGroupsStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
+
     @Override
     protected OfHeader buildRequest(final Xid xid, final GetAllGroupStatisticsInput input) {
         // Create multipart request header
@@ -52,4 +63,14 @@ final class AllGroupsStatsService extends AbstractSimpleService<GetAllGroupStati
         // Send the request, no cookies associated, use any connection
         return mprInput.build();
     }
+
+    @Override
+    public GetAllGroupStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAllGroupStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 4842c272bc93c1e6b16464782ecbfbe301fc1c19..f7667e8116432c84efc4228767f1b7d4ba273846 100644 (file)
@@ -7,25 +7,41 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.GetAllMeterConfigStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
 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.MultipartReply;
 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.multipart.reply.body.MultipartReplyMeterConfigCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
 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> {
+final class AllMeterConfigStatsService
+        extends AbstractCompatibleStatService<GetAllMeterConfigStatisticsInput, GetAllMeterConfigStatisticsOutput, MeterConfigStatsUpdated> {
+
     private static final MultipartRequestMeterConfigCase METER_CONFIG_CASE;
+    private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
+
 
     static {
         MultipartRequestMeterConfigCaseBuilder caseBuilder =
@@ -38,8 +54,8 @@ final class AllMeterConfigStatsService extends AbstractSimpleService<GetAllMeter
         METER_CONFIG_CASE = caseBuilder.build();
     }
 
-    AllMeterConfigStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetAllMeterConfigStatisticsOutput.class);
+    public AllMeterConfigStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -48,4 +64,27 @@ final class AllMeterConfigStatsService extends AbstractSimpleService<GetAllMeter
                 .createMultipartHeader(MultipartType.OFPMPMETERCONFIG, xid.getValue(), getVersion());
         return mprInput.setMultipartRequestBody(METER_CONFIG_CASE).build();
     }
+
+    @Override
+    public GetAllMeterConfigStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAllMeterConfigStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public MeterConfigStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        MeterConfigStatsUpdatedBuilder message = new MeterConfigStatsUpdatedBuilder();
+        message.setId(getDeviceContext().getDeviceState().getNodeId());
+        message.setMoreReplies(Boolean.FALSE);
+        message.setTransactionId(emulatedTxId);
+
+        message.setMeterConfigStats(new ArrayList<MeterConfigStats>());
+        for (MultipartReply mpReply : result) {
+            MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) mpReply.getMultipartReplyBody();
+            MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
+            message.getMeterConfigStats().addAll(meterStatsConvertor.toSALMeterConfigList(replyBody.getMeterConfig()));
+
+        }
+
+        return message.build();
+    }
 }
index bd7fcde53988fda383cbaf9f960d46734669ccde..1dd24c2fb9307df053c379e945ae1da82db61ab1 100644 (file)
@@ -7,24 +7,32 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.MeterStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
 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.MultipartReply;
 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> {
+final class AllMeterStatsService
+        extends AbstractCompatibleStatService<GetAllMeterStatisticsInput, GetAllMeterStatisticsOutput, MeterStatisticsUpdated> {
     private static final MultipartRequestMeterCase METER_CASE;
 
     static {
@@ -38,8 +46,8 @@ final class AllMeterStatsService extends AbstractSimpleService<GetAllMeterStatis
         METER_CASE = caseBuilder.build();
     }
 
-    AllMeterStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetAllMeterStatisticsOutput.class);
+    public AllMeterStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -49,4 +57,14 @@ final class AllMeterStatsService extends AbstractSimpleService<GetAllMeterStatis
         return mprInput.setMultipartRequestBody(METER_CASE).build();
     }
 
+
+    @Override
+    public GetAllMeterStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAllMeterStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index a45dfdecb76a62dfb437fb8c73a22a7c0b515a14..d2ca4400443c908e06abff59a4053d4ebeee3d70 100644 (file)
@@ -7,13 +7,18 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.NodeConnectorStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase;
@@ -21,8 +26,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 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.GetAllNodeConnectorsStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
+
+final class AllPortStatsService
+        extends AbstractCompatibleStatService<GetAllNodeConnectorsStatisticsInput, GetAllNodeConnectorsStatisticsOutput, NodeConnectorStatisticsUpdate> {
 
-final class AllPortStatsService extends AbstractSimpleService<GetAllNodeConnectorsStatisticsInput, GetAllNodeConnectorsStatisticsOutput> {
     private static final MultipartRequestPortStatsCase PORT_STATS_CASE;
 
     static {
@@ -37,8 +46,8 @@ final class AllPortStatsService extends AbstractSimpleService<GetAllNodeConnecto
         PORT_STATS_CASE = caseBuilder.build();
     }
 
-    AllPortStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetAllNodeConnectorsStatisticsOutput.class);
+    public AllPortStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -48,4 +57,14 @@ final class AllPortStatsService extends AbstractSimpleService<GetAllNodeConnecto
         mprInput.setMultipartRequestBody(PORT_STATS_CASE);
         return mprInput.build();
     }
+
+    @Override
+    public GetAllNodeConnectorsStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAllNodeConnectorsStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public NodeConnectorStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return NodeConnectorStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 89e707d0730b79118a37cb24917e35ec1c182809..c1660eeef91d0b5b030bca5ce372aec57857bd14 100644 (file)
@@ -7,13 +7,18 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.QueueStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase;
@@ -21,8 +26,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 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.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
+
+final class AllQueuesAllPortsService
+        extends AbstractCompatibleStatService<GetAllQueuesStatisticsFromAllPortsInput, GetAllQueuesStatisticsFromAllPortsOutput, QueueStatisticsUpdate> {
 
-final class AllQueuesAllPortsService extends AbstractSimpleService<GetAllQueuesStatisticsFromAllPortsInput, GetAllQueuesStatisticsFromAllPortsOutput> {
     private static final MultipartRequestQueueCase QUEUE_CASE;
 
     static {
@@ -37,8 +46,8 @@ final class AllQueuesAllPortsService extends AbstractSimpleService<GetAllQueuesS
         QUEUE_CASE = caseBuilder.build();
     }
 
-    AllQueuesAllPortsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetAllQueuesStatisticsFromAllPortsOutput.class);
+    public AllQueuesAllPortsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -49,4 +58,14 @@ final class AllQueuesAllPortsService extends AbstractSimpleService<GetAllQueuesS
         mprInput.setMultipartRequestBody(QUEUE_CASE);
         return mprInput.build();
     }
+
+    @Override
+    public GetAllQueuesStatisticsFromAllPortsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAllQueuesStatisticsFromAllPortsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 86fa2dd53e246ccd0ff257e42d3772896afbfd4c..09439e78eec0b621defb8f53d584a032dccba277 100644 (file)
@@ -7,25 +7,34 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.QueueStatisticsToNotificationTransformer;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
 
-final class AllQueuesOnePortService extends AbstractSimpleService<GetAllQueuesStatisticsFromGivenPortInput, GetAllQueuesStatisticsFromGivenPortOutput> {
-    AllQueuesOnePortService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetAllQueuesStatisticsFromGivenPortOutput.class);
+final class AllQueuesOnePortService
+        extends AbstractCompatibleStatService<GetAllQueuesStatisticsFromGivenPortInput, GetAllQueuesStatisticsFromGivenPortOutput, QueueStatisticsUpdate> {
+
+    public AllQueuesOnePortService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -49,4 +58,13 @@ final class AllQueuesOnePortService extends AbstractSimpleService<GetAllQueuesSt
         return mprInput.build();
     }
 
+    @Override
+    public GetAllQueuesStatisticsFromGivenPortOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetAllQueuesStatisticsFromGivenPortOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index d0f0bb97e9edd9d6a13b4357abf4fecc0782ac3e..b47879558f4b9825b31924c74a6fcd9104863964 100644 (file)
@@ -7,24 +7,33 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 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.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.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);
+public final class FlowsInTableService extends AbstractCompatibleStatService<GetFlowStatisticsFromFlowTableInput,
+        GetFlowStatisticsFromFlowTableOutput, FlowsStatisticsUpdate> {
+
+    public FlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -71,4 +80,14 @@ final class FlowsInTableService extends AbstractSimpleService<GetFlowStatisticsF
 
         return mprInput.build();
     }
+
+    @Override
+    public GetFlowStatisticsFromFlowTableOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetFlowStatisticsFromFlowTableOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 0f7cd3dcd9832de9caa9ff9dac24c482f9125554..46e2588be17e56b501b7d3707f8291862354938c 100644 (file)
@@ -7,24 +7,39 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
 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.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
 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> {
+final class GroupDescriptionService
+        extends AbstractCompatibleStatService<GetGroupDescriptionInput, GetGroupDescriptionOutput, GroupDescStatsUpdated> {
     private static final MultipartRequestGroupDescCase GROUP_DESC_CASE = new MultipartRequestGroupDescCaseBuilder().build();
+    private final GroupStatsResponseConvertor groupStatsResponseConvertor;
 
-    GroupDescriptionService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetGroupDescriptionOutput.class);
+    public GroupDescriptionService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
+        groupStatsResponseConvertor = new GroupStatsResponseConvertor();
     }
 
     @Override
@@ -34,4 +49,27 @@ final class GroupDescriptionService extends AbstractSimpleService<GetGroupDescri
         mprInput.setMultipartRequestBody(GROUP_DESC_CASE);
         return mprInput.build();
     }
+
+    @Override
+    public GetGroupDescriptionOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetGroupDescriptionOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public GroupDescStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        GroupDescStatsUpdatedBuilder notification = new GroupDescStatsUpdatedBuilder();
+        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setMoreReplies(Boolean.FALSE);
+        notification.setTransactionId(emulatedTxId);
+
+        notification.setGroupDescStats(new ArrayList<GroupDescStats>());
+        for (MultipartReply mpReply : result) {
+            MultipartReplyGroupDescCase caseBody = (MultipartReplyGroupDescCase) mpReply.getMultipartReplyBody();
+            MultipartReplyGroupDesc replyBody = caseBody.getMultipartReplyGroupDesc();
+            notification.getGroupDescStats().addAll(
+                    groupStatsResponseConvertor.toSALGroupDescStatsList(replyBody.getGroupDesc(), getOfVersion()));
+        }
+
+        return notification.build();
+    }
 }
index fce8e93019230b0ba6c7c94a9d0dbef398a28409..22c8d6d465c3e8c07031ed15c1a5840e199839a5 100644 (file)
@@ -7,25 +7,52 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Chaining;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.ChainingChecks;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupAll;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupFf;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupIndirect;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupSelect;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectLiveness;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectWeight;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
 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.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
 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> {
+final class GroupFeaturesService
+        extends AbstractCompatibleStatService<GetGroupFeaturesInput, GetGroupFeaturesOutput, GroupFeaturesUpdated> {
+
     private static final MultipartRequestGroupFeaturesCase GROUP_FEAT_CASE =
             new MultipartRequestGroupFeaturesCaseBuilder().build();
 
-    GroupFeaturesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetGroupFeaturesOutput.class);
+    public GroupFeaturesService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -35,4 +62,94 @@ final class GroupFeaturesService extends AbstractSimpleService<GetGroupFeaturesI
         mprInput.setMultipartRequestBody(GROUP_FEAT_CASE);
         return mprInput.build();
     }
+
+    @Override
+    public GetGroupFeaturesOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetGroupFeaturesOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public GroupFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        final int mpSize = result.size();
+        Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
+
+        GroupFeaturesUpdatedBuilder notification = new GroupFeaturesUpdatedBuilder();
+        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setMoreReplies(Boolean.FALSE);
+        notification.setTransactionId(emulatedTxId);
+
+        MultipartReplyGroupFeaturesCase caseBody = (MultipartReplyGroupFeaturesCase) result.get(0).getMultipartReplyBody();
+        MultipartReplyGroupFeatures replyBody = caseBody.getMultipartReplyGroupFeatures();
+
+        notification.setGroupTypesSupported(extractSupportedGroupTypes(replyBody.getTypes()));
+        notification.setMaxGroups(replyBody.getMaxGroups());
+        notification.setGroupCapabilitiesSupported(extractSupportedCapabilities(replyBody.getCapabilities()));
+        notification.setActions(extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
+
+        return notification.build();
+    }
+
+    @VisibleForTesting
+    static List<Class<? extends GroupCapability>> extractSupportedCapabilities(GroupCapabilities capabilities) {
+        List<Class<? extends GroupCapability>> supportedCapabilities = new ArrayList<>();
+
+        if (capabilities.isOFPGFCCHAINING()) {
+            supportedCapabilities.add(Chaining.class);
+        }
+        if (capabilities.isOFPGFCCHAININGCHECKS()) {
+            supportedCapabilities.add(ChainingChecks.class);
+        }
+        if (capabilities.isOFPGFCSELECTLIVENESS()) {
+            supportedCapabilities.add(SelectLiveness.class);
+        }
+        if (capabilities.isOFPGFCSELECTWEIGHT()) {
+            supportedCapabilities.add(SelectWeight.class);
+        }
+        return supportedCapabilities;
+    }
+
+    @VisibleForTesting
+    static List<Class<? extends GroupType>> extractSupportedGroupTypes(GroupTypes types) {
+        List<Class<? extends GroupType>> supportedGroups = new ArrayList<>();
+
+        if (types.isOFPGTALL()) {
+            supportedGroups.add(GroupAll.class);
+        }
+        if (types.isOFPGTSELECT()) {
+            supportedGroups.add(GroupSelect.class);
+        }
+        if (types.isOFPGTINDIRECT()) {
+            supportedGroups.add(GroupIndirect.class);
+        }
+        if (types.isOFPGTFF()) {
+            supportedGroups.add(GroupFf.class);
+        }
+        return supportedGroups;
+    }
+
+    @VisibleForTesting
+    static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
+        List<Long> supportActionByGroups = new ArrayList<>();
+        for (ActionType supportedActions : actionsSupported) {
+            long supportActionBitmap = 0;
+            supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? (1 << 0) : 0;
+            supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? (1 << 11) : 0;
+            supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? (1 << 12) : 0;
+            supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? (1 << 15) : 0;
+            supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? (1 << 16) : 0;
+            supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? (1 << 17) : 0;
+            supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? (1 << 18) : 0;
+            supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? (1 << 19) : 0;
+            supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? (1 << 20) : 0;
+            supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? (1 << 21) : 0;
+            supportActionBitmap |= supportedActions.isOFPATGROUP() ? (1 << 22) : 0;
+            supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? (1 << 23) : 0;
+            supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? (1 << 24) : 0;
+            supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? (1 << 25) : 0;
+            supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? (1 << 26) : 0;
+            supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? (1 << 27) : 0;
+            supportActionByGroups.add(Long.valueOf(supportActionBitmap));
+        }
+        return supportActionByGroups;
+    }
 }
index e8defee795f1a05e56677b51cf71a1b417a35d6d..d22b719ab4849ef816571b3be6261ae7a67b3548 100644 (file)
@@ -7,23 +7,32 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.GroupStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.GetGroupStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
 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.MultipartReply;
 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);
+final class GroupStatsService
+        extends AbstractCompatibleStatService<GetGroupStatisticsInput, GetGroupStatisticsOutput, GroupStatisticsUpdated> {
+
+    public GroupStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -39,4 +48,14 @@ final class GroupStatsService extends AbstractSimpleService<GetGroupStatisticsIn
         mprInput.setMultipartRequestBody(caseBuilder.build());
         return mprInput.build();
     }
+
+    @Override
+    public GetGroupStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetGroupStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 44b988c53f036f969ee4b1534ce26e4dde9e64c0..142b3c0c85f6859c05b256e202a285966c3bc8bb 100644 (file)
@@ -7,24 +7,48 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandDrop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandDscpRemark;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBurst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
 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.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
 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> {
+final class MeterFeaturesService
+        extends AbstractCompatibleStatService<GetMeterFeaturesInput, GetMeterFeaturesOutput, MeterFeaturesUpdated> {
     private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE = new MultipartRequestMeterFeaturesCaseBuilder().build();
 
-    protected MeterFeaturesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetMeterFeaturesOutput.class);
+    public MeterFeaturesService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -34,4 +58,61 @@ final class MeterFeaturesService extends AbstractSimpleService<GetMeterFeaturesI
         mprInput.setMultipartRequestBody(METER_FEATURES_CASE);
         return mprInput.build();
     }
+
+    @Override
+    public GetMeterFeaturesOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetMeterFeaturesOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        final int mpSize = result.size();
+        Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
+
+        MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
+        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setMoreReplies(Boolean.FALSE);
+        notification.setTransactionId(emulatedTxId);
+
+        MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
+        MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
+        notification.setMaxBands(replyBody.getMaxBands());
+        notification.setMaxColor(replyBody.getMaxColor());
+        notification.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
+        notification.setMeterCapabilitiesSupported(extractMeterCapabilities(replyBody.getCapabilities()));
+        notification.setMeterBandSupported(extractSupportedMeterBand(replyBody, replyBody.getBandTypes()));
+
+        return notification.build();
+    }
+
+    @VisibleForTesting
+    protected List<Class<? extends MeterBand>> extractSupportedMeterBand(MultipartReplyMeterFeatures replyBody, MeterBandTypeBitmap bandTypes) {
+        List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
+        if (bandTypes.isOFPMBTDROP()) {
+            supportedMeterBand.add(MeterBandDrop.class);
+        }
+        if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
+            supportedMeterBand.add(MeterBandDscpRemark.class);
+        }
+        return supportedMeterBand;
+    }
+
+    @VisibleForTesting
+    protected static List<Class<? extends MeterCapability>> extractMeterCapabilities(MeterFlags capabilities) {
+        List<Class<? extends MeterCapability>> supportedCapabilities = new ArrayList<>();
+
+        if (capabilities.isOFPMFBURST()) {
+            supportedCapabilities.add(MeterBurst.class);
+        }
+        if (capabilities.isOFPMFKBPS()) {
+            supportedCapabilities.add(MeterKbps.class);
+        }
+        if (capabilities.isOFPMFPKTPS()) {
+            supportedCapabilities.add(MeterPktps.class);
+        }
+        if (capabilities.isOFPMFSTATS()) {
+            supportedCapabilities.add(MeterStats.class);
+        }
+        return supportedCapabilities;
+    }
 }
index 976b06fc1443d383cab1c6615761558d0fe1ee67..84e510854473e5062fe946a2d5ae467800f82f32 100644 (file)
@@ -7,24 +7,32 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.MeterStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.GetMeterStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
 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.MultipartReply;
 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> {
+final class MeterStatsService
+        extends AbstractCompatibleStatService<GetMeterStatisticsInput, GetMeterStatisticsOutput, MeterStatisticsUpdated> {
 
-    MeterStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetMeterStatisticsOutput.class);
+    public MeterStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -41,4 +49,14 @@ final class MeterStatsService extends AbstractSimpleService<GetMeterStatisticsIn
         mprInput.setMultipartRequestBody(caseBuilder.build());
         return mprInput.build();
     }
+
+    @Override
+    public GetMeterStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetMeterStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index a8c80eaace73c9a59f78883061bb77e4426b79fe..2a0169c1ad3eea4006532ec8034ff5f96280100d 100644 (file)
@@ -7,24 +7,33 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.QueueStatisticsToNotificationTransformer;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
 
-final class OneQueueOnePortService extends AbstractSimpleService<GetQueueStatisticsFromGivenPortInput, GetQueueStatisticsFromGivenPortOutput> {
-    OneQueueOnePortService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetQueueStatisticsFromGivenPortOutput.class);
+final class OneQueueOnePortService
+        extends AbstractCompatibleStatService<GetQueueStatisticsFromGivenPortInput, GetQueueStatisticsFromGivenPortOutput, QueueStatisticsUpdate> {
+
+    public OneQueueOnePortService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -45,4 +54,14 @@ final class OneQueueOnePortService extends AbstractSimpleService<GetQueueStatist
         mprInput.setMultipartRequestBody(caseBuilder.build());
         return mprInput.build();
     }
+
+    @Override
+    public GetQueueStatisticsFromGivenPortOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetQueueStatisticsFromGivenPortOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 7879447c15176ee4db8e0164f0a4d56f7d9766ff..cd127d6e16f68a03b3ba742049742e70c15a17e1 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
+import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator;
 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;
@@ -40,7 +41,8 @@ import org.slf4j.LoggerFactory;
 /**
  * @author joe
  */
-public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService {
+public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService, Delegator<OpendaylightFlowStatisticsService> {
+
     private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceImpl.class);
 
     private final Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> matchingConvertor =
@@ -49,7 +51,7 @@ public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowSt
                 public RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> apply(final RpcResult<List<MultipartReply>> input) {
                     final DeviceContext deviceContext = matchingFlowsInTable.getDeviceContext();
                     TranslatorLibrary translatorLibrary = deviceContext.oook();
-                    RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
+                    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
                     if (input.isSuccessful()) {
                         MultipartReply reply = input.getResult().get(0);
                         final TranslatorKey translatorKey = new TranslatorKey(reply.getVersion(), MultipartReplyAggregateCase.class.getName());
@@ -79,24 +81,30 @@ public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowSt
                 }
     };
 
-    private final AggregateFlowsInTableService aggregateFlowsInTable;
     private final MatchingFlowsInTableService matchingFlowsInTable;
-    private final AllFlowsInAllTablesService allFlowsInAllTables;
-    private final AllFlowsInTableService allFlowsInTable;
-    private final FlowsInTableService flowsInTable;
+    private OpendaylightFlowStatisticsService delegate;
 
     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 void setDelegate(OpendaylightFlowStatisticsService delegate) {
+        this.delegate = delegate;
+    }
+
+    /**
+     * @deprecated provided for Be-release as backward compatibility relic
+     */
+    @Override
+    @Deprecated
     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
             final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
-        return aggregateFlowsInTable.handleServiceCall(input);
+        if (delegate != null) {
+            return delegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
+        } else {
+            throw new IllegalAccessError("no delegate available - service is currently out of order");
+        }
     }
 
     @Override
@@ -105,21 +113,45 @@ public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowSt
         return Futures.transform(matchingFlowsInTable.handleServiceCall(input), matchingConvertor);
     }
 
+    /**
+     * @deprecated provided for Be-release as backward compatibility relic
+     */
     @Override
+    @Deprecated
     public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
             final GetAllFlowStatisticsFromFlowTableInput input) {
-        return allFlowsInTable.handleServiceCall(input);
+        if (delegate != null) {
+            return delegate.getAllFlowStatisticsFromFlowTable(input);
+        } else {
+            throw new IllegalAccessError("no delegate available - service is currently out of order");
+        }
     }
 
+    /**
+     * @deprecated provided for Be-release as backward compatibility relic
+     */
     @Override
+    @Deprecated
     public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
             final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
-        return allFlowsInAllTables.handleServiceCall(input);
+        if (delegate != null) {
+            return delegate.getAllFlowsStatisticsFromAllFlowTables(input);
+        } else {
+            throw new IllegalAccessError("no delegate available - service is currently out of order");
+        }
     }
 
+    /**
+     * @deprecated provided for Be-release as backward compatibility relic
+     */
     @Override
+    @Deprecated
     public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
             final GetFlowStatisticsFromFlowTableInput input) {
-        return flowsInTable.handleServiceCall(input);
+        if (delegate != null) {
+            return delegate.getFlowStatisticsFromFlowTable(input);
+        } else {
+            throw new IllegalAccessError("no delegate available - service is currently out of order");
+        }
     }
 }
index 23433764fb76ef06e664214f55612ae5a15c6791..a6f6b2b197455ea1f8fbdb9748f5541553966e6f 100644 (file)
@@ -7,33 +7,57 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
 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.GetFlowTablesStatisticsOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats;
 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.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-public final class OpendaylightFlowTableStatisticsServiceImpl extends AbstractSimpleService<GetFlowTablesStatisticsInput, GetFlowTablesStatisticsOutput> implements
+public final class OpendaylightFlowTableStatisticsServiceImpl extends
+        AbstractCompatibleStatService<GetFlowTablesStatisticsInput, GetFlowTablesStatisticsOutput, FlowTableStatisticsUpdate> implements
         OpendaylightFlowTableStatisticsService {
 
-    public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetFlowTablesStatisticsOutput.class);
+    private final NotificationPublishService notificationPublishService;
+
+    public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack,
+                                                      final DeviceContext deviceContext,
+                                                      final AtomicLong compatibilityXidSeed,
+                                                      final NotificationPublishService notificationPublishService) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
+        this.notificationPublishService = notificationPublishService;
     }
 
     @Override
     public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
             final GetFlowTablesStatisticsInput input) {
-        return handleServiceCall(input);
+        return handleAndNotify(input, notificationPublishService);
     }
 
     @Override
@@ -52,4 +76,36 @@ public final class OpendaylightFlowTableStatisticsServiceImpl extends AbstractSi
 
         return mprInput.build();
     }
+
+    @Override
+    public GetFlowTablesStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetFlowTablesStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public FlowTableStatisticsUpdate transformToNotification(List<MultipartReply> mpReplyList, TransactionId emulatedTxId) {
+        FlowTableStatisticsUpdateBuilder notification = new FlowTableStatisticsUpdateBuilder();
+        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setMoreReplies(Boolean.FALSE);
+        notification.setTransactionId(emulatedTxId);
+
+        final List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
+        notification.setFlowTableAndStatisticsMap(salFlowStats);
+        for (MultipartReply mpReply : mpReplyList) {
+            MultipartReplyTableCase caseBody = (MultipartReplyTableCase) mpReply.getMultipartReplyBody();
+            MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
+            List<TableStats> swTablesStats = replyBody.getTableStats();
+
+            for (TableStats swTableStats : swTablesStats) {
+                FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
+                statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
+                statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
+                statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
+                statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
+                salFlowStats.add(statisticsBuilder.build());
+            }
+        }
+
+        return notification.build();
+    }
 }
index 674063b5e01427193fb4d7bf76dc37c3e5c787c9..28eaa8f0230280206590e1c6ae55688e70a31906 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
@@ -29,31 +31,35 @@ public class OpendaylightGroupStatisticsServiceImpl implements OpendaylightGroup
     private final GroupDescriptionService groupDesc;
     private final GroupFeaturesService groupFeat;
     private final GroupStatsService groupStats;
+    private final NotificationPublishService notificationPublishService;
 
-    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);
+    public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
+                                                  final AtomicLong compatibilityXidSeed,
+                                                  final NotificationPublishService notificationPublishService) {
+        this.notificationPublishService = notificationPublishService;
+        allGroups = new AllGroupsStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+        groupDesc = new GroupDescriptionService(requestContextStack, deviceContext, compatibilityXidSeed);
+        groupFeat = new GroupFeaturesService(requestContextStack, deviceContext, compatibilityXidSeed);
+        groupStats = new GroupStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
     public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
-        return allGroups.handleServiceCall(input);
+        return allGroups.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
-        return groupDesc.handleServiceCall(input);
+        return groupDesc.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
-        return groupFeat.handleServiceCall(input);
+        return groupFeat.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
-        return groupStats.handleServiceCall(input);
+        return groupStats.handleAndNotify(input, notificationPublishService);
     }
 }
index ecee95ef785df4229edf5bcafe0ee42c70996a36..22f74d27672f5eea4c5bb0a9134a640085e1dc8e 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
@@ -26,32 +28,38 @@ public class OpendaylightMeterStatisticsServiceImpl implements OpendaylightMeter
     private final AllMeterStatsService allMeterStats;
     private final MeterFeaturesService meterFeatures;
     private final MeterStatsService meterStats;
+    private final NotificationPublishService notificationPublishService;
 
-    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);
+    public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack,
+                                                  final DeviceContext deviceContext,
+                                                  final AtomicLong compatibilityXidSeed,
+                                                  final NotificationPublishService notificationPublishService) {
+        this.notificationPublishService = notificationPublishService;
+
+        allMeterConfig = new AllMeterConfigStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+        allMeterStats = new AllMeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+        meterFeatures = new MeterFeaturesService(requestContextStack, deviceContext, compatibilityXidSeed);
+        meterStats = new MeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
     public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
             final GetAllMeterConfigStatisticsInput input) {
-        return allMeterConfig.handleServiceCall(input);
+        return allMeterConfig.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(final GetAllMeterStatisticsInput input) {
-        return allMeterStats.handleServiceCall(input);
+        return allMeterStats.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(final GetMeterFeaturesInput input) {
-        return meterFeatures.handleServiceCall(input);
+        return meterFeatures.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(final GetMeterStatisticsInput input) {
-        return meterStats.handleServiceCall(input);
+        return meterStats.handleAndNotify(input, notificationPublishService);
     }
 }
index 4258c01331901e7d3b16bde9a331580a7ac6ba69..7f97e503d2128fda4d227ad720049b1da4d6a8b5 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
@@ -20,21 +22,26 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 public class OpendaylightPortStatisticsServiceImpl implements OpendaylightPortStatisticsService {
     private final AllPortStatsService allPortStats;
     private final PortStatsService portStats;
+    private final NotificationPublishService notificationPublishService;
 
-    public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        allPortStats = new AllPortStatsService(requestContextStack, deviceContext);
-        portStats = new PortStatsService(requestContextStack, deviceContext);
+    public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack,
+                                                 final DeviceContext deviceContext,
+                                                 final AtomicLong compatibilityXidSeed,
+                                                 final NotificationPublishService notificationPublishService) {
+        this.notificationPublishService = notificationPublishService;
+        allPortStats = new AllPortStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+        portStats = new PortStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
     public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
             final GetAllNodeConnectorsStatisticsInput input) {
-        return allPortStats.handleServiceCall(input);
+        return allPortStats.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
             final GetNodeConnectorStatisticsInput input) {
-        return portStats.handleServiceCall(input);
+        return portStats.handleAndNotify(input, notificationPublishService);
     }
 }
index adc97cf1332273b3096fa58caa0f81673f852525..2c90974a310dd31fe2836e960f9af26a1516da30 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
@@ -23,28 +25,33 @@ public class OpendaylightQueueStatisticsServiceImpl implements OpendaylightQueue
     private final AllQueuesAllPortsService allQueuesAllPorts;
     private final AllQueuesOnePortService allQueuesOnePort;
     private final OneQueueOnePortService oneQueueOnePort;
+    private final NotificationPublishService notificationPublishService;
 
-    public OpendaylightQueueStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        allQueuesAllPorts = new AllQueuesAllPortsService(requestContextStack, deviceContext);
-        allQueuesOnePort = new AllQueuesOnePortService(requestContextStack, deviceContext);
-        oneQueueOnePort = new OneQueueOnePortService(requestContextStack, deviceContext);
+    public OpendaylightQueueStatisticsServiceImpl(final RequestContextStack requestContextStack,
+                                                  final DeviceContext deviceContext,
+                                                  final AtomicLong compatibilityXidSeed,
+                                                  final NotificationPublishService notificationPublishService) {
+        this.notificationPublishService = notificationPublishService;
+        allQueuesAllPorts = new AllQueuesAllPortsService(requestContextStack, deviceContext, compatibilityXidSeed);
+        allQueuesOnePort = new AllQueuesOnePortService(requestContextStack, deviceContext, compatibilityXidSeed);
+        oneQueueOnePort = new OneQueueOnePortService(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
     public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
             final GetAllQueuesStatisticsFromAllPortsInput input) {
-        return allQueuesAllPorts.handleServiceCall(input);
+        return allQueuesAllPorts.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
             final GetAllQueuesStatisticsFromGivenPortInput input) {
-        return allQueuesOnePort.handleServiceCall(input);
+        return allQueuesOnePort.handleAndNotify(input, notificationPublishService);
     }
 
     @Override
     public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
             final GetQueueStatisticsFromGivenPortInput input) {
-        return oneQueueOnePort.handleServiceCall(input);
+        return oneQueueOnePort.handleAndNotify(input, notificationPublishService);
     }
 }
index 6803ba28d25e065e7a07c9f652967376c0fea759..ed8caa2c6525325359518da4530e3159e2b631f2 100644 (file)
@@ -7,25 +7,33 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 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.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.NodeConnectorStatisticsToNotificationTransformer;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
 
-final class PortStatsService extends AbstractSimpleService<GetNodeConnectorStatisticsInput, GetNodeConnectorStatisticsOutput> {
+final class PortStatsService
+        extends AbstractCompatibleStatService<GetNodeConnectorStatisticsInput, GetNodeConnectorStatisticsOutput, NodeConnectorStatisticsUpdate> {
 
-    protected PortStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        super(requestContextStack, deviceContext, GetNodeConnectorStatisticsOutput.class);
+    public PortStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+        super(requestContextStack, deviceContext, compatibilityXidSeed);
     }
 
     @Override
@@ -48,4 +56,14 @@ final class PortStatsService extends AbstractSimpleService<GetNodeConnectorStati
 
         return mprInput.build();
     }
+
+    @Override
+    public GetNodeConnectorStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+        return new GetNodeConnectorStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+    }
+
+    @Override
+    public NodeConnectorStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+        return NodeConnectorStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+    }
 }
index 7f28f258e45378cca1677bafb0bc727c997f628c..05462226e0463ab6092b522d551fba86005be9e6 100644 (file)
@@ -43,6 +43,7 @@ public class FlowStatisticsToNotificationTransformer {
                                                                 final TransactionId emulatedTxId) {
         final FlowsStatisticsUpdateBuilder notification = new FlowsStatisticsUpdateBuilder();
         final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
+        notification.setId(deviceContext.getDeviceState().getNodeId());
         notification.setFlowAndStatisticsMapList(statsList);
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImpl.java
new file mode 100644 (file)
index 0000000..05fc1ba
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * 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.compatibility;
+
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService;
+import org.opendaylight.openflowplugin.impl.statistics.services.AllFlowsInAllTablesService;
+import org.opendaylight.openflowplugin.impl.statistics.services.AllFlowsInTableService;
+import org.opendaylight.openflowplugin.impl.statistics.services.FlowsInTableService;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
+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.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+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.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author joe
+ */
+public class OpendaylightFlowStatisticsServiceDelegateImpl implements OpendaylightFlowStatisticsService {
+
+    private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceDelegateImpl.class);
+
+    private final AggregateFlowsInTableService aggregateFlowsInTable;
+    private final AllFlowsInAllTablesService allFlowsInAllTables;
+    private final AllFlowsInTableService allFlowsInTable;
+    private final FlowsInTableService flowsInTable;
+    private final NotificationPublishService notificationService;
+
+    public OpendaylightFlowStatisticsServiceDelegateImpl(final RequestContextStack requestContextStack,
+                                                         final DeviceContext deviceContext,
+                                                         final NotificationPublishService notificationService,
+                                                         final AtomicLong compatibilityXidSeed) {
+        this.notificationService = notificationService;
+        aggregateFlowsInTable = new AggregateFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
+        allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext, compatibilityXidSeed);
+        allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
+        flowsInTable = new FlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
+    }
+
+    /**
+     * @deprecated this is the only method with real implementation provided, in delegate it makes no sense
+     */
+    @Override
+    @Deprecated
+    public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
+            final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
+        throw new IllegalAccessError("unsupported by backward compatibility delegate service " +
+                "- this rpc is always provided by default service implementation");
+    }
+
+    @Override
+    public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
+            final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
+        return aggregateFlowsInTable.handleAndNotify(input, notificationService);
+    }
+
+    @Override
+    public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
+            final GetAllFlowStatisticsFromFlowTableInput input) {
+        return allFlowsInTable.handleAndNotify(input, notificationService);
+    }
+
+    @Override
+    public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
+            final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
+        return allFlowsInAllTables.handleAndNotify(input, notificationService);
+    }
+
+    @Override
+    public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
+            final GetFlowStatisticsFromFlowTableInput input) {
+        return flowsInTable.handleAndNotify(input, notificationService);
+    }
+}
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java
new file mode 100644 (file)
index 0000000..8140e84
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
+import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+/**
+ * Created by mirehak on 9/9/15.
+ */
+public abstract class AbstractSingleStatsServiceTest extends AbstractStatsServiceTest {
+
+    @Mock
+    protected NotificationPublishService notificationPublishService;
+
+    protected RequestContext<Object> rqContext;
+
+    protected RpcResult<Object> rpcResult;
+
+    @Override
+    public void init() throws Exception {
+        super.init();
+        rqContext = new AbstractRequestContext<Object>(42L) {
+            @Override
+            public void close() {
+                //NOOP
+            }
+        };
+        final Answer closeRequestFutureAnswer = new Answer() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                rqContext.setResult(rpcResult);
+                rqContext.close();
+                return null;
+            }
+        };
+
+        Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
+        Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting();
+        Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
+    }
+}
index f794caddfb613b4687b171c6526aead85d6c6a51..db225e3594c32833e24007d57819def8a5315bee 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
 import org.junit.Before;
 import org.junit.runner.RunWith;
 import org.mockito.Matchers;
@@ -21,6 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
@@ -33,6 +35,7 @@ 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.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -42,23 +45,30 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 @RunWith(MockitoJUnitRunner.class)
 public abstract class AbstractStatsServiceTest {
     @Mock
-    RequestContextStack rqContextStack;
+    protected RequestContextStack rqContextStack;
     @Mock
-    DeviceContext deviceContext;
+    protected DeviceContext deviceContext;
     @Mock
-    ConnectionContext connectionContext;
+    protected ConnectionContext connectionContext;
     @Mock
-    FeaturesReply features;
+    protected FeaturesReply features;
     @Mock
-    MessageSpy messageSpy;
+    private GetFeaturesOutput getFeaturesOutput;
     @Mock
-    OutboundQueue outboundQueueProvider;
+    protected MessageSpy messageSpy;
     @Mock
-    MultiMsgCollector multiMsgCollector;
+    protected OutboundQueue outboundQueueProvider;
     @Mock
-    TranslatorLibrary translatorLibrary;
+    protected MultiMsgCollector multiMsgCollector;
+    @Mock
+    protected TranslatorLibrary translatorLibrary;
+    @Mock
+    protected DeviceState deviceState;
+
 
-    final Answer<Void> answerVoidToCallback = new Answer<Void>() {
+    public static final NodeId NODE_ID = new NodeId("unit-test-node:123");
+
+    protected final Answer<Void> answerVoidToCallback = new Answer<Void>() {
         @Override
         public Void answer(InvocationOnMock invocation) throws Throwable {
             final FutureCallback<OfHeader> callback = (FutureCallback<OfHeader>) (invocation.getArguments()[2]);
@@ -80,10 +90,16 @@ public abstract class AbstractStatsServiceTest {
         Mockito.when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
         Mockito.when(deviceContext.getMultiMsgCollector(Matchers.any(RequestContext.class))).thenReturn(multiMsgCollector);
         Mockito.when(deviceContext.oook()).thenReturn(translatorLibrary);
+        Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
+        Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
+        Mockito.when(getFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
         Mockito.when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
         Mockito.when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
 
+
         setUp();
     }
 
@@ -91,7 +107,7 @@ public abstract class AbstractStatsServiceTest {
         //NOOP
     }
 
-    static NodeRef createNodeRef(String nodeIdValue) {
+    protected static NodeRef createNodeRef(String nodeIdValue) {
         InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, new NodeKey(new NodeId(nodeIdValue)));
         return new NodeRef(nodePath);
index 59a563c0a27c67cc12f88cc1f07bd85b0daba262..5fb40eac6ec5eceaf8df9ebb5c6b2c57ef578d58 100644 (file)
@@ -8,30 +8,23 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
-import com.google.common.util.concurrent.FutureCallback;
 import java.util.concurrent.Future;
-import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
-import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
 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.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 /**
- * Test for {@link OpendaylightFlowStatisticsServiceImpl}
+ * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods (failing)
  */
 public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsServiceTest {
 
@@ -42,7 +35,6 @@ public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsSer
 
     private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
 
-
     public void setUp() {
         flowStatisticsService = new OpendaylightFlowStatisticsServiceImpl(rqContextStack, deviceContext);
 
@@ -55,74 +47,39 @@ public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsSer
         Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
     }
 
-    @Test
+    @Test(expected = IllegalAccessError.class)
     public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"))
                 .setTableId(new TableId((short) 1));
 
-        final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture
-                = flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
-
-        Assert.assertTrue(resultFuture.isDone());
-        final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResult = resultFuture.get();
-        Assert.assertTrue(rpcResult.isSuccessful());
-        Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
+        flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
     }
 
-    @Test
+    @Test(expected = IllegalAccessError.class)
     public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
                 .setNode(createNodeRef("unitProt:123"))
                 .setTableId(new TableId((short) 1));
 
-        final Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> resultFuture
-                = flowStatisticsService.getAllFlowStatisticsFromFlowTable(input.build());
-
-        Assert.assertTrue(resultFuture.isDone());
-        final RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResult = resultFuture.get();
-        Assert.assertTrue(rpcResult.isSuccessful());
-        Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+        flowStatisticsService.getAllFlowStatisticsFromFlowTable(input.build());
     }
 
-    @Test
+    @Test(expected = IllegalAccessError.class)
     public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
-        final Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> resultFuture
-                = flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input.build());
-
-        Assert.assertTrue(resultFuture.isDone());
-        final RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResult = resultFuture.get();
-        Assert.assertTrue(rpcResult.isSuccessful());
-        Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+        flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input.build());
     }
 
-    @Test
+    @Test(expected = IllegalAccessError.class)
     public void testGetFlowStatisticsFromFlowTable() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetFlowStatisticsFromFlowTableInputBuilder input = new GetFlowStatisticsFromFlowTableInputBuilder()
                 .setNode(createNodeRef("unitProt:123"))
                 .setPriority(5);
 
         final Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> resultFuture
                 = flowStatisticsService.getFlowStatisticsFromFlowTable(input.build());
-
-        Assert.assertTrue(resultFuture.isDone());
-        final RpcResult<GetFlowStatisticsFromFlowTableOutput> rpcResult = resultFuture.get();
-        Assert.assertTrue(rpcResult.isSuccessful());
-        Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
     }
 }
\ No newline at end of file
index 71f4ff5811997848990d7cf757bcaf66d0deb183..43945f1d3d7b8e2dd38644031305d634a7dc40e1 100644 (file)
@@ -38,7 +38,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
- * Test for {@link OpendaylightFlowStatisticsServiceImpl}
+ * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only not delegated method
  */
 public class OpendaylightFlowStatisticsServiceImpl2Test extends AbstractStatsServiceTest {
 
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl3Test.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl3Test.java
new file mode 100644 (file)
index 0000000..897c872
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+
+/**
+ * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods
+ */
+public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsServiceTest {
+
+    @Mock
+    private OpendaylightFlowStatisticsService flowStatisticsDelegate;
+
+    private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
+
+    public void setUp() {
+        flowStatisticsService = new OpendaylightFlowStatisticsServiceImpl(rqContextStack, deviceContext);
+        flowStatisticsService.setDelegate(flowStatisticsDelegate);
+    }
+
+    @Test
+    public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
+        GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
+                .setNode(createNodeRef("unitProt:123"))
+                .setTableId(new TableId((short) 1))
+                .build();
+
+        flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
+        Mockito.verify(flowStatisticsDelegate).getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
+    }
+
+    @Test
+    public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
+        GetAllFlowStatisticsFromFlowTableInput input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
+                .setNode(createNodeRef("unitProt:123"))
+                .setTableId(new TableId((short) 1))
+                .build();
+
+        flowStatisticsService.getAllFlowStatisticsFromFlowTable(input);
+        Mockito.verify(flowStatisticsDelegate).getAllFlowStatisticsFromFlowTable(input);
+    }
+
+    @Test
+    public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
+        GetAllFlowsStatisticsFromAllFlowTablesInput input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
+                .setNode(createNodeRef("unitProt:123"))
+                .build();
+
+        flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input);
+        Mockito.verify(flowStatisticsDelegate).getAllFlowsStatisticsFromAllFlowTables(input);
+    }
+
+    @Test
+    public void testGetFlowStatisticsFromFlowTable() throws Exception {
+        GetFlowStatisticsFromFlowTableInput input = new GetFlowStatisticsFromFlowTableInputBuilder()
+                .setNode(createNodeRef("unitProt:123"))
+                .setPriority(5)
+                .build();
+
+        flowStatisticsService.getFlowStatisticsFromFlowTable(input);
+        Mockito.verify(flowStatisticsDelegate).getFlowStatisticsFromFlowTable(input);
+    }
+}
index e364e894688faeb1c881d1f3e01c4331df569d60..9993ab3e50a28878e445634af3dd7e1d11333b6f 100644 (file)
@@ -9,46 +9,46 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Matchers;
 import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
 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.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
  * Test for {@link OpendaylightFlowTableStatisticsServiceImpl}
  */
-public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
 
+    private static final Short TABLE_ID = (short) 123;
     @Captor
     private ArgumentCaptor<MultipartRequestInput> requestInput;
 
-    private RequestContext<Object> rqContext;
-
     private OpendaylightFlowTableStatisticsServiceImpl flowTableStatisticsService;
 
     public void setUp() {
-        flowTableStatisticsService = new OpendaylightFlowTableStatisticsServiceImpl(rqContextStack, deviceContext);
-
-        rqContext = new AbstractRequestContext<Object>(42L) {
-            @Override
-            public void close() {
-                //NOOP
-            }
-        };
-        Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
+        flowTableStatisticsService = new OpendaylightFlowTableStatisticsServiceImpl(rqContextStack, deviceContext,
+                new AtomicLong(), notificationPublishService);
     }
 
     @Test
@@ -59,6 +59,26 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractStat
         GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyTableCaseBuilder()
+                                .setMultipartReplyTable(new MultipartReplyTableBuilder()
+                                        .setTableStats(Collections.singletonList(new TableStatsBuilder()
+                                                .setActiveCount(31L)
+                                                .setLookupCount(BigInteger.valueOf(32L))
+                                                .setMatchedCount(BigInteger.valueOf(33L))
+                                                .setMaxEntries(34L)
+                                                .setName("test-table")
+                                                .setNwDstMask((short) 35)
+                                                .setNwSrcMask((short) 36)
+                                                .setTableId(TABLE_ID)
+                                                .build()))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+
         final Future<RpcResult<GetFlowTablesStatisticsOutput>> resultFuture
                 = flowTableStatisticsService.getFlowTablesStatistics(input.build());
 
@@ -66,6 +86,8 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractStat
         final RpcResult<GetFlowTablesStatisticsOutput> rpcResult = resultFuture.get();
         Assert.assertTrue(rpcResult.isSuccessful());
         Assert.assertEquals(MultipartType.OFPMPTABLE, requestInput.getValue().getType());
+
+        Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
     }
 
     @Test
index 0102ad7e1dabe9f2118a1cdc0317dbe604e50c90..84e5b4e2d37fadafb6cb25d8c9e1043f8de693a1 100644 (file)
@@ -9,15 +9,18 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Matchers;
 import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
@@ -27,59 +30,93 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
  * Test for {@link OpendaylightGroupStatisticsServiceImpl}
  */
-public class OpendaylightGroupStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
 
+    private static final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId GROUP_ID =
+            new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(123L);
     @Captor
     private ArgumentCaptor<MultipartRequestInput> requestInput;
 
-    private RequestContext<Object> rqContext;
-
     private OpendaylightGroupStatisticsServiceImpl groupStatisticsService;
 
     public void setUp() {
-        groupStatisticsService = new OpendaylightGroupStatisticsServiceImpl(rqContextStack, deviceContext);
-
-        rqContext = new AbstractRequestContext<Object>(42L) {
-            @Override
-            public void close() {
-                //NOOP
-            }
-        };
-        Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
-    }
+        groupStatisticsService = new OpendaylightGroupStatisticsServiceImpl(rqContextStack, deviceContext,
+                new AtomicLong(), notificationPublishService);
 
-    @Test
-    public void testGetAllGroupStatistics() throws Exception {
         Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
                 .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
+    }
 
+    @Test
+    public void testGetAllGroupStatistics() throws Exception {
         GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = buildGroupStatsResponse();
+
         final Future<RpcResult<GetAllGroupStatisticsOutput>> resultFuture
                 = groupStatisticsService.getAllGroupStatistics(input.build());
 
         Assert.assertTrue(resultFuture.isDone());
-        final RpcResult<GetAllGroupStatisticsOutput> rpcResult = resultFuture.get();
-        Assert.assertTrue(rpcResult.isSuccessful());
+        final RpcResult<GetAllGroupStatisticsOutput> rpcResultCompatible = resultFuture.get();
+        Assert.assertTrue(rpcResultCompatible.isSuccessful());
         Assert.assertEquals(MultipartType.OFPMPGROUP, requestInput.getValue().getType());
     }
 
     @Test
     public void testGetGroupDescription() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyGroupDescCaseBuilder()
+                                .setMultipartReplyGroupDesc(new MultipartReplyGroupDescBuilder()
+                                        .setGroupDesc(Collections.singletonList(new GroupDescBuilder()
+                                                .setGroupId(GROUP_ID)
+                                                .setBucketsList(Collections.singletonList(new BucketsListBuilder()
+                                                        .setWatchGroup(51L)
+                                                        .setWatchPort(new PortNumber(52L))
+                                                        .setWeight(53)
+                                                        .build()))
+                                                .setType(GroupType.OFPGTALL)
+                                                .build()))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+
         final Future<RpcResult<GetGroupDescriptionOutput>> resultFuture
                 = groupStatisticsService.getGroupDescription(input.build());
 
@@ -91,12 +128,25 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractStatsSer
 
     @Test
     public void testGetGroupFeatures() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyGroupFeaturesCaseBuilder()
+                                .setMultipartReplyGroupFeatures(new MultipartReplyGroupFeaturesBuilder()
+                                        .setActionsBitmap(Collections.singletonList(new ActionType(true,
+                                                false, false, false, false, false, false, false, false, false, false,
+                                                false, false, false, false, false, false)))
+                                        .setCapabilities(new GroupCapabilities(true, false, false, false))
+                                        .setTypes(new GroupTypes(true, false, false, false))
+                                        .setMaxGroups(Collections.singletonList(5L))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+
         final Future<RpcResult<GetGroupFeaturesOutput>> resultFuture
                 = groupStatisticsService.getGroupFeatures(input.build());
 
@@ -108,13 +158,12 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractStatsSer
 
     @Test
     public void testGetGroupStatistics() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"))
                 .setGroupId(new GroupId(21L));
 
+        rpcResult = buildGroupStatsResponse();
+
         final Future<RpcResult<GetGroupStatisticsOutput>> resultFuture
                 = groupStatisticsService.getGroupStatistics(input.build());
 
@@ -123,4 +172,28 @@ public class OpendaylightGroupStatisticsServiceImplTest extends AbstractStatsSer
         Assert.assertTrue(rpcResult.isSuccessful());
         Assert.assertEquals(MultipartType.OFPMPGROUP, requestInput.getValue().getType());
     }
+
+    private static RpcResult<Object> buildGroupStatsResponse() {
+        return RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyGroupCaseBuilder()
+                                .setMultipartReplyGroup(new MultipartReplyGroupBuilder()
+                                        .setGroupStats(Collections.singletonList(new GroupStatsBuilder()
+                                                .setByteCount(BigInteger.valueOf(21L))
+                                                .setPacketCount(BigInteger.valueOf(22L))
+                                                .setRefCount(23L)
+                                                .setDurationSec(24L)
+                                                .setDurationNsec(25L)
+                                                .setGroupId(GROUP_ID)
+                                                .setBucketStats(Collections.singletonList(new BucketStatsBuilder()
+                                                        .setByteCount(BigInteger.valueOf(26L))
+                                                        .setPacketCount(BigInteger.valueOf(27L))
+                                                        .build()))
+                                                .build()))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+    }
 }
\ No newline at end of file
index 7ab278e3fd5babf3d8d0e5065589598803acbdc2..0952a01dc9543ea21de3f59e6d97cc74e41e5f9c 100644 (file)
@@ -9,15 +9,18 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Matchers;
 import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
@@ -27,42 +30,80 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeaturesBuilder;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
  * Test for {@link OpendaylightMeterStatisticsServiceImpl}
  */
-public class OpendaylightMeterStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
 
+    private static final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId METER_ID = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(123L);
     @Captor
     private ArgumentCaptor<MultipartRequestInput> requestInput;
 
-    private RequestContext<Object> rqContext;
-
     private OpendaylightMeterStatisticsServiceImpl meterStatisticsService;
 
     public void setUp() {
-        meterStatisticsService = new OpendaylightMeterStatisticsServiceImpl(rqContextStack, deviceContext);
-
-        rqContext = new AbstractRequestContext<Object>(42L) {
-            @Override
-            public void close() {
-                //NOOP
-            }
-        };
-        Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
-    }
+        meterStatisticsService = new OpendaylightMeterStatisticsServiceImpl(rqContextStack, deviceContext,
+                new AtomicLong(), notificationPublishService);
 
-    @Test
-    public void testGetAllMeterConfigStatistics() throws Exception {
         Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
                 .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
+    }
 
+    @Test
+    public void testGetAllMeterConfigStatistics() throws Exception {
         GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyMeterConfigCaseBuilder()
+                                .setMultipartReplyMeterConfig(new MultipartReplyMeterConfigBuilder()
+                                        .setMeterConfig(Collections.singletonList(new MeterConfigBuilder()
+                                                .setFlags(new MeterFlags(true, false, false, false))
+                                                .setMeterId(METER_ID)
+                                                .setBands(Collections.singletonList(new BandsBuilder()
+                                                        .setMeterBand(new MeterBandDropCaseBuilder()
+                                                                .setMeterBandDrop(new MeterBandDropBuilder()
+                                                                        .setBurstSize(61L)
+                                                                        .setRate(62L)
+                                                                        .setType(MeterBandType.OFPMBTDROP)
+                                                                        .build())
+                                                                .build())
+                                                        .build()))
+                                                .build()))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+
         final Future<RpcResult<GetAllMeterConfigStatisticsOutput>> resultFuture
                 = meterStatisticsService.getAllMeterConfigStatistics(input.build());
 
@@ -74,12 +115,11 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractStatsSer
 
     @Test
     public void testGetAllMeterStatistics() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = buildMeterStatisticsReply();
+
         final Future<RpcResult<GetAllMeterStatisticsOutput>> resultFuture
                 = meterStatisticsService.getAllMeterStatistics(input.build());
 
@@ -91,12 +131,24 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractStatsSer
 
     @Test
     public void testGetMeterFeatures() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyMeterFeaturesCaseBuilder()
+                                .setMultipartReplyMeterFeatures(new MultipartReplyMeterFeaturesBuilder()
+                                        .setBandTypes(new MeterBandTypeBitmap(true, false))
+                                        .setCapabilities(new MeterFlags(true, false, false, false))
+                                        .setMaxBands((short) 71)
+                                        .setMaxColor((short) 72)
+                                        .setMaxMeter(73L)
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+
         final Future<RpcResult<GetMeterFeaturesOutput>> resultFuture
                 = meterStatisticsService.getMeterFeatures(input.build());
 
@@ -108,13 +160,12 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractStatsSer
 
     @Test
     public void testGetMeterStatistics() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"))
                 .setMeterId(new MeterId(21L));
 
+        rpcResult = buildMeterStatisticsReply();
+
         final Future<RpcResult<GetMeterStatisticsOutput>> resultFuture
                 = meterStatisticsService.getMeterStatistics(input.build());
 
@@ -123,4 +174,28 @@ public class OpendaylightMeterStatisticsServiceImplTest extends AbstractStatsSer
         Assert.assertTrue(rpcResult.isSuccessful());
         Assert.assertEquals(MultipartType.OFPMPMETER, requestInput.getValue().getType());
     }
+
+    protected RpcResult<Object> buildMeterStatisticsReply() {
+        return RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyMeterCaseBuilder()
+                                .setMultipartReplyMeter(new MultipartReplyMeterBuilder()
+                                        .setMeterStats(Collections.singletonList(new MeterStatsBuilder()
+                                                .setMeterId(METER_ID)
+                                                .setByteInCount(BigInteger.valueOf(81L))
+                                                .setDurationSec(82L)
+                                                .setDurationNsec(83L)
+                                                .setFlowCount(84L)
+                                                .setPacketInCount(BigInteger.valueOf(85L))
+                                                .setMeterBandStats(Collections.singletonList(new MeterBandStatsBuilder()
+                                                        .setByteBandCount(BigInteger.valueOf(86L))
+                                                        .setPacketBandCount(BigInteger.valueOf(87L))
+                                                        .build()))
+                                                .build()))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+    }
 }
\ No newline at end of file
index 34fa9dc7c6fe7fe2196e15a9ed4c810640bd2506..7aa587f32111e399afe51199aa38652545dbaee9 100644 (file)
@@ -9,56 +9,63 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Matchers;
 import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
  * Test for {@link OpendaylightPortStatisticsServiceImpl}
  */
-public class OpendaylightPortStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightPortStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
 
     @Captor
     private ArgumentCaptor<MultipartRequestInput> requestInput;
 
-    private RequestContext<Object> rqContext;
-
     private OpendaylightPortStatisticsServiceImpl portStatisticsService;
 
     public void setUp() {
-        portStatisticsService = new OpendaylightPortStatisticsServiceImpl(rqContextStack, deviceContext);
-
-        rqContext = new AbstractRequestContext<Object>(42L) {
-            @Override
-            public void close() {
-                //NOOP
-            }
-        };
-        Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
-    }
+        portStatisticsService = new OpendaylightPortStatisticsServiceImpl(rqContextStack, deviceContext,
+                new AtomicLong(), notificationPublishService);
 
-    @Test
-    public void testGetAllNodeConnectorsStatistics() throws Exception {
         Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
                 .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
+    }
 
+    @Test
+    public void testGetAllNodeConnectorsStatistics() throws Exception {
         GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = buildPortStatisticsReply();
+
         final Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> resultFuture
                 = portStatisticsService.getAllNodeConnectorsStatistics(input.build());
 
@@ -68,15 +75,43 @@ public class OpendaylightPortStatisticsServiceImplTest extends AbstractStatsServ
         Assert.assertEquals(MultipartType.OFPMPPORTSTATS, requestInput.getValue().getType());
     }
 
+    private static RpcResult<Object> buildPortStatisticsReply() {
+        return RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyPortStatsCaseBuilder()
+                                .setMultipartReplyPortStats(new MultipartReplyPortStatsBuilder()
+                                        .setPortStats(Collections.singletonList(new PortStatsBuilder()
+                                                .setDurationSec(90L)
+                                                .setDurationNsec(91L)
+                                                .setCollisions(BigInteger.valueOf(92L))
+                                                .setPortNo(93L)
+                                                .setRxBytes(BigInteger.valueOf(94L))
+                                                .setRxCrcErr(BigInteger.valueOf(95L))
+                                                .setRxDropped(BigInteger.valueOf(96L))
+                                                .setRxFrameErr(BigInteger.valueOf(97L))
+                                                .setRxErrors(BigInteger.valueOf(98L))
+                                                .setRxOverErr(BigInteger.valueOf(99L))
+                                                .setRxPackets(BigInteger.valueOf(100L))
+                                                .setTxBytes(BigInteger.valueOf(94L))
+                                                .setTxDropped(BigInteger.valueOf(96L))
+                                                .setTxErrors(BigInteger.valueOf(98L))
+                                                .setTxPackets(BigInteger.valueOf(98L))
+                                                .build()))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+    }
+
     @Test
     public void testGetNodeConnectorStatistics() throws Exception {
-        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
-                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
         GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"))
                 .setNodeConnectorId(new NodeConnectorId("unitProt:123:321"));
 
+        rpcResult = buildPortStatisticsReply();
+
         final Future<RpcResult<GetNodeConnectorStatisticsOutput>> resultFuture
                 = portStatisticsService.getNodeConnectorStatistics(input.build());
 
index 4bd9ab97c82190c5cfb145dbb8f938dcd184d0ce..64a892c025cd9cfaa3626cd9736da68f25b9765e 100644 (file)
@@ -9,49 +9,54 @@
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
 import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Matchers;
 import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
  * Test for {@link OpendaylightQueueStatisticsServiceImpl}
  */
-public class OpendaylightQueueStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightQueueStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
 
     @Captor
     private ArgumentCaptor<MultipartRequestInput> requestInput;
 
-    private RequestContext<Object> rqContext;
-
     private OpendaylightQueueStatisticsServiceImpl queueStatisticsService;
 
     public void setUp() {
-        queueStatisticsService = new OpendaylightQueueStatisticsServiceImpl(rqContextStack, deviceContext);
-
-        rqContext = new AbstractRequestContext<Object>(42L) {
-            @Override
-            public void close() {
-                //NOOP
-            }
-        };
-        Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
+        queueStatisticsService = new OpendaylightQueueStatisticsServiceImpl(rqContextStack, deviceContext,
+                new AtomicLong(), notificationPublishService);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
     }
 
     @Test
@@ -62,6 +67,8 @@ public class OpendaylightQueueStatisticsServiceImplTest extends AbstractStatsSer
         GetAllQueuesStatisticsFromAllPortsInputBuilder input = new GetAllQueuesStatisticsFromAllPortsInputBuilder()
                 .setNode(createNodeRef("unitProt:123"));
 
+        rpcResult = buildQueueStatsReply();
+
         final Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> resultFuture
                 = queueStatisticsService.getAllQueuesStatisticsFromAllPorts(input.build());
 
@@ -71,6 +78,27 @@ public class OpendaylightQueueStatisticsServiceImplTest extends AbstractStatsSer
         Assert.assertEquals(MultipartType.OFPMPQUEUE, requestInput.getValue().getType());
     }
 
+    protected RpcResult<Object> buildQueueStatsReply() {
+        return RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyQueueCaseBuilder()
+                                .setMultipartReplyQueue(new MultipartReplyQueueBuilder()
+                                        .setQueueStats(Collections.singletonList(new QueueStatsBuilder()
+                                                .setDurationSec(41L)
+                                                .setDurationNsec(42L)
+                                                .setTxBytes(BigInteger.valueOf(43L))
+                                                .setTxErrors(BigInteger.valueOf(44L))
+                                                .setTxPackets(BigInteger.valueOf(45L))
+                                                .setPortNo(46L)
+                                                .setQueueId(47L)
+                                                .build()))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+    }
+
     @Test
     public void testGetAllQueuesStatisticsFromGivenPort() throws Exception {
         Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
@@ -80,6 +108,8 @@ public class OpendaylightQueueStatisticsServiceImplTest extends AbstractStatsSer
                 .setNode(createNodeRef("unitProt:123"))
                 .setNodeConnectorId(new NodeConnectorId("unitProt:123:321"));
 
+        rpcResult = buildQueueStatsReply();
+
         final Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> resultFuture
                 = queueStatisticsService.getAllQueuesStatisticsFromGivenPort(input.build());
 
@@ -99,6 +129,8 @@ public class OpendaylightQueueStatisticsServiceImplTest extends AbstractStatsSer
                 .setNodeConnectorId(new NodeConnectorId("unitProt:123:321"))
                 .setQueueId(new QueueId(21L));
 
+        rpcResult = buildQueueStatsReply();
+
         final Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> resultFuture
                 = queueStatisticsService.getQueueStatisticsFromGivenPort(input.build());
 
index e6ba084bf54ee5340debbfbbf0f8ec64665524fb..842eac18cbd8c12fb65aa11beefb6e0e8c054522 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
+import java.util.concurrent.atomic.AtomicLong;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
@@ -25,7 +26,8 @@ public class PortStatsServiceTest extends AbstractStatsServiceTest {
     private PortStatsService portStatsService;
 
     public void setUp() {
-        portStatsService = new PortStatsService(rqContextStack, deviceContext);
+        portStatsService = new PortStatsService(rqContextStack, deviceContext,
+                new AtomicLong());
     }
 
     @Test
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java
new file mode 100644 (file)
index 0000000..501020b
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * 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.compatibility;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
+import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
+import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.impl.statistics.services.AbstractStatsServiceTest;
+import org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+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.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+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.MultipartReplyMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+/**
+ * Test for {@link AbstractCompatibleStatService}.
+ */
+public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest {
+
+    private static final NodeId NODE_ID = new NodeId("unit-test-node:123");
+    @Captor
+    private ArgumentCaptor<MultipartRequestInput> requestInput;
+    @Mock
+    private NotificationPublishService notificationPublishService;
+    @Mock
+    private DeviceState deviceState;
+    @Mock
+    private MessageTranslator<Object, Object> translator;
+
+    private AbstractRequestContext<Object> rqContext;
+
+    private RpcResult<Object> rpcResult;
+
+    private AbstractCompatibleStatService<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput,
+            GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput, AggregateFlowStatisticsUpdate> service;
+
+    @Override
+    public void setUp() {
+        rqContext = new AbstractRequestContext<Object>(42L) {
+            @Override
+            public void close() {
+                //NOOP
+            }
+        };
+        final Answer closeRequestFutureAnswer = new Answer() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                rqContext.setResult(rpcResult);
+                rqContext.close();
+                return null;
+            }
+        };
+
+        Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
+        Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
+        Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting();
+        Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
+
+        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
+                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+
+        Mockito.when(translatorLibrary.lookupTranslator(Matchers.any(TranslatorKey.class))).thenReturn(translator);
+
+        service = new AggregateFlowsInTableService(rqContextStack, deviceContext, new AtomicLong(20L));
+    }
+
+    @Test
+    public void testGetOfVersion() throws Exception {
+        Assert.assertEquals(OFConstants.OFP_VERSION_1_3, service.getOfVersion().getVersion());
+    }
+
+    @Test
+    public void testHandleAndNotify() throws Exception {
+        GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input =
+                new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
+                        .setNode(createNodeRef("unitProt:123"))
+                        .setTableId(new TableId((short) 1))
+                        .build();
+
+        rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+                new MultipartReplyMessageBuilder()
+                        .setVersion(OFConstants.OFP_VERSION_1_3)
+                        .setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder()
+                                .setMultipartReplyAggregate(new MultipartReplyAggregateBuilder()
+                                        .setByteCount(BigInteger.valueOf(11L))
+                                        .setFlowCount(12L)
+                                        .setPacketCount(BigInteger.valueOf(13L))
+                                        .build())
+                                .build())
+                        .build()
+        )).build();
+
+        AggregatedFlowStatistics aggregatedStats = new AggregatedFlowStatisticsBuilder()
+                .setByteCount(new Counter64(BigInteger.valueOf(11L)))
+                .setFlowCount(new Counter32(12L))
+                .setPacketCount(new Counter64(BigInteger.valueOf(13L)))
+                .build();
+        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceContext), Matchers.any()))
+                .thenReturn(aggregatedStats);
+
+
+        ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture =
+                service.handleAndNotify(input, notificationPublishService);
+
+        Assert.assertTrue(resultFuture.isDone());
+        final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResult = resultFuture.get();
+        Assert.assertTrue(rpcResult.isSuccessful());
+        Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
+        Mockito.verify(notificationPublishService, Mockito.timeout(500)).offerNotification(Matchers.any(AggregateFlowStatisticsUpdate.class));
+    }
+
+}
\ No newline at end of file
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java
new file mode 100644 (file)
index 0000000..01b363c
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * 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.compatibility;
+
+import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
+import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
+import org.opendaylight.openflowplugin.impl.statistics.services.AbstractSingleStatsServiceTest;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
+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.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+/**
+ * Test for {@link OpendaylightFlowStatisticsServiceDelegateImpl}.
+ * Skipping notification verification. This will be tested in tests of underlying single task oriented services.
+ */
+public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractSingleStatsServiceTest {
+
+    public static final int NOTIFICATION_WAIT_TIMEOUT_MS = 500;
+    @Captor
+    private ArgumentCaptor<MultipartRequestInput> requestInput;
+
+    private OpendaylightFlowStatisticsServiceDelegateImpl flowStatisticsServiceDelegate;
+    @Mock
+    private MessageTranslator<Object, Object> translator;
+
+    @Override
+    public void setUp() {
+        flowStatisticsServiceDelegate = new OpendaylightFlowStatisticsServiceDelegateImpl(
+                rqContextStack, deviceContext, notificationPublishService, new AtomicLong(21));
+
+        Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
+                .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+        Mockito.when(translatorLibrary.lookupTranslator(Matchers.<TranslatorKey>any())).thenReturn(translator);
+    }
+
+    @Test(expected = IllegalAccessError.class)
+    public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws Exception {
+        flowStatisticsServiceDelegate.getAggregateFlowStatisticsFromFlowTableForGivenMatch(null);
+    }
+
+    @Test
+    public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
+        GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
+                .setNode(createNodeRef("unitProt:123"))
+                .setTableId(new TableId((short) 1));
+
+        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceContext), Matchers.any()))
+                .thenReturn(new AggregatedFlowStatisticsBuilder()
+                        .setByteCount(new Counter64(BigInteger.valueOf(50L)))
+                        .setPacketCount(new Counter64(BigInteger.valueOf(51L)))
+                        .setFlowCount(new Counter32(52L))
+                        .build());
+
+        rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder()
+                .setType(MultipartType.OFPMPAGGREGATE)
+                .setVersion(OFConstants.OFP_VERSION_1_3)
+                .setFlags(new MultipartRequestFlags(false))
+                .setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder()
+                        .setMultipartReplyAggregate(new MultipartReplyAggregateBuilder()
+                                .setByteCount(BigInteger.valueOf(50L))
+                                .setPacketCount(BigInteger.valueOf(51L))
+                                .setFlowCount(52L)
+                                .build())
+                        .build())
+                .build()))
+                .build();
+
+        final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture
+                = flowStatisticsServiceDelegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
+
+        Assert.assertTrue(resultFuture.isDone());
+        final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResultCompatible = resultFuture.get();
+        Assert.assertTrue(rpcResultCompatible.isSuccessful());
+        Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
+
+        Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
+    }
+
+    @Test
+    public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
+        GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
+                .setNode(createNodeRef("unitProt:123"))
+                .setTableId(new TableId((short) 1));
+
+        rpcResult = buildFlowStatsReply();
+
+        final Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> resultFuture
+                = flowStatisticsServiceDelegate.getAllFlowStatisticsFromFlowTable(input.build());
+
+        Assert.assertTrue(resultFuture.isDone());
+        final RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResultCompatible = resultFuture.get();
+        Assert.assertTrue(rpcResultCompatible.isSuccessful());
+        Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+
+        Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
+    }
+
+    private static RpcResult<Object> buildFlowStatsReply() {
+        return RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder()
+                .setType(MultipartType.OFPMPFLOW)
+                .setVersion(OFConstants.OFP_VERSION_1_3)
+                .setFlags(new MultipartRequestFlags(false))
+                .setMultipartReplyBody(new MultipartReplyFlowCaseBuilder()
+                        .setMultipartReplyFlow(new MultipartReplyFlowBuilder()
+                                .setFlowStats(Collections.singletonList(new FlowStatsBuilder()
+                                        .setTableId((short) 123)
+                                        .setDurationSec(10L)
+                                        .setDurationNsec(11L)
+                                        .setByteCount(BigInteger.valueOf(12L))
+                                        .setPacketCount(BigInteger.valueOf(13L))
+                                        .setCookie(BigInteger.ZERO)
+                                        .setPriority(14)
+                                        .setMatch(new MatchBuilder()
+                                                .setMatchEntry(Collections.<MatchEntry>emptyList())
+                                                .build())
+                                        .setHardTimeout(15)
+                                        .setIdleTimeout(16)
+                                        .setFlags(new FlowModFlags(true, false, false, false, false))
+                                        .setInstruction(Collections.singletonList(new InstructionBuilder()
+                                                .setInstructionChoice(new ApplyActionsCaseBuilder()
+                                                        .setApplyActions(new ApplyActionsBuilder()
+                                                                .setAction(Collections.singletonList(new ActionBuilder()
+                                                                        .setActionChoice(new OutputActionCaseBuilder()
+                                                                                .setOutputAction(new OutputActionBuilder()
+                                                                                        .setMaxLength(17)
+                                                                                        .setPort(new PortNumber(18L))
+                                                                                        .build())
+                                                                                .build())
+                                                                        .build()))
+                                                                .build())
+                                                        .build())
+                                                .build()))
+                                        .build()))
+                                .build())
+                        .build())
+                .build()))
+                .build();
+    }
+
+    @Test
+    public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
+        GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
+                .setNode(createNodeRef("unitProt:123"));
+
+        rpcResult = buildFlowStatsReply();
+
+        final Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> resultFuture
+                = flowStatisticsServiceDelegate.getAllFlowsStatisticsFromAllFlowTables(input.build());
+
+        Assert.assertTrue(resultFuture.isDone());
+        final RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResultCompatible = resultFuture.get();
+        Assert.assertTrue(rpcResultCompatible.isSuccessful());
+        Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+
+        Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
+    }
+
+    @Test
+    public void testGetFlowStatisticsFromFlowTable() throws Exception {
+        GetFlowStatisticsFromFlowTableInputBuilder input = new GetFlowStatisticsFromFlowTableInputBuilder()
+                .setNode(createNodeRef("unitProt:123"))
+                .setTableId((short) 1)
+                .setPriority(123)
+                .setOutPort(BigInteger.ONE);
+
+        rpcResult = buildFlowStatsReply();
+
+        final Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> resultFuture
+                = flowStatisticsServiceDelegate.getFlowStatisticsFromFlowTable(input.build());
+
+        Assert.assertTrue(resultFuture.isDone());
+        final RpcResult<GetFlowStatisticsFromFlowTableOutput> rpcResultCompatible = resultFuture.get();
+        Assert.assertTrue(rpcResultCompatible.isSuccessful());
+        Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+
+        Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
+    }
+}
\ No newline at end of file