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:com.facebook.buck.parser.BuildTargetRawNodeParsePipeline.java
@Override public ListenableFuture<Map<String, Object>> getNodeJob(Cell cell, UnconfiguredBuildTarget buildTarget) throws BuildTargetException { return Futures.transformAsync( buildFileRawNodeParsePipeline.getAllNodesJob(cell, cell.getAbsolutePathToBuildFile(buildTarget)), input -> {/* w ww . j a va 2 s . c o m*/ if (!input.getTargets().containsKey(buildTarget.getShortName())) { throw NoSuchBuildTargetException.createForMissingBuildRule(buildTarget, cell.getAbsolutePathToBuildFile(buildTarget)); } return Futures.immediateFuture(input.getTargets().get(buildTarget.getShortName())); }, executorService); }
From source file:org.opendaylight.controller.clustering.it.provider.BasicRpcTestProvider.java
@Override public ListenableFuture<Void> closeServiceInstance() { rpcRegistration.close(); rpcRegistration = null; return Futures.immediateFuture(null); }
From source file:io.crate.executor.transport.task.AsyncChainedTask.java
protected AsyncChainedTask() { result = SettableFuture.create();/*from ww w .j av a 2 s . c om*/ ListenableFuture<TaskResult> resultFallback = Futures.withFallback(result, new FutureFallback<TaskResult>() { @Override public ListenableFuture<TaskResult> create(@Nonnull Throwable t) throws Exception { return Futures.immediateFuture((TaskResult) RowCountResult.error(t)); } }); resultList = new ArrayList<>(); resultList.add(resultFallback); }
From source file:com.google.api.server.spi.config.datastore.testing.FakeAsyncMemcacheService.java
@Override public Future<Void> clearAll() { memcacheService.clearAll(); return Futures.immediateFuture(null); }
From source file:org.esbtools.eventhandler.lightblue.testing.StringNotification.java
@Override public Future<Collection<DocumentEvent>> toDocumentEvents() { return Futures .immediateFuture(Collections.singleton(new StringDocumentEvent(entity.get_id(), value, clock))); }
From source file:org.opendaylight.openflowplugin.applications.frsync.impl.SyncReactorGuardDecorator.java
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath, final SyncupEntry syncupEntry) throws InterruptedException { final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath); LOG.trace("syncup guard decorator: {}", nodeId.getValue()); final long stampBeforeGuard = System.nanoTime(); final Semaphore guard = summonGuardAndAcquire(flowcapableNodePath); if (guard == null) { return Futures.immediateFuture(false); }//from w ww. j a v a2s . co m final long stampAfterGuard = System.nanoTime(); try { if (LOG.isDebugEnabled()) { LOG.debug("syncup start {} waiting:{} guard:{} thread:{}", nodeId.getValue(), formatNanos(stampAfterGuard - stampBeforeGuard), guard, threadName()); } final ListenableFuture<Boolean> endResult = delegate.syncup(flowcapableNodePath, syncupEntry); Futures.addCallback(endResult, createSyncupCallback(guard, stampBeforeGuard, stampAfterGuard, nodeId)); return endResult; } catch (InterruptedException e) { releaseGuardForNodeId(guard); throw e; } }
From source file:com.facebook.buck.util.concurrent.ListeningSemaphore.java
public synchronized ListenableFuture<Void> acquire(int permits) { // If the semaphore isn't full, acquire it now. Since an immediate future cannot be canceled, // there's no extra handling we have to do here. if (canFit(permits)) { size += permits;/*from w ww.ja va 2 s . co m*/ return Futures.immediateFuture(null); } // Otherwise, queue it up for later. SettableFuture<Void> future = SettableFuture.create(); pending.add(new AbstractMap.SimpleEntry<>(permits, future)); return future; }
From source file:com.facebook.buck.rules.InputRule.java
/** * It is imperative that {@code inputFile} be properly relativized, so use * {@link #inputPathAsInputRule(String, Function)} to create an {@link InputRule}. The only reason * this method is {@code protected} rather than {@code private} is so that fakes can be created * for testing.//from w w w . j a va 2s .co m */ @VisibleForTesting protected InputRule(File inputFile, String relativePath) { this.inputFile = Preconditions.checkNotNull(inputFile); this.buildTarget = BuildTarget.createBuildTargetForInputFile(inputFile, relativePath); this.buildOutput = Futures.immediateFuture(new BuildRuleSuccess(this, SUCCESS_TYPE)); }
From source file:com.tc.services.EntityClientCommunicatorService.java
@Override public Future<Void> send(ClientDescriptor clientDescriptor, byte[] payload) { // We are in internal code so downcast the descriptor. ClientDescriptorImpl rawDescriptor = (ClientDescriptorImpl) clientDescriptor; ClientAccount clientAccount = clientAccounts.get(rawDescriptor.getNodeID()); if (clientAccount != null) { EntityDescriptor entityDescriptor = rawDescriptor.getEntityDescriptor(); return clientAccount.send(entityDescriptor, payload); } else {//from w w w. ja v a 2s . c om return Futures.immediateFuture(null); } }
From source file:org.thingsboard.rule.engine.metadata.TbGetAttributesNode.java
@Override protected ListenableFuture<EntityId> findEntityIdAsync(TbContext ctx, EntityId originator) { return Futures.immediateFuture(originator); }