DataCrate removed and its usage replaced by RequestContext 87/20587/1
authorMartin Bobak <mbobak@cisco.com>
Sat, 16 May 2015 09:01:10 +0000 (11:01 +0200)
committerMartin Bobak <mbobak@cisco.com>
Sat, 16 May 2015 09:02:17 +0000 (11:02 +0200)
DataCrate created unnecessary code and in light of newest OFJ changes became obsolete.
All we need to have when handling rpc call is request context.

Change-Id: Iff565c48af6634c9000a2b09057997b81cbb062b
Signed-off-by: Martin Bobak <mbobak@cisco.com>
16 files changed:
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/CommonService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/DataCrate.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/DataCrateBuilder.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/PacketProcessingServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalPortServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalTableServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringService.java

index 733806123134145922187aa35b9c96d1c2bfbf00..b6d691f939fc2ad99fb72b38977a3a2e5c720322 100644 (file)
@@ -97,33 +97,14 @@ public abstract class CommonService {
         return primaryConnectionAdapter;
     }
 
-    /**
-     * @param connectionID connection identifier
-     * @param function     data sender
-     * @param <T>          rpc result backend type
-     * @param <F>          final rpc backend type
-     * @return
-     */
-    public <T, F> ListenableFuture<RpcResult<T>> handleServiceCall(final BigInteger connectionID,
-                                                                   final Function<DataCrate<T>, ListenableFuture<RpcResult<F>>> function) {
-        DataCrateBuilder<T> dataCrateBuilder = DataCrateBuilder.<T>builder();
-        return handleServiceCall(function, dataCrateBuilder);
-    }
-
-    public <T, F> ListenableFuture<RpcResult<T>> handleServiceCall(final Function<DataCrate<T>, ListenableFuture<RpcResult<F>>> function) {
-        DataCrateBuilder<T> dataCrateBuilder = DataCrateBuilder.<T>builder();
-        return handleServiceCall(function, dataCrateBuilder);
-    }
 
     /**
      * @param <T>
      * @param <F>
      * @param function
-     * @param dataCrateBuilder predefined data
      * @return
      */
