Merge "Fix codestyle"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / dedicated / StatisticsGatheringService.java
index fc0f8d3f3ff3c09a6833ddc9efdab0eeb556be47..ade408bf9d5fdb9def2da260c9e1fa0c6ded73b7 100644 (file)
@@ -8,8 +8,8 @@
 
 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;
@@ -17,28 +17,28 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.Event
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.StatisticsGatherer;
 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
 import org.opendaylight.openflowplugin.impl.services.AbstractMultipartService;
-import org.opendaylight.openflowplugin.impl.services.ServiceException;
+import org.opendaylight.openflowplugin.impl.services.util.ServiceException;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCounter;
 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;
 
-/**
- * Created by Martin Bobak <mbobak@cisco.com> on 4.4.2015.
- */
-public class StatisticsGatheringService extends AbstractMultipartService<MultipartType> implements StatisticsGatherer {
+public class StatisticsGatheringService<T extends OfHeader>
+    extends AbstractMultipartService<MultipartType, T>
+    implements StatisticsGatherer<T> {
 
     private static final Logger LOG = LoggerFactory.getLogger(StatisticsGatheringService.class);
 
-    public StatisticsGatheringService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+    public StatisticsGatheringService(final RequestContextStack requestContextStack,
+                                      final DeviceContext deviceContext) {
         super(requestContextStack, deviceContext);
     }
 
     @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 for node {} of type {}", getDeviceInfo().getNodeId(), type);
         EventsTimeCounter.markStart(eventIdentifier);
         setEventIdentifier(eventIdentifier);
@@ -47,6 +47,9 @@ public class StatisticsGatheringService extends AbstractMultipartService<Multipa
 
     @Override
     protected OfHeader buildRequest(final Xid xid, final MultipartType input) throws ServiceException {
-        return MultipartRequestInputFactory.makeMultipartRequestInput(xid.getValue(), getVersion(), input);
+        return MultipartRequestInputFactory.makeMultipartRequest(xid.getValue(),
+                                                                 getVersion(),
+                                                                 input,
+                                                                 canUseSingleLayerSerialization());
     }
 }