List of usage examples for com.google.common.util.concurrent Futures immediateFuture
@CheckReturnValue public static <V> ListenableFuture<V> immediateFuture(@Nullable V value)
From source file:org.opendaylight.openflowplugin.applications.frsync.impl.SyncReactorClusterDecorator.java
@Override public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath, final SyncupEntry syncupEntry) throws InterruptedException { final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath); LOG.trace("Syncup cluster decorator: {}", nodeId.getValue()); if (!deviceMastershipManager.isDeviceMastered(nodeId)) { LOG.debug("Skip syncup since not master for: {}", nodeId.getValue()); return Futures.immediateFuture(Boolean.TRUE); } else {/*w w w. ja va2 s.c o m*/ return delegate.syncup(flowcapableNodePath, syncupEntry); } }
From source file:org.opendaylight.mdsal.dom.store.inmemory.ForeignShardThreePhaseCommitCohort.java
@Override public ListenableFuture<Void> abort() { LOG.debug("Aborting transaction of foreign shard {}", prefix); shard.closeForeignTransaction();//w ww . j av a 2 s . c o m return Futures.immediateFuture(null); }
From source file:rpcbenchmark.impl.GlobalBindingRTCServer.java
@Override public Future<RpcResult<RoutedRpcBenchOutput>> routedRpcBench(RoutedRpcBenchInput input) { RoutedRpcBenchOutput output = new RoutedRpcBenchOutputBuilder(input).build(); RpcResult<RoutedRpcBenchOutput> result = RpcResultBuilder.success(output).build(); numRpcs++;/* w ww . j a v a 2s.c om*/ return Futures.immediateFuture(result); }
From source file:com.google.gapid.util.FutureCache.java
public ListenableFuture<V> get(K key) { // Look up the value in the cache using the executor. ListenableFuture<V> cacheLookUp = EXECUTOR.submit(() -> cache.getIfPresent(key)); return Futures.transformAsync(cacheLookUp, fromCache -> { if (fromCache != null) { return Futures.immediateFuture(fromCache); }/*from w ww . j av a 2 s . co m*/ return Futures.transform(fetcher.apply(key), value -> { if (shouldCache.test(value)) { cache.put(key, value); } return value; }); }); }
From source file:io.joynr.messaging.NoBackendMessagingSenderReceiver.java
@Override public Future<Void> start(MessageArrivedListener messageArrivedListener, ReceiverStatusListener... statusListeners) { return Futures.immediateFuture(null); }
From source file:me.j360.trace.storage.elasticsearch.ElasticsearchSpanConsumer.java
@Override public ListenableFuture<Void> accept(List<Span> spans) { if (spans.isEmpty()) return Futures.immediateFuture(null); // Create a bulk request when there is more than one span to store ListenableFuture<?> future;/* w w w . j a va 2s. c o m*/ if (spans.size() == 1) { future = toGuava(createSpanIndexRequest(spans.get(0)).execute()); } else { BulkRequestBuilder request = client.prepareBulk(); for (Span span : spans) { request.add(createSpanIndexRequest(span)); } future = toGuava(request.execute()); } if (ElasticsearchStorage.FLUSH_ON_WRITES) { future = transform(future, new AsyncFunction() { @Override public ListenableFuture apply(Object input) { return toGuava(client.admin().indices().prepareFlush(indexNameFormatter.catchAll()).execute()); } }); } return transform(future, TO_VOID); }
From source file:producerstest.multibindings.MultibindingProducerModule.java
@Produces @IntoMap @PossiblyThrowingMap @IntKey(42) static ListenableFuture<String> successfulFutureFor42() { return Futures.immediateFuture("forty two"); }
From source file:org.opendaylight.openflowplugin.applications.frsync.impl.SyncReactorRetryDecorator.java
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath, final SyncupEntry syncupEntry) throws InterruptedException { final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath); LOG.trace("syncup retry decorator: {}", nodeId.getValue()); if (syncupEntry.isOptimizedConfigDelta() && reconciliationRegistry.isRegistered(nodeId)) { LOG.debug("Config change ignored because {} is in reconcile.", nodeId.getValue()); return Futures.immediateFuture(Boolean.FALSE); }//from w w w. j av a 2 s. c om ListenableFuture<Boolean> syncupResult = delegate.syncup(flowcapableNodePath, syncupEntry); return Futures.transform(syncupResult, new Function<Boolean, Boolean>() { @Override public Boolean apply(Boolean result) { LOG.trace("syncup return in retry decorator: {} [{}]", nodeId.getValue(), result); if (result) { reconciliationRegistry.unregisterIfRegistered(nodeId); return true; } else { reconciliationRegistry.register(nodeId); return false; } } }); }
From source file:org.opendaylight.openflowplugin.applications.frsync.impl.clustering.DeviceMastership.java
@Override public ListenableFuture<Void> closeServiceInstance() { LOG.debug("FRS stopped for: {}", nodeId.getValue()); deviceMastered = false;// w ww.j a va2 s . com reconciliationRegistry.unregisterIfRegistered(nodeId); return Futures.immediateFuture(null); }
From source file:c5db.replication.SingleNodeFakeReplicator.java
@Override public ListenableFuture<QuorumConfiguration> getQuorumConfiguration() { return Futures.immediateFuture(QuorumConfiguration.of(Sets.newHashSet(nodeId))); }