-    public final <T, F> ListenableFuture<RpcResult<T>> handleServiceCall(final Function<DataCrate<T>, ListenableFuture<RpcResult<F>>> function,
-                                                                         final DataCrateBuilder<T> dataCrateBuilder) {
+    public final <T, F> ListenableFuture<RpcResult<T>> handleServiceCall(final Function<RequestContext<T>, ListenableFuture<RpcResult<F>>> function) {
 
         LOG.trace("Handling general service call");
         final RequestContext<T> requestContext = createRequestContext();
@@ -140,15 +121,13 @@ public abstract class CommonService {
         }
         final Xid xid = new Xid(reservedXid);
         requestContext.setXid(xid);
-        DataCrate<T> dataCrate = dataCrateBuilder.setRequestContext(requestContext)
-                .build();
         final ListenableFuture<RpcResult<F>> resultFromOFLib;
 
         LOG.trace("Hooking xid {} to device context - precaution.", requestContext.getXid().getValue());
         deviceContext.hookRequestCtx(xid, requestContext);
 
         messageSpy.spyMessage(requestContext.getClass(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_READY_FOR_SUBMIT);
-        function.apply(dataCrate);
+        function.apply(requestContext);
 
         return requestContext.getFuture();
 
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/DataCrate.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/DataCrate.java
deleted file mode 100644 (file)
index 14c0c04..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.impl.services;
-
-import java.math.BigInteger;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
-
-public final class DataCrate<T> {
-    private final BigInteger iDConnection;
-    private final RequestContext<T> requestContext;
-    private final FlowModInputBuilder flowModInputBuilder;
-
-    public DataCrate(final DataCrateBuilder<T> builder) {
-        iDConnection = builder.iDConnection;
-        flowModInputBuilder = builder.flowModInputBuilder;
-        requestContext = builder.requestContext;
-    }
-
-    public FlowModInputBuilder getFlowModInputBuilder() {
-        return flowModInputBuilder;
-    }
-
-    public BigInteger getiDConnection() {
-        return iDConnection;
-    }
-
-    public RequestContext<T> getRequestContext() {
-        return requestContext;
-    }
-}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/DataCrateBuilder.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/DataCrateBuilder.java
deleted file mode 100644 (file)
index a9674b0..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.impl.services;
-
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import java.math.BigInteger;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
-
-public class DataCrateBuilder<T> {
-    BigInteger iDConnection;
-    RequestContext<T> requestContext;
-    FlowModInputBuilder flowModInputBuilder;
-
-    public DataCrateBuilder() {
-    }
-
-    public DataCrateBuilder<T> setFlowModInputBuilder(final FlowModInputBuilder flowModInputBuilder) {
-        this.flowModInputBuilder = flowModInputBuilder;
-        return this;
-    }
-
-    public DataCrateBuilder<T> setiDConnection(final BigInteger iDConnection) {
-        this.iDConnection = iDConnection;
-        return this;
-    }
-
-    public DataCrateBuilder<T> setRequestContext(final RequestContext<T> requestContext) {
-        this.requestContext = requestContext;
-        return this;
-    }
-
-    public static <T> DataCrateBuilder<T> builder() {
-        return new DataCrateBuilder<>();
-    }
-
-    public DataCrate<T> build() {
-        return new DataCrate<>(this);
-    }
-
-
-
-}
index 91f4f51432ec174011788ebd29a70e388807c1bf..c176a2a282374278bdb17725b8b2e831f3674314 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
@@ -34,10 +35,10 @@ public class PacketProcessingServiceImpl extends CommonService implements Packet
     public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
         getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
 
-        return handleServiceCall(new Function<DataCrate<Void>, ListenableFuture<RpcResult<Void>>>() {
+        return handleServiceCall(new Function<RequestContext<Void>, ListenableFuture<RpcResult<Void>>>() {
             @Override
-            public ListenableFuture<RpcResult<Void>> apply(final DataCrate<Void> data) {
-                final Xid xid = data.getRequestContext().getXid();
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<Void> requestContext) {
+                final Xid xid = requestContext.getXid();
                 final PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, getVersion(), xid.getValue(),
                         getDatapathId());
 
index 2431f06e60d5756186529faff6f6cba8545f6e01..27532be7b76c438f9d354e09dd5d9b545d2d8fe6 100644 (file)
@@ -19,6 +19,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
@@ -100,12 +101,12 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
     @Override
     public Future<RpcResult<RemoveFlowOutput>> removeFlow(final RemoveFlowInput input) {
         LOG.trace("Calling remove flow for flow with ID ={}.", input.getFlowRef());
-        return this.<RemoveFlowOutput, Void>handleServiceCall(new Function<DataCrate<RemoveFlowOutput>, ListenableFuture<RpcResult<Void>>>() {
+        return this.<RemoveFlowOutput, Void>handleServiceCall(new Function<RequestContext<RemoveFlowOutput>, ListenableFuture<RpcResult<Void>>>() {
             @Override
-            public ListenableFuture<RpcResult<Void>> apply(final DataCrate<RemoveFlowOutput> data) {
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<RemoveFlowOutput> requestContext) {
                 final FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(input, getVersion(),
                         getDatapathId());
-                final ListenableFuture<RpcResult<Void>> future = createResultForFlowMod(data, ofFlowModInput);
+                final ListenableFuture<RpcResult<Void>> future = createResultForFlowMod(requestContext, ofFlowModInput);
                 Futures.addCallback(future, new FutureCallback() {
                     @Override
                     public void onSuccess(final Object o) {
@@ -194,17 +195,14 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
 
         final List<ListenableFuture<RpcResult<T>>> partialFutures = new ArrayList<>();
 
-        for (FlowModInputBuilder flowModInputBuilder : ofFlowModInputs) {
-            DataCrateBuilder<T> dataCrateBuilder = DataCrateBuilder.<T>builder().setFlowModInputBuilder(flowModInputBuilder);
+        for (final FlowModInputBuilder flowModInputBuilder : ofFlowModInputs) {
             ListenableFuture<RpcResult<T>> partialFuture = handleServiceCall(
-                    new Function<DataCrate<T>, ListenableFuture<RpcResult<Void>>>() {
+                    new Function<RequestContext<T>, ListenableFuture<RpcResult<Void>>>() {
                         @Override
-                        public ListenableFuture<RpcResult<Void>> apply(final DataCrate<T> data) {
-                            return createResultForFlowMod(data);
+                        public ListenableFuture<RpcResult<Void>> apply(final RequestContext<T> requestContext) {
+                            return createResultForFlowMod(requestContext, flowModInputBuilder);
                         }
-                    },
-                    dataCrateBuilder
-            );
+                    });
             partialFutures.add(partialFuture);
         }
 
@@ -227,13 +225,9 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
         return finalFuture;
     }
 
-    protected <T> ListenableFuture<RpcResult<Void>> createResultForFlowMod(final DataCrate<T> data) {
-        return createResultForFlowMod(data, data.getFlowModInputBuilder());
-    }
-
-    protected <T> ListenableFuture<RpcResult<Void>> createResultForFlowMod(final DataCrate<T> data, final FlowModInputBuilder flowModInputBuilder) {
+    protected <T> ListenableFuture<RpcResult<Void>> createResultForFlowMod(final RequestContext<T> requestContext, final FlowModInputBuilder flowModInputBuilder) {
         final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-        final long xid = data.getRequestContext().getXid().getValue();
+        final long xid = requestContext.getXid().getValue();
         flowModInputBuilder.setXid(xid);
         final FlowModInput flowModInput = flowModInputBuilder.build();
 
@@ -241,8 +235,8 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
         outboundQueue.commitEntry(xid, flowModInput, new FutureCallback<OfHeader>() {
             @Override
             public void onSuccess(final OfHeader ofHeader) {
-                RequestContextUtil.closeRequstContext(data.getRequestContext());
-                getDeviceContext().unhookRequestCtx(data.getRequestContext().getXid());
+                RequestContextUtil.closeRequstContext(requestContext);
+                getDeviceContext().unhookRequestCtx(requestContext.getXid());
                 getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
 
                 settableFuture.set(RpcResultBuilder.<Void>success().build());
@@ -251,8 +245,8 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
             @Override
             public void onFailure(final Throwable throwable) {
                 RpcResultBuilder rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, throwable.getMessage(), throwable);
-                RequestContextUtil.closeRequstContext(data.getRequestContext());
-                getDeviceContext().unhookRequestCtx(data.getRequestContext().getXid());
+                RequestContextUtil.closeRequstContext(requestContext);
+                getDeviceContext().unhookRequestCtx(requestContext.getXid());
                 settableFuture.set(rpcResultBuilder.build());
             }
         });
index 91579f56fe2772f0040a43e9ebf89376800859c6..1aa25d60f24fd59d1625fc891622630bca1ddd76 100644 (file)
@@ -8,10 +8,14 @@
 package org.opendaylight.openflowplugin.impl.services;
 
 import com.google.common.base.Function;
+import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.Future;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
@@ -24,8 +28,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.Sal
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 
 public class SalGroupServiceImpl extends CommonService implements SalGroupService {
@@ -40,24 +48,21 @@ public class SalGroupServiceImpl extends CommonService implements SalGroupServic
     @Override
     public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
         getDeviceContext().getDeviceGroupRegistry().store(input.getGroupId());
-        return this.<AddGroupOutput, Void>handleServiceCall(getPrimaryConnection(),
-                new Function<DataCrate<AddGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
-
+        return this.<AddGroupOutput, Void>handleServiceCall(new Function<RequestContext<AddGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<AddGroupOutput> data) {
-                        return convertAndSend(input, data);
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<AddGroupOutput> requestContext) {
+                        return convertAndSend(input, requestContext);
                     }
                 });
     }
 
     @Override
     public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
-        return this.<UpdateGroupOutput, Void>handleServiceCall(getPrimaryConnection(),
-                new Function<DataCrate<UpdateGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
+        return this.<UpdateGroupOutput, Void>handleServiceCall(new Function<RequestContext<UpdateGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<UpdateGroupOutput> data) {
-                        return convertAndSend(input.getUpdatedGroup(), data);
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<UpdateGroupOutput> requestContext) {
+                        return convertAndSend(input.getUpdatedGroup(), requestContext);
                     }
                 });
     }
@@ -65,21 +70,40 @@ public class SalGroupServiceImpl extends CommonService implements SalGroupServic
     @Override
     public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
         getDeviceContext().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
-        return this.<RemoveGroupOutput, Void>handleServiceCall(getPrimaryConnection(),
-                new Function<DataCrate<RemoveGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
+        return this.<RemoveGroupOutput, Void>handleServiceCall(new Function<RequestContext<RemoveGroupOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<RemoveGroupOutput> data) {
-                        return convertAndSend(input, data);
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<RemoveGroupOutput> requestContext) {
+                        return convertAndSend(input, requestContext);
                     }
                 });
     }
 
-    <T> ListenableFuture<RpcResult<Void>> convertAndSend(final Group iputGroup, final DataCrate<T> data) {
+    <T> ListenableFuture<RpcResult<Void>> convertAndSend(final Group iputGroup, final RequestContext<T> requestContext) {
+        final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
         getMessageSpy().spyMessage(iputGroup.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
         final GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(iputGroup, getVersion(), getDatapathId());
-        final Xid xid = data.getRequestContext().getXid();
+        final Xid xid = requestContext.getXid();
         ofGroupModInput.setXid(xid.getValue());
-        return JdkFutureAdapters.listenInPoolThread(provideConnectionAdapter(data.getiDConnection()).groupMod(ofGroupModInput.build()));
+        final SettableFuture<RpcResult<Void>> settableFuture = SettableFuture.create();
+        outboundQueue.commitEntry(xid.getValue(), ofGroupModInput.build(), new FutureCallback<OfHeader>() {
+            @Override
+            public void onSuccess(final OfHeader ofHeader) {
+                RequestContextUtil.closeRequstContext(requestContext);
+                getDeviceContext().unhookRequestCtx(requestContext.getXid());
+                getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+
+                settableFuture.set(RpcResultBuilder.<Void>success().build());
+            }
+
+            @Override
+            public void onFailure(final Throwable throwable) {
+                RpcResultBuilder rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
+                RequestContextUtil.closeRequstContext(requestContext);
+                getDeviceContext().unhookRequestCtx(requestContext.getXid());
+                settableFuture.set(rpcResultBuilder.build());
+            }
+        });
+        return settableFuture;
     }
 }
index 13689e5a267faa17d42bb0a0f69d5f3bcff5617b..1b0a1fe5f9042be68b27c9d7476961923171214a 100644 (file)
@@ -8,10 +8,13 @@
 package org.opendaylight.openflowplugin.impl.services;
 
 import com.google.common.base.Function;
-import com.google.common.util.concurrent.JdkFutureAdapters;
+import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.Future;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
@@ -24,8 +27,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Sal
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 
 public class SalMeterServiceImpl extends CommonService implements SalMeterService {
@@ -39,44 +46,61 @@ public class SalMeterServiceImpl extends CommonService implements SalMeterServic
     @Override
     public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
         getDeviceContext().getDeviceMeterRegistry().store(input.getMeterId());
-        return this.<AddMeterOutput, Void>handleServiceCall( getPrimaryConnection(),
-                 new Function<DataCrate<AddMeterOutput>,ListenableFuture<RpcResult<Void>>>() {
-                    @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<AddMeterOutput> data) {
-                        return convertAndSend(input, data);
-                    }
-                });
+        return this.<AddMeterOutput, Void>handleServiceCall(new Function<RequestContext<AddMeterOutput>, ListenableFuture<RpcResult<Void>>>() {
+            @Override
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<AddMeterOutput> requestContext) {
+                return convertAndSend(input, requestContext);
+            }
+        });
     }
 
     @Override
     public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
-        return this.<UpdateMeterOutput, Void>handleServiceCall( getPrimaryConnection(),
-                 new Function<DataCrate<UpdateMeterOutput>,ListenableFuture<RpcResult<Void>>>() {
-                    @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<UpdateMeterOutput> data) {
-                        return convertAndSend(input.getUpdatedMeter(), data);
-                    }
-                });
+        return this.<UpdateMeterOutput, Void>handleServiceCall(new Function<RequestContext<UpdateMeterOutput>, ListenableFuture<RpcResult<Void>>>() {
+            @Override
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<UpdateMeterOutput> requestContext) {
+                return convertAndSend(input.getUpdatedMeter(), requestContext);
+            }
+        });
     }
 
     @Override
     public Future<RpcResult<RemoveMeterOutput>> removeMeter(final RemoveMeterInput input) {
         getDeviceContext().getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
-        return this.<RemoveMeterOutput, Void>handleServiceCall( getPrimaryConnection(),
-                 new Function<DataCrate<RemoveMeterOutput>,ListenableFuture<RpcResult<Void>>>() {
-                    @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<RemoveMeterOutput> data) {
-                        return convertAndSend(input, data);
-                    }
-                });
+        return this.<RemoveMeterOutput, Void>handleServiceCall(new Function<RequestContext<RemoveMeterOutput>, ListenableFuture<RpcResult<Void>>>() {
+            @Override
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<RemoveMeterOutput> requestContext) {
+                return convertAndSend(input, requestContext);
+            }
+        });
     }
 
-    <T> ListenableFuture<RpcResult<Void>> convertAndSend(final Meter iputMeter, final DataCrate<T> data) {
+    <T> ListenableFuture<RpcResult<Void>> convertAndSend(final Meter iputMeter, final RequestContext<T> requestContext) {
         getMessageSpy().spyMessage(iputMeter.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+        final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
 
         final MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(iputMeter, getVersion());
-        final Xid xid = data.getRequestContext().getXid();
+        final Xid xid = requestContext.getXid();
         ofMeterModInput.setXid(xid.getValue());
-        return JdkFutureAdapters.listenInPoolThread(provideConnectionAdapter(data.getiDConnection()).meterMod(ofMeterModInput.build()));
+        final SettableFuture<RpcResult<Void>> settableFuture = SettableFuture.create();
+        outboundQueue.commitEntry(xid.getValue(), ofMeterModInput.build(), new FutureCallback<OfHeader>() {
+            @Override
+            public void onSuccess(final OfHeader ofHeader) {
+                RequestContextUtil.closeRequstContext(requestContext);
+                getDeviceContext().unhookRequestCtx(requestContext.getXid());
+                getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+
+                settableFuture.set(RpcResultBuilder.<Void>success().build());
+            }
+
+            @Override
+            public void onFailure(final Throwable throwable) {
+                RpcResultBuilder rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
+                RequestContextUtil.closeRequstContext(requestContext);
+                getDeviceContext().unhookRequestCtx(requestContext.getXid());
+                settableFuture.set(rpcResultBuilder.build());
+            }
+        });
+        return settableFuture;
     }
 }
index bbea73379c9ab8014f1f185a6353d34987813bbd..f5d8ac0644a7525b4176ce2d45e3c0288043b8bf 100644 (file)
@@ -8,21 +8,28 @@
 package org.opendaylight.openflowplugin.impl.services;
 
 import com.google.common.base.Function;
-import com.google.common.util.concurrent.JdkFutureAdapters;
+import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.Future;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
+import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 
 public class SalPortServiceImpl extends CommonService implements SalPortService {
@@ -34,19 +41,40 @@ public class SalPortServiceImpl extends CommonService implements SalPortService
 
     @Override
     public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
-        return this.<UpdatePortOutput, Void> handleServiceCall(new Function<DataCrate<UpdatePortOutput>, ListenableFuture<RpcResult<Void>>>() {
+        return this.<UpdatePortOutput, Void>handleServiceCall(new Function<RequestContext<UpdatePortOutput>, ListenableFuture<RpcResult<Void>>>() {
+            @Override
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<UpdatePortOutput> requestContext) {
+                getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+
+                final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
+                final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, getVersion());
+                final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
+                final Xid xid = requestContext.getXid();
+                final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
+
+                mdInput.setXid(xid.getValue());
+                final SettableFuture<RpcResult<Void>> settableFuture = SettableFuture.create();
+                outboundQueue.commitEntry(xid.getValue(), mdInput.build(), new FutureCallback<OfHeader>() {
+                    @Override
+                    public void onSuccess(final OfHeader ofHeader) {
+                        RequestContextUtil.closeRequstContext(requestContext);
+                        getDeviceContext().unhookRequestCtx(requestContext.getXid());
+                        getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+
+                        settableFuture.set(RpcResultBuilder.<Void>success().build());
+                    }
+
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<UpdatePortOutput> data) {
-                        getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
-                        final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
-                        final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, getVersion());
-                        final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
-                        final Xid xid = data.getRequestContext().getXid();
-                        mdInput.setXid(xid.getValue());
-                        return JdkFutureAdapters.listenInPoolThread(provideConnectionAdapter(data.getiDConnection()).portMod(mdInput.build()));
+                    public void onFailure(final Throwable throwable) {
+                        RpcResultBuilder rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
+                        RequestContextUtil.closeRequstContext(requestContext);
+                        getDeviceContext().unhookRequestCtx(requestContext.getXid());
+                        settableFuture.set(rpcResultBuilder.build());
                     }
                 });
+                return settableFuture;
+            }
+        });
     }
 
 }
index 055005ccf77bae381d7718be36d12b7bbad38ea6..ea7ae91ee8e53a55a36de7680498bef427671436 100644 (file)
@@ -18,9 +18,12 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
@@ -34,8 +37,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;
@@ -49,6 +54,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -65,10 +71,10 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
     @Override
     public Future<RpcResult<UpdateTableOutput>> updateTable(final UpdateTableInput input) {
         class FunctionImpl implements
-                Function<DataCrate<List<MultipartReply>>, ListenableFuture<RpcResult<List<MultipartReply>>>> {
+                Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<Void>>> {
 
             @Override
-            public ListenableFuture<RpcResult<List<MultipartReply>>> apply(final DataCrate<List<MultipartReply>> data) {
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<List<MultipartReply>> requestContext) {
                 getMessageSpy().spyMessage(input.getImplementedInterface(),
                         MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
 
@@ -82,18 +88,43 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
                 caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
 
                 // Set request body to main multipart request
-                final Xid xid = data.getRequestContext().getXid();
+                final Xid xid = requestContext.getXid();
                 getDeviceContext().getMultiMsgCollector().registerMultipartXid(xid.getValue());
                 final MultipartRequestInputBuilder mprInput = createMultipartHeader(MultipartType.OFPMPTABLEFEATURES,
                         xid.getValue());
                 mprInput.setMultipartRequestBody(caseBuilder.build());
+                final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
+
+                final SettableFuture<RpcResult<Void>> settableFuture = SettableFuture.create();
+                final MultiMsgCollector multiMsgCollector = getDeviceContext().getMultiMsgCollector();
+                multiMsgCollector.registerMultipartXid(xid.getValue());
+
+                outboundQueue.commitEntry(xid.getValue(), mprInput.build(), new FutureCallback<OfHeader>() {
+                    @Override
+                    public void onSuccess(final OfHeader ofHeader) {
+                        if (ofHeader instanceof MultipartReply) {
+                            MultipartReply multipartReply = (MultipartReply) ofHeader;
+                            multiMsgCollector.addMultipartMsg(multipartReply);
+                        } else {
+                            if (null != ofHeader) {
+                                LOG.info("Unexpected response type received {}.", ofHeader.getClass());
+                            } else {
+                                LOG.info("Response received is null.");
+                            }
+                        }
+                        getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+                        settableFuture.set(RpcResultBuilder.<Void>success().build());
+                    }
 
-                final Future<RpcResult<Void>> resultFromOFLib = getPrimaryConnectionAdapter()
-                        .multipartRequest(mprInput.build());
-                final ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters
-                        .listenInPoolThread(resultFromOFLib);
-
-                return result;
+                    @Override
+                    public void onFailure(final Throwable throwable) {
+                        RpcResultBuilder rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
+                        RequestContextUtil.closeRequstContext(requestContext);
+                        getDeviceContext().unhookRequestCtx(requestContext.getXid());
+                        settableFuture.set(rpcResultBuilder.build());
+                    }
+                });
+                return settableFuture;
             }
         }
 
index 3a517306c9bad8a9de8169600b453beebba5a7a5..dfaaaa39eef2f0a12a9e081dd2f650e592942c6d 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.DataCrate;
 import org.opendaylight.openflowplugin.impl.services.OFJResult2RequestCtxFuture;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
@@ -73,10 +72,10 @@ public class OpendaylightFlowStatisticsServiceImpl extends CommonService impleme
 
 
         return this.<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> requestContext) {
 
                         // Create multipart request body for fetch all the group stats
                         final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
@@ -92,7 +91,7 @@ public class OpendaylightFlowStatisticsServiceImpl extends CommonService impleme
                         // Set request body to main multipart request
                         multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
                                 .build());
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                                 MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
 
@@ -113,11 +112,11 @@ public class OpendaylightFlowStatisticsServiceImpl extends CommonService impleme
 
 
         ListenableFuture<RpcResult<List<MultipartReply>>> rpcResultListenableFuture = handleServiceCall(
-                new Function<DataCrate<List<MultipartReply>>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
-                        final Xid xid = data.getRequestContext().getXid();
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<List<MultipartReply>> requestContext) {
+                        final Xid xid = requestContext.getXid();
                         final DeviceContext deviceContext = getDeviceContext();
                         deviceContext.getMultiMsgCollector().registerMultipartXid(xid.getValue());
                         final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
@@ -211,34 +210,34 @@ public class OpendaylightFlowStatisticsServiceImpl extends CommonService impleme
     public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
             final GetAllFlowStatisticsFromFlowTableInput input) {
 
-        return this.<GetAllFlowStatisticsFromFlowTableOutput, Void>handleServiceCall(new Function<DataCrate<GetAllFlowStatisticsFromFlowTableOutput>, ListenableFuture<RpcResult<Void>>>() {
+        return this.<GetAllFlowStatisticsFromFlowTableOutput, Void>handleServiceCall(new Function<RequestContext<GetAllFlowStatisticsFromFlowTableOutput>, ListenableFuture<RpcResult<Void>>>() {
 
-                    @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAllFlowStatisticsFromFlowTableOutput> data) {
+            @Override
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAllFlowStatisticsFromFlowTableOutput> requestContext) {
 
-                        final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
-                        mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
-                        mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
-                        mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
-                        mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                        mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+                final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+                mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
+                mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+                mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+                mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+                mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
 
-                        final short version = getVersion();
-                        FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
+                final short version = getVersion();
+                FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
 
-                        final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
-                        multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+                final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+                multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
 
-                        final Xid xid = data.getRequestContext().getXid();
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPFLOW, xid.getValue(), version);
+                final Xid xid = requestContext.getXid();
+                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                        MultipartType.OFPMPFLOW, xid.getValue(), version);
 
-                        mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
-                        final Future<RpcResult<Void>> resultFromOFLib = getDeviceContext().getPrimaryConnectionContext()
-                                .getConnectionAdapter().multipartRequest(mprInput.build());
-                        return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-                    }
-                });
+                mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+                final Future<RpcResult<Void>> resultFromOFLib = getDeviceContext().getPrimaryConnectionContext()
+                        .getConnectionAdapter().multipartRequest(mprInput.build());
+                return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+            }
+        });
     }
 
     @Override
@@ -246,32 +245,32 @@ public class OpendaylightFlowStatisticsServiceImpl extends CommonService impleme
             final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
 
 
-        return this.<GetAllFlowsStatisticsFromAllFlowTablesOutput, Void>handleServiceCall(new Function<DataCrate<GetAllFlowsStatisticsFromAllFlowTablesOutput>, ListenableFuture<RpcResult<Void>>>() {
-
-                    @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAllFlowsStatisticsFromAllFlowTablesOutput> data) {
-
-                        final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
-                        final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
-                        mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
-                        mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
-                        mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
-                        mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                        mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-                        final short version = getVersion();
-                        FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
-
-                        final Xid xid = data.getRequestContext().getXid();
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPFLOW, xid.getValue(), version);
+        return this.<GetAllFlowsStatisticsFromAllFlowTablesOutput, Void>handleServiceCall(new Function<RequestContext<GetAllFlowsStatisticsFromAllFlowTablesOutput>, ListenableFuture<RpcResult<Void>>>() {
 
-                        multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
-                        mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
-                        final Future<RpcResult<Void>> resultFromOFLib = getDeviceContext().getPrimaryConnectionContext()
-                                .getConnectionAdapter().multipartRequest(mprInput.build());
-                        return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-                    }
-                });
+            @Override
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAllFlowsStatisticsFromAllFlowTablesOutput> requestContext) {
+
+                final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+                final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+                mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
+                mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+                mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+                mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+                mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+                final short version = getVersion();
+                FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
+
+                final Xid xid = requestContext.getXid();
+                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                        MultipartType.OFPMPFLOW, xid.getValue(), version);
+
+                multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+                mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+                final Future<RpcResult<Void>> resultFromOFLib = getDeviceContext().getPrimaryConnectionContext()
+                        .getConnectionAdapter().multipartRequest(mprInput.build());
+                return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+            }
+        });
     }
 
     @Override
