use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput in project openflowplugin by opendaylight.
the class BarrierUtil method chainBarrier.
/**
* Chain a barrier message - regardless of previous result and use given {@link Function} to combine
* original result and barrier result.
*
* @param <T> type of input future
* @param input future to chain barrier to
* @param nodeRef target device
* @param transactionService barrier service
* @param compositeTransform composite transform
* @return future holding both results (input and of the barrier)
*/
public static <T> ListenableFuture<RpcResult<T>> chainBarrier(final ListenableFuture<RpcResult<T>> input, final NodeRef nodeRef, final FlowCapableTransactionService transactionService, final Function<Pair<RpcResult<T>, RpcResult<Void>>, RpcResult<T>> compositeTransform) {
final MutablePair<RpcResult<T>, RpcResult<Void>> resultPair = new MutablePair<>();
// store input result and append barrier
final ListenableFuture<RpcResult<Void>> barrierResult = Futures.transformAsync(input, interInput -> {
resultPair.setLeft(interInput);
final SendBarrierInput barrierInput = createSendBarrierInput(nodeRef);
return JdkFutureAdapters.listenInPoolThread(transactionService.sendBarrier(barrierInput));
}, MoreExecutors.directExecutor());
// store barrier result and return initiated pair
final ListenableFuture<Pair<RpcResult<T>, RpcResult<Void>>> compositeResult = Futures.transform(barrierResult, new Function<RpcResult<Void>, Pair<RpcResult<T>, RpcResult<Void>>>() {
@Nullable
@Override
public Pair<RpcResult<T>, RpcResult<Void>> apply(@Nullable final RpcResult<Void> input) {
resultPair.setRight(input);
return resultPair;
}
}, MoreExecutors.directExecutor());
// append assembling transform to barrier result
return Futures.transform(compositeResult, compositeTransform, MoreExecutors.directExecutor());
}
Aggregations