Update MRI upstreams for Phosphorus
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / dedicated / StatisticsGatheringOnTheFlyService.java
index a88e405b7c71372a3cb846253e2f7c52713c525f..e90d10ec0aec9b830df01d64cce66914127fdba8 100644 (file)
@@ -8,38 +8,43 @@
 
 package org.opendaylight.openflowplugin.impl.statistics.services.dedicated;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
-import java.util.concurrent.Future;
 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.statistics.ofpspecific.EventIdentifier;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.StatisticsGatherer;
 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
+import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
 import org.opendaylight.openflowplugin.impl.services.AbstractMultipartOnTheFlyService;
-import org.opendaylight.openflowplugin.impl.services.ServiceException;
 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.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.OfHeader;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * collects statistics and processes them on the fly
+ * Collects statistics and processes them on the fly.
  */
-public class StatisticsGatheringOnTheFlyService extends AbstractMultipartOnTheFlyService<MultipartType> implements StatisticsGatherer {
+public class StatisticsGatheringOnTheFlyService<T extends OfHeader>
+    extends AbstractMultipartOnTheFlyService<MultipartType, T>
+    implements StatisticsGatherer<T> {
 
     private static final Logger LOG = LoggerFactory.getLogger(StatisticsGatheringOnTheFlyService.class);
 
-    public StatisticsGatheringOnTheFlyService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
-        super(requestContextStack, deviceContext, convertorExecutor);
+    public StatisticsGatheringOnTheFlyService(final RequestContextStack requestContextStack,
+                                              final DeviceContext deviceContext,
+                                              final ConvertorExecutor convertorExecutor,
+                                              final MultipartWriterProvider statisticsWriterProvider) {
+        super(requestContextStack, deviceContext, convertorExecutor, statisticsWriterProvider);
     }
 
     @Override
-    public Future<RpcResult<List<MultipartReply>>> getStatisticsOfType(final EventIdentifier eventIdentifier, final MultipartType type) {
+    public ListenableFuture<RpcResult<List<T>>> getStatisticsOfType(final EventIdentifier eventIdentifier,
+                                                                    final MultipartType type) {
         LOG.debug("Getting statistics (onTheFly) for node {} of type {}", getDeviceInfo().getNodeId(), type);
         EventsTimeCounter.markStart(eventIdentifier);
         setEventIdentifier(eventIdentifier);
@@ -47,7 +52,10 @@ public class StatisticsGatheringOnTheFlyService extends AbstractMultipartOnTheFl
     }
 
     @Override
-    protected OfHeader buildRequest(final Xid xid, final MultipartType input) throws ServiceException {
-        return MultipartRequestInputFactory.makeMultipartRequestInput(xid.getValue(), getVersion(), input);
+    protected OfHeader buildRequest(final Xid xid, final MultipartType input) {
+        return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue(),
+                                                                 getVersion(),
+                                                                 input,
+                                                                 canUseSingleLayerSerialization());
     }
 }