@@ -279,56 +278,56 @@ public class OpendaylightFlowStatisticsServiceImpl extends CommonService impleme
             final GetFlowStatisticsFromFlowTableInput input) {
 
 
-        return this.<GetFlowStatisticsFromFlowTableOutput, Void>handleServiceCall(new Function<DataCrate<GetFlowStatisticsFromFlowTableOutput>, ListenableFuture<RpcResult<Void>>>() {
+        return this.<GetFlowStatisticsFromFlowTableOutput, Void>handleServiceCall(new Function<RequestContext<GetFlowStatisticsFromFlowTableOutput>, ListenableFuture<RpcResult<Void>>>() {
 
-                    @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetFlowStatisticsFromFlowTableOutput> data) {
-
-                        final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
-                        final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
-                        mprFlowRequestBuilder.setTableId(input.getTableId());
+            @Override
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetFlowStatisticsFromFlowTableOutput> requestContext) {
 
-                        if (input.getOutPort() != null) {
-                            mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
-                        } else {
-                            mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
-                        }
+                final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+                final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+                mprFlowRequestBuilder.setTableId(input.getTableId());
 
-                        if (input.getOutGroup() != null) {
-                            mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
-                        } else {
-                            mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
-                        }
+                if (input.getOutPort() != null) {
+                    mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
+                } else {
+                    mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+                }
 
-                        if (input.getCookie() != null) {
-                            mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
-                        } else {
-                            mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
-                        }
+                if (input.getOutGroup() != null) {
+                    mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
+                } else {
+                    mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+                }
 
-                        if (input.getCookieMask() != null) {
-                            mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
-                        } else {
-                            mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-                        }
+                if (input.getCookie() != null) {
+                    mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
+                } else {
+                    mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+                }
 
-                        // convert and inject match
-                        final short version = getVersion();
-                        final DeviceContext deviceContext = getDeviceContext();
-                        MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
-                                deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
+                if (input.getCookieMask() != null) {
+                    mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
+                } else {
+                    mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+                }
 
-                        // Set request body to main multipart request
-                        final Xid xid = data.getRequestContext().getXid();
-                        multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPFLOW, xid.getValue(), version);
-                        mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
-                        final Future<RpcResult<Void>> resultFromOFLib = deviceContext.getPrimaryConnectionContext()
-                                .getConnectionAdapter().multipartRequest(mprInput.build());
-                        return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-                    }
-                });
+                // convert and inject match
+                final short version = getVersion();
+                final DeviceContext deviceContext = getDeviceContext();
+                MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
+                        deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
+
+                // Set request body to main multipart request
+                final Xid xid = requestContext.getXid();
+                multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                        MultipartType.OFPMPFLOW, xid.getValue(), version);
+                mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+                final Future<RpcResult<Void>> resultFromOFLib = deviceContext.getPrimaryConnectionContext()
+                        .getConnectionAdapter().multipartRequest(mprInput.build());
+                return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+            }
+        });
     }
 
     private <T> void convertRpcResultToRequestFuture(final RequestContext<T> requestContext,
index 4ab9576687f15355845c84b610fc4554ee8014f1..31af26932391276794f1a85c5488e40eed3026a6 100644 (file)
@@ -12,10 +12,10 @@ import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.DataCrate;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
@@ -41,29 +41,29 @@ public class OpendaylightFlowTableStatisticsServiceImpl extends CommonService im
             final GetFlowTablesStatisticsInput input) {
 
 
-        return this.<GetFlowTablesStatisticsOutput, Void>handleServiceCall(new Function<DataCrate<GetFlowTablesStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
+        return this.<GetFlowTablesStatisticsOutput, Void>handleServiceCall(new Function<RequestContext<GetFlowTablesStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
 
-                    @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetFlowTablesStatisticsOutput> data) {
+            @Override
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetFlowTablesStatisticsOutput> requestContext) {
 
-                        // Create multipart request body for fetch all the group stats
-                        final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
-                        final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
-                        multipartRequestTableBuilder.setEmpty(true);
-                        multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
+                // Create multipart request body for fetch all the group stats
+                final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
+                final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
+                multipartRequestTableBuilder.setEmpty(true);
+                multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
 
-                        // Set request body to main multipart request
-                        final Xid xid = data.getRequestContext().getXid();
-                        final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
-                                MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
+                // Set request body to main multipart request
+                final Xid xid = requestContext.getXid();
+                final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+                        MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
 
-                        mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
-                        final Future<RpcResult<Void>> resultFromOFLib = getDeviceContext().getPrimaryConnectionContext()
-                                .getConnectionAdapter().multipartRequest(mprInput.build());
+                mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
+                final Future<RpcResult<Void>> resultFromOFLib = getDeviceContext().getPrimaryConnectionContext()
+                        .getConnectionAdapter().multipartRequest(mprInput.build());
 
-                        return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-                    }
-                });
+                return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+            }
+        });
     }
 
 }
