Merge "DeviceState changes"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / AggregateFlowsInTableService.java
index e71017b4780b049c2b5ed0dba7c91a0e96966476..4c822cd55cd7623790fe34a5b775e901a09a63ad 100644 (file)
@@ -38,8 +38,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public final class AggregateFlowsInTableService extends AbstractCompatibleStatService<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput,
         GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput, AggregateFlowStatisticsUpdate> {
 
-    public AggregateFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    final TranslatorLibrary translatorLibrary;
+
+    public static AggregateFlowsInTableService createWithOook(final RequestContextStack requestContextStack,
+                                                                                  final DeviceContext deviceContext,
+                                                                                  AtomicLong compatibilityXidSeed) {
+        return new AggregateFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed, deviceContext.oook());
+    }
+
+    public AggregateFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
+                                        AtomicLong compatibilityXidSeed, TranslatorLibrary translatorLibrary) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
+
+        this.translatorLibrary = translatorLibrary;
     }
 
     @Override
@@ -76,14 +87,13 @@ public final class AggregateFlowsInTableService extends AbstractCompatibleStatSe
         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 AggregatedFlowStatistics flowStatistics = messageTranslator.translate(mpReply, getDeviceContext().getDeviceInfo(), null);
         final AggregateFlowStatisticsUpdateBuilder notification = new AggregateFlowStatisticsUpdateBuilder(flowStatistics)
-                .setId(getDeviceContext().getDeviceState().getNodeId())
+                .setId(getDeviceContext().getDeviceInfo().getNodeId())
                 .setMoreReplies(Boolean.FALSE)
                 .setTransactionId(emulatedTxId);