Improve flow collection
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / singlelayer / SingleLayerFlowMultipartRequestOnTheFlyCallback.java
index fb896eb217f4101edd7dbf862029b8466093f372..7744c4d6f288c35732eaa1b66c38d95d5c340dc3 100644 (file)
@@ -8,40 +8,25 @@
 
 package org.opendaylight.openflowplugin.impl.services.singlelayer;
 
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
-import java.util.Optional;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
-import org.opendaylight.openflowplugin.impl.common.MultipartReplyTranslatorUtil;
 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
 import org.opendaylight.openflowplugin.impl.services.AbstractMultipartRequestOnTheFlyCallback;
-import org.opendaylight.openflowplugin.impl.statistics.StatisticsGatheringUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 
 public class SingleLayerFlowMultipartRequestOnTheFlyCallback<T extends OfHeader> extends AbstractMultipartRequestOnTheFlyCallback<T> {
 
-    private final DeviceInfo deviceInfo;
-    private final DeviceFlowRegistry deviceFlowRegistry;
-    private boolean virgin = true;
-
-    public SingleLayerFlowMultipartRequestOnTheFlyCallback(final RequestContext<List<T>> context, Class<?> requestType,
+    public SingleLayerFlowMultipartRequestOnTheFlyCallback(final RequestContext<List<T>> context,
+                                                           final Class<?> requestType,
                                                            final DeviceContext deviceContext,
                                                            final EventIdentifier eventIdentifier,
                                                            final MultipartWriterProvider statisticsWriterProvider) {
-        super(context, requestType, deviceContext, eventIdentifier, statisticsWriterProvider);
-        deviceInfo = deviceContext.getDeviceInfo();
-        deviceFlowRegistry = deviceContext.getDeviceFlowRegistry();
+        super(context, requestType, deviceContext, eventIdentifier, statisticsWriterProvider, null);
     }
 
     @Override
@@ -60,28 +45,4 @@ public class SingleLayerFlowMultipartRequestOnTheFlyCallback<T extends OfHeader>
         return MultipartType.OFPMPFLOW;
     }
 
-    @Override
-    protected void onFinishedCollecting() {
-        deviceFlowRegistry.processMarks();
-    }
-
-    @Override
-    protected ListenableFuture<Optional<? extends MultipartReplyBody>> processStatistics(T result) {
-        final ListenableFuture<Optional<? extends MultipartReplyBody>> future = Futures.transform(
-            StatisticsGatheringUtils.deleteAllKnownFlows(
-                getTxFacade(),
-                deviceInfo
-                    .getNodeInstanceIdentifier()
-                    .augmentation(FlowCapableNode.class),
-                !virgin),
-            (Function<Void, Optional<? extends MultipartReplyBody>>) input -> MultipartReplyTranslatorUtil
-                .translate(result, deviceInfo, null, null));
-
-        if (virgin) {
-            virgin = false;
-        }
-
-        return future;
-    }
-
 }