index b5e2719f43e56756e28d64871ebb71dd07b7ef2d..da7f167442eb1f1b7df390aabf0d38b4c25f924e 100644 (file)
@@ -13,10 +13,10 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.DataCrate;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
@@ -50,10 +50,10 @@ public class OpendaylightGroupStatisticsServiceImpl extends CommonService implem
     public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
 
 
-        return this.<GetAllGroupStatisticsOutput, Void>handleServiceCall(new Function<DataCrate<GetAllGroupStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
+        return this.<GetAllGroupStatisticsOutput, Void>handleServiceCall(new Function<RequestContext<GetAllGroupStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
 
             @Override
-            public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAllGroupStatisticsOutput> data) {
+            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAllGroupStatisticsOutput> requestContext) {
 
                 final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
                 final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
@@ -64,7 +64,7 @@ public class OpendaylightGroupStatisticsServiceImpl extends CommonService implem
                 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
 
                 // Create multipart request header
-                final Xid xid = data.getRequestContext().getXid();
+                final Xid xid = requestContext.getXid();
                 final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                         MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
 
@@ -84,13 +84,13 @@ public class OpendaylightGroupStatisticsServiceImpl extends CommonService implem
     @Override
     public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
         return this.<GetGroupDescriptionOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetGroupDescriptionOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetGroupDescriptionOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetGroupDescriptionOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetGroupDescriptionOutput> requestContext) {
                         final MultipartRequestGroupDescCaseBuilder mprGroupDescCaseBuild = new MultipartRequestGroupDescCaseBuilder();
 
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                                 MultipartType.OFPMPGROUPDESC, xid.getValue(), getVersion());
                         mprInput.setMultipartRequestBody(mprGroupDescCaseBuild.build());
@@ -105,13 +105,13 @@ public class OpendaylightGroupStatisticsServiceImpl extends CommonService implem
     @Override
     public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
         return this.<GetGroupFeaturesOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetGroupFeaturesOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetGroupFeaturesOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetGroupFeaturesOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetGroupFeaturesOutput> requestContext) {
                         final MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild = new MultipartRequestGroupFeaturesCaseBuilder();
 
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                                 MultipartType.OFPMPGROUPFEATURES, xid.getValue(), getVersion());
                         mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
