X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Futil%2FBarrierUtil.java;h=1c0250d5b256bb1496b83f0755893d2a407b3041;hb=a240c35de0fe5641ce68f1c614f485d88ff170cc;hp=209ff92c1bb7061b5b6ac401f14524ea4f2ed362;hpb=e1ef8b31e7f6c908e06d947bd10f51e498378ab5;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/BarrierUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/BarrierUtil.java index 209ff92c1b..1c0250d5b2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/BarrierUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/BarrierUtil.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowplugin.impl.util; import com.google.common.base.Function; -import com.google.common.util.concurrent.AsyncFunction; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.JdkFutureAdapters; import com.google.common.util.concurrent.ListenableFuture; @@ -21,16 +20,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304. import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** - * provides barrier message chaining and factory methods + * Provides barrier message chaining and factory methods. */ public final class BarrierUtil { - private static final Logger LOG = LoggerFactory.getLogger(BarrierUtil.class); - private BarrierUtil() { throw new IllegalStateException("This class should not be instantiated."); @@ -38,14 +33,14 @@ public final class BarrierUtil { /** - * chain a barrier message - regardless of previous result and use given {@link Function} to combine - * original result and barrier result + * Chain a barrier message - regardless of previous result and use given {@link Function} to combine + * original result and barrier result. * * @param type of input future * @param input future to chain barrier to * @param nodeRef target device * @param transactionService barrier service - * @param compositeTransform + * @param compositeTransform composite transform * @return future holding both results (input and of the barrier) */ public static ListenableFuture> chainBarrier( @@ -55,15 +50,12 @@ public final class BarrierUtil { final MutablePair, RpcResult> resultPair = new MutablePair<>(); // store input result and append barrier - final ListenableFuture> barrierResult = Futures.transform(input, - new AsyncFunction, RpcResult>() { - @Override - public ListenableFuture> apply(@Nullable final RpcResult interInput) throws Exception { - resultPair.setLeft(interInput); - final SendBarrierInput barrierInput = createSendBarrierInput(nodeRef); - return JdkFutureAdapters.listenInPoolThread(transactionService.sendBarrier(barrierInput)); - } - }); + final ListenableFuture> barrierResult = Futures.transformAsync(input, + interInput -> { + resultPair.setLeft(interInput); + final SendBarrierInput barrierInput = createSendBarrierInput(nodeRef); + return JdkFutureAdapters.listenInPoolThread(transactionService.sendBarrier(barrierInput)); + }); // store barrier result and return initiated pair final ListenableFuture, RpcResult>> compositeResult = Futures.transform( barrierResult, new Function, Pair, RpcResult>>() { @@ -79,6 +71,8 @@ public final class BarrierUtil { } /** + * Creates barrier input. + * * @param nodeRef rpc routing context * @return input for {@link FlowCapableTransactionService#sendBarrier(SendBarrierInput)} */