Fix errors in serializers and deserializers
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / MultipartRequestOnTheFlyCallback.java
index d3b34ce520efa9ae2faa4cfcb310812f56b0a91f..9b1c0e729158ba831b4fe13ce4dcd379f13501fe 100644 (file)
@@ -12,9 +12,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collections;
 import java.util.List;
-
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
@@ -23,6 +21,7 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.Messa
 import org.opendaylight.openflowplugin.impl.statistics.SinglePurposeMultipartReplyTranslator;
 import org.opendaylight.openflowplugin.impl.statistics.StatisticsGatheringUtils;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCounter;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 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;
@@ -36,14 +35,13 @@ import org.slf4j.LoggerFactory;
 
 final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<List<MultipartReply>> {
     private static final Logger LOG = LoggerFactory.getLogger(MultipartRequestOnTheFlyCallback.class);
-    private static final SinglePurposeMultipartReplyTranslator MULTIPART_REPLY_TRANSLATOR = new SinglePurposeMultipartReplyTranslator();
+    private final SinglePurposeMultipartReplyTranslator multipartReplyTranslator;
     private final DeviceInfo deviceInfo;
     private final DeviceFlowRegistry registry;
     private boolean virgin = true;
     private boolean finished = false;
     private final EventIdentifier doneEventIdentifier;
     private final TxFacade txFacade;
-    private final DeviceState deviceState;
 
 
     public MultipartRequestOnTheFlyCallback(final RequestContext<List<MultipartReply>> context,
@@ -53,13 +51,14 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
                                             final DeviceInfo deviceInfo,
                                             final DeviceFlowRegistry registry,
                                             final TxFacade txFacade,
-                                            final DeviceState deviceState) {
+                                            final ConvertorExecutor convertorExecutor) {
         super(context, requestType, messageSpy, eventIdentifier);
 
         this.deviceInfo = deviceInfo;
         this.registry = registry;
         this.txFacade = txFacade;
-        this.deviceState = deviceState;
+
+        multipartReplyTranslator = new SinglePurposeMultipartReplyTranslator(convertorExecutor);
 
         //TODO: this is focused on flow stats only - need more general approach if used for more than flow stats
         doneEventIdentifier = new EventIdentifier(MultipartType.OFPMPFLOW.name(), deviceInfo.getNodeId().toString());
@@ -93,14 +92,14 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
             final MultipartReply multipartReply = (MultipartReply) result;
 
             final MultipartReply singleReply = multipartReply;
-            final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(
+            final List<? extends DataObject> multipartDataList = multipartReplyTranslator.translate(
                     deviceInfo.getDatapathId(), deviceInfo.getVersion(), singleReply);
             final Iterable<? extends DataObject> allMultipartData = multipartDataList;
 
             //TODO: following part is focused on flow stats only - need more general approach if used for more than flow stats
             ListenableFuture<Void> future;
             if (virgin) {
-                future = StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo, registry, txFacade, deviceState);
+                future = StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo, registry, txFacade);
                 virgin = false;
             } else {
                 future = Futures.immediateFuture(null);
@@ -127,8 +126,8 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
         EventsTimeCounter.markEnd(getEventIdentifier());
         final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(Collections.<MultipartReply>emptyList()).build();
         spyMessage(MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_OUT_SUCCESS);
-        setResult(rpcResult);
         txFacade.submitTransaction();
+        setResult(rpcResult);
         finished = true;
     }
 }