@@ -126,17 +126,17 @@ public class OpendaylightGroupStatisticsServiceImpl extends CommonService implem
     @Override
     public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
         return this.<GetGroupStatisticsOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetGroupStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetGroupStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetGroupStatisticsOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetGroupStatisticsOutput> requestContext) {
 
                         final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
                         final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
                         mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
                         caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
 
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                                 MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
 
index 21aa86823f2621ebaf3a0c870b68137b831db417..38585565747715092664857f911d20cc49eabd50 100644 (file)
@@ -13,10 +13,10 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.DataCrate;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
@@ -51,10 +51,10 @@ public class OpendaylightMeterStatisticsServiceImpl extends CommonService implem
     public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
             final GetAllMeterConfigStatisticsInput input) {
         return this
-                .<GetAllMeterConfigStatisticsOutput, Void>handleServiceCall(new Function<DataCrate<GetAllMeterConfigStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
+                .<GetAllMeterConfigStatisticsOutput, Void>handleServiceCall(new Function<RequestContext<GetAllMeterConfigStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAllMeterConfigStatisticsOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAllMeterConfigStatisticsOutput> requestContext) {
 
                         MultipartRequestMeterConfigCaseBuilder caseBuilder =
                                 new MultipartRequestMeterConfigCaseBuilder();
@@ -65,7 +65,7 @@ public class OpendaylightMeterStatisticsServiceImpl extends CommonService implem
                                         .types.rev130731.Meter.OFPMALL.getIntValue())));
                         caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
 
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         MultipartRequestInputBuilder mprInput = RequestInputUtils
                                 .createMultipartHeader(MultipartType.OFPMPMETERCONFIG, xid.getValue(), getVersion());
                         mprInput.setMultipartRequestBody(caseBuilder.build());
