Example usage for com.google.common.util.concurrent Futures immediateFuture

List of usage examples for com.google.common.util.concurrent Futures immediateFuture

Introduction

In this page you can find the example usage for com.google.common.util.concurrent Futures immediateFuture.

Prototype

@CheckReturnValue
public static <V> ListenableFuture<V> immediateFuture(@Nullable V value) 

Source Link

Document

Creates a ListenableFuture which has its value set immediately upon construction.

Usage

From source file:me.grapebaba.hyperledger.fabric.ChronicleMapStore.java

@Override
public ListenableFuture<Member> getValue(String name) {
    return Futures.immediateFuture(store.get(name));
}

From source file:com.vmware.photon.controller.common.zookeeper.SimpleServiceNode.java

@Override
/**/*from   w w  w .  ja  v  a 2 s.  com*/
 * @return This is a simple one that allows anyone to join anytime
 */
protected ListenableFuture<Void> joinCondition() {
    return Futures.immediateFuture(null);
}

From source file:org.opendaylight.openflowplugin.applications.lldpspeaker.OperationalStatusChangeService.java

@Override
public Future<RpcResult<Void>> changeOperationalStatus(final ChangeOperationalStatusInput input) {
    speakerInstance.setOperationalStatus(input.getOperationalStatus());
    RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.success();
    return Futures.immediateFuture(rpcResultBuilder.build());
}

From source file:com.google.idea.blaze.base.vcs.FallbackBlazeVcsHandler.java

@Override
public ListenableFuture<WorkingSet> getWorkingSet(Project project, BlazeContext context,
        WorkspaceRoot workspaceRoot, ListeningExecutorService executor) {
    return Futures.immediateFuture(null);
}

From source file:com.google.wave.splash.rpc.WaveServiceAdapter.java

@Override
public ListenableFuture<Wavelet> fetchWavelet(WaveId waveId, WaveletId waveletId) {
    try {/*from w ww .jav  a2  s . c  o  m*/
        return Futures.immediateFuture(waveService.fetchWavelet(waveId, waveletId, rpcEndpoint));
    } catch (IOException e) {
        return Futures.immediateFailedFuture(e);
    }
}

From source file:rpcbenchmark.impl.GlobalBindingRTCServer.java

@Override
public Future<RpcResult<GlobalRpcBenchOutput>> globalRpcBench(GlobalRpcBenchInput input) {
    GlobalRpcBenchOutput output = new GlobalRpcBenchOutputBuilder(input).build();
    RpcResult<GlobalRpcBenchOutput> result = RpcResultBuilder.success(output).build();
    numRpcs++;//from w  w w .  j a  v a 2  s  .c o  m
    return Futures.immediateFuture(result);
}

From source file:io.v.impl.google.lib.discovery.DiscoveryImpl.java

@Override
public ListenableFuture<Void> advertise(VContext ctx, Advertisement ad, List<BlessingPattern> visibility)
        throws VException {
    ListenableFutureCallback<Void> cb = new ListenableFutureCallback<>();
    nativeAdvertise(nativeRef, ctx, ad, visibility, cb);
    return Futures.withFallback(cb.getFuture(ctx), new FutureFallback<Void>() {
        public ListenableFuture<Void> create(Throwable t) {
            if (t instanceof CancellationException) {
                return Futures.immediateFuture(null);
            }/*  w  ww. j a v a 2  s  .c o  m*/
            return Futures.immediateFailedFuture(t);
        }
    });
}

From source file:me.grapebaba.hyperledger.fabric.ChronicleMapStore.java

@Override
public ListenableFuture<Member> setValue(String name, Member value) {
    return Futures.immediateFuture(store.put(name, value));
}

From source file:co.cask.cdap.common.async.AsyncFunctions.java

/**
 * Converts a {@link Function} into {@link AsyncFunction} by performing the operation in the same thread.
 *
 * @param function Function to apply// w ww. j  av a  2 s.com
 * @param <I> Input type
 * @param <O> Output type
 * @return A {@link AsyncFunction} that will call the function in the same thread as the caller thread.
 */
public static <I, O> AsyncFunction<I, O> asyncWrap(final Function<I, O> function) {
    return new AsyncFunction<I, O>() {
        @Override
        public ListenableFuture<O> apply(I input) throws Exception {
            return Futures.immediateFuture(function.apply(input));
        }
    };
}

From source file:org.opendaylight.openflowplugin.applications.frm.impl.DeviceMastership.java

@Override
public ListenableFuture<Void> closeServiceInstance() {
    LOG.debug("FRM stopped for: {}", nodeId.getValue());
    deviceMastered = false;/*from  w w w. ja v a 2  s. c  o  m*/
    return Futures.immediateFuture(null);
}