@@ -82,9 +82,9 @@ public class OpendaylightMeterStatisticsServiceImpl extends CommonService implem
     public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(final GetAllMeterStatisticsInput input) {
 
         return this.<GetAllMeterStatisticsOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetAllMeterStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetAllMeterStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAllMeterStatisticsOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAllMeterStatisticsOutput> requestContext) {
 
                         MultipartRequestMeterCaseBuilder caseBuilder =
                                 new MultipartRequestMeterCaseBuilder();
@@ -95,7 +95,7 @@ public class OpendaylightMeterStatisticsServiceImpl extends CommonService implem
                                         .types.rev130731.Meter.OFPMALL.getIntValue())));
                         caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
 
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         MultipartRequestInputBuilder mprInput = RequestInputUtils
                                 .createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
                         mprInput.setMultipartRequestBody(caseBuilder.build());
@@ -112,14 +112,14 @@ public class OpendaylightMeterStatisticsServiceImpl extends CommonService implem
     @Override
     public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(final GetMeterFeaturesInput input) {
         return this.<GetMeterFeaturesOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetMeterFeaturesOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetMeterFeaturesOutput>, ListenableFuture<RpcResult<Void>>>() {
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetMeterFeaturesOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetMeterFeaturesOutput> requestContext) {
 
                         MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild =
                                 new MultipartRequestMeterFeaturesCaseBuilder();
 
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         MultipartRequestInputBuilder mprInput =
                                 RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETERFEATURES, xid.getValue(), getVersion());
                         mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
@@ -132,9 +132,9 @@ public class OpendaylightMeterStatisticsServiceImpl extends CommonService implem
     @Override
     public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(final GetMeterStatisticsInput input) {
         return this.<GetMeterStatisticsOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetMeterStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetMeterStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetMeterStatisticsOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetMeterStatisticsOutput> requestContext) {
                         MultipartRequestMeterCaseBuilder caseBuilder =
                                 new MultipartRequestMeterCaseBuilder();
                         MultipartRequestMeterBuilder mprMeterBuild =
@@ -142,7 +142,7 @@ public class OpendaylightMeterStatisticsServiceImpl extends CommonService implem
                         mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
                         caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
 
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         MultipartRequestInputBuilder mprInput =
                                 RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
                         mprInput.setMultipartRequestBody(caseBuilder.build());
index f31c47557b4e94b7329c857be4cef4a9c78cf012..b3b41f58676f1487edf799b8303b7f426f92858d 100644 (file)
@@ -13,11 +13,11 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.DataCrate;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
@@ -45,10 +45,10 @@ public class OpendaylightPortStatisticsServiceImpl extends CommonService impleme
             final GetAllNodeConnectorsStatisticsInput input) {
         return this
                 .<GetAllNodeConnectorsStatisticsOutput, Void>handleServiceCall(
-                        new Function<DataCrate<GetAllNodeConnectorsStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
+                        new Function<RequestContext<GetAllNodeConnectorsStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                             @Override
-                            public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAllNodeConnectorsStatisticsOutput> data) {
+                            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAllNodeConnectorsStatisticsOutput> requestContext) {
 
                                 MultipartRequestPortStatsCaseBuilder caseBuilder =
                                         new MultipartRequestPortStatsCaseBuilder();
@@ -58,7 +58,7 @@ public class OpendaylightPortStatisticsServiceImpl extends CommonService impleme
                                 mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
                                 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
 
-                                final Xid xid = data.getRequestContext().getXid();
+                                final Xid xid = requestContext.getXid();
                                 MultipartRequestInputBuilder mprInput = RequestInputUtils
                                         .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), getVersion());
                                 mprInput.setMultipartRequestBody(caseBuilder.build());
@@ -74,10 +74,10 @@ public class OpendaylightPortStatisticsServiceImpl extends CommonService impleme
             final GetNodeConnectorStatisticsInput input) {
         return this
                 .<GetNodeConnectorStatisticsOutput, Void>handleServiceCall(
-                        new Function<DataCrate<GetNodeConnectorStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
+                        new Function<RequestContext<GetNodeConnectorStatisticsOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                             @Override
-                            public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetNodeConnectorStatisticsOutput> data) {
+                            public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetNodeConnectorStatisticsOutput> requestContext) {
 
                                 MultipartRequestPortStatsCaseBuilder caseBuilder =
                                         new MultipartRequestPortStatsCaseBuilder();
@@ -91,7 +91,7 @@ public class OpendaylightPortStatisticsServiceImpl extends CommonService impleme
                                                 input.getNodeConnectorId()));
                                 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
 
-                                final Xid xid = data.getRequestContext().getXid();
+                                final Xid xid = requestContext.getXid();
                                 MultipartRequestInputBuilder mprInput = RequestInputUtils
                                         .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), version);
                                 mprInput.setMultipartRequestBody(caseBuilder.build());
index cade836f1989e49475374fda5ccf48c3b4b0f41f..9ea587cf32413006d1a31ee1305597afbb76fe89 100644 (file)
@@ -13,11 +13,11 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.DataCrate;
 import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
@@ -46,10 +46,10 @@ public class OpendaylightQueueStatisticsServiceImpl extends CommonService implem
     public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
             final GetAllQueuesStatisticsFromAllPortsInput input) {
         return this.<GetAllQueuesStatisticsFromAllPortsOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetAllQueuesStatisticsFromAllPortsOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetAllQueuesStatisticsFromAllPortsOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAllQueuesStatisticsFromAllPortsOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAllQueuesStatisticsFromAllPortsOutput> requestContext) {
 
 
                         MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
@@ -61,7 +61,7 @@ public class OpendaylightQueueStatisticsServiceImpl extends CommonService implem
                         caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
 
                         // Set request body to main multipart request
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                                 MultipartType.OFPMPQUEUE, xid.getValue(), getVersion());
                         mprInput.setMultipartRequestBody(caseBuilder.build());
@@ -77,10 +77,10 @@ public class OpendaylightQueueStatisticsServiceImpl extends CommonService implem
     public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
             final GetAllQueuesStatisticsFromGivenPortInput input) {
         return this.<GetAllQueuesStatisticsFromGivenPortOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetAllQueuesStatisticsFromGivenPortOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetAllQueuesStatisticsFromGivenPortOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetAllQueuesStatisticsFromGivenPortOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetAllQueuesStatisticsFromGivenPortOutput> requestContext) {
 
                         MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
                         MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
@@ -93,7 +93,7 @@ public class OpendaylightQueueStatisticsServiceImpl extends CommonService implem
                         caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
 
                         // Set request body to main multipart request
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                                 MultipartType.OFPMPQUEUE, xid.getValue(), version);
                         mprInput.setMultipartRequestBody(caseBuilder.build());
@@ -109,10 +109,10 @@ public class OpendaylightQueueStatisticsServiceImpl extends CommonService implem
     public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
             final GetQueueStatisticsFromGivenPortInput input) {
         return this.<GetQueueStatisticsFromGivenPortOutput, Void>handleServiceCall(
-                new Function<DataCrate<GetQueueStatisticsFromGivenPortOutput>, ListenableFuture<RpcResult<Void>>>() {
+                new Function<RequestContext<GetQueueStatisticsFromGivenPortOutput>, ListenableFuture<RpcResult<Void>>>() {
 
                     @Override
-                    public ListenableFuture<RpcResult<Void>> apply(final DataCrate<GetQueueStatisticsFromGivenPortOutput> data) {
+                    public ListenableFuture<RpcResult<Void>> apply(final RequestContext<GetQueueStatisticsFromGivenPortOutput> requestContext) {
 
                         MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
                         MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
@@ -125,7 +125,7 @@ public class OpendaylightQueueStatisticsServiceImpl extends CommonService implem
                         caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
 
                         // Set request body to main multipart request
-                        final Xid xid = data.getRequestContext().getXid();
+                        final Xid xid = requestContext.getXid();
                         MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
                                 MultipartType.OFPMPQUEUE, xid.getValue(), version);
                         mprInput.setMultipartRequestBody(caseBuilder.build());
index da26413667a138f675621c4dc4d47a616be4fe29..720a2dddb76f6d065e5a19dd835b3380ff6d0532 100644 (file)
@@ -16,12 +16,12 @@ import java.util.List;
 import java.util.concurrent.Future;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
 import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.DataCrate;
 import org.opendaylight.openflowplugin.impl.services.RequestContextUtil;
 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;
@@ -47,10 +47,10 @@ public class StatisticsGatheringService extends CommonService {
 
 
     public Future<RpcResult<List<MultipartReply>>> getStatisticsOfType(final MultipartType type) {
-        return handleServiceCall(new Function<DataCrate<List<MultipartReply>>, ListenableFuture<RpcResult<Void>>>() {
+        return handleServiceCall(new Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<Void>>>() {
                                      @Override
-                                     public ListenableFuture<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
-                                         final Xid xid = data.getRequestContext().getXid();
+                                     public ListenableFuture<RpcResult<Void>> apply(final RequestContext<List<MultipartReply>> requestContext) {
+                                         final Xid xid = requestContext.getXid();
                                          final DeviceContext deviceContext = getDeviceContext();
                                          final MultiMsgCollector multiMsgCollector = deviceContext.getMultiMsgCollector();
 
@@ -80,8 +80,8 @@ public class StatisticsGatheringService extends CommonService {
                                              @Override
                                              public void onFailure(final Throwable throwable) {
                                                  RpcResultBuilder rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage());
-                                                 getDeviceContext().unhookRequestCtx(data.getRequestContext().getXid());
-                                                 RequestContextUtil.closeRequstContext(data.getRequestContext());
+                                                 getDeviceContext().unhookRequestCtx(requestContext.getXid());
+                                                 RequestContextUtil.closeRequstContext(requestContext);
 
                                                  settableFuture.set(rpcResultBuilder.build());
                                              }