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.netvirt.aclservice.stats.AclLiveStatisticsRpcServiceImpl.java
@Override public Future<RpcResult<GetAclPortStatisticsOutput>> getAclPortStatistics(GetAclPortStatisticsInput input) { LOG.trace("Get ACL port statistics for input: {}", input); RpcResultBuilder<GetAclPortStatisticsOutput> rpcResultBuilder; if (this.securityGroupMode != SecurityGroupMode.Stateful) { rpcResultBuilder = RpcResultBuilder.failed(); rpcResultBuilder.withError(ErrorType.APPLICATION, "operation-not-supported", "Operation not supported for ACL " + this.securityGroupMode + " mode"); return Futures.immediateFuture(rpcResultBuilder.build()); }// w w w . j a v a2 s .c o m // Default direction is Both Direction direction = (input.getDirection() == null ? Direction.Both : input.getDirection()); List<AclPortStats> lstAclInterfaceStats = AclLiveStatisticsHelper.getAclPortStats(direction, input.getInterfaceNames(), this.odlDirectStatsService, this.dataBroker); GetAclPortStatisticsOutputBuilder output = new GetAclPortStatisticsOutputBuilder() .setAclPortStats(lstAclInterfaceStats); rpcResultBuilder = RpcResultBuilder.success(); rpcResultBuilder.withResult(output.build()); return Futures.immediateFuture(rpcResultBuilder.build()); }
From source file:com.google.gapid.server.Client.java
public ListenableFuture<Value> get(Path.Any path) { LOG.log(FINE, "RPC->get({0})", path); return Futures.transformAsync(client.get(GetRequest.newBuilder().setPath(path).build()), in -> Futures.immediateFuture(throwIfError(in.getValue(), in.getError()))); }
From source file:org.opendaylight.tsdr.collector.spi.CollectorSPIImpl.java
@Override public Future<RpcResult<Void>> insertTSDRMetricRecord(InsertTSDRMetricRecordInput input) { StoreTSDRMetricRecordInputBuilder tsdrServiceInput = new StoreTSDRMetricRecordInputBuilder(); List<TSDRMetricRecord> records = new ArrayList<TSDRMetricRecord>(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.tsdr.collector.spi.rev150915.inserttsdrmetricrecord.input.TSDRMetricRecord inputRec : input .getTSDRMetricRecord()) {/*from w ww . j a v a 2 s. c om*/ TSDRMetricRecordBuilder rec = new TSDRMetricRecordBuilder(); rec.setMetricName(inputRec.getMetricName()); rec.setMetricValue(inputRec.getMetricValue()); rec.setNodeID(inputRec.getNodeID()); rec.setRecordKeys(inputRec.getRecordKeys()); rec.setTimeStamp(inputRec.getTimeStamp()); rec.setTSDRDataCategory(inputRec.getTSDRDataCategory()); records.add(rec.build()); } tsdrServiceInput.setTSDRMetricRecord(records); metricDataService.storeTSDRMetricRecord(tsdrServiceInput.build()); return Futures.immediateFuture(RpcResultBuilder.<Void>success().build()); }
From source file:com.android.camera.one.v2.initialization.PreviewStarter.java
/** * See {@link OneCamera#startPreview}./*from w w w . j a v a2s . com*/ * * @param surface The preview surface to use. */ public ListenableFuture<Void> startPreview(final Surface surface) { // When we have the preview surface, start the capture session. List<Surface> surfaceList = new ArrayList<>(); // Workaround of the face detection failure on Nexus 5 and L. (b/21039466) // Need to create a capture session with the single preview stream first // to lock it as the first stream. Then resend the another session with preview // and JPEG stream. if (ApiHelper.isLorLMr1() && ApiHelper.IS_NEXUS_5) { surfaceList.add(surface); mCaptureSessionCreator.createCaptureSession(surfaceList); surfaceList.addAll(mOutputSurfaces); } else { surfaceList.addAll(mOutputSurfaces); surfaceList.add(surface); } final ListenableFuture<CameraCaptureSessionProxy> sessionFuture = mCaptureSessionCreator .createCaptureSession(surfaceList); return Futures.transform(sessionFuture, new AsyncFunction<CameraCaptureSessionProxy, Void>() { @Override public ListenableFuture<Void> apply(CameraCaptureSessionProxy captureSession) throws Exception { mSessionListener.onCameraCaptureSessionCreated(captureSession, surface); return Futures.immediateFuture(null); } }); }
From source file:io.crate.operation.collect.HandlerSideDataCollectOperation.java
@Override public ListenableFuture<Object[][]> collect(CollectNode collectNode, RamAccountingContext ramAccountingContext) { if (collectNode.isPartitioned()) { // edge case: partitioned table without actual indices // no results return Futures.immediateFuture(TaskResult.EMPTY_RESULT.rows()); }//w w w.j a v a2 s. co m if (collectNode.maxRowGranularity() == RowGranularity.DOC) { // we assume information schema here return handleWithService(informationSchemaCollectService, collectNode, ramAccountingContext); } else if (collectNode.maxRowGranularity() == RowGranularity.CLUSTER) { return handleCluster(collectNode, ramAccountingContext); } else if (collectNode.maxRowGranularity() == RowGranularity.SHARD) { return handleWithService(unassignedShardsCollectService, collectNode, ramAccountingContext); } else { return Futures.immediateFailedFuture(new IllegalStateException("unsupported routing")); } }
From source file:org.thingsboard.rule.engine.metadata.TbAbstractGetAttributesNode.java
private ListenableFuture<Void> putAttrAsync(TbContext ctx, EntityId entityId, TbMsg msg, String scope, List<String> keys, String prefix) { if (CollectionUtils.isEmpty(keys)) { return Futures.immediateFuture(null); }// ww w . j a va 2 s.c o m ListenableFuture<List<AttributeKvEntry>> latest = ctx.getAttributesService().find(ctx.getTenantId(), entityId, scope, keys); return Futures.transform(latest, l -> { l.forEach(r -> { if (r.getValue() != null) { msg.getMetaData().putValue(prefix + r.getKey(), r.getValueAsString()); } else { throw new RuntimeException( "[" + scope + "][" + r.getKey() + "] attribute value is not present in the DB!"); } }); return null; }); }
From source file:producerstest.SimpleProducerModule.java
@Produces @Qual(11)//from ww w . j a va 2s .c o m @SuppressWarnings("unused") // unthrown exception for test, unused parameter for test static ListenableFuture<String> futureStrWithArgsThrowingException(int i, Produced<Double> b, Producer<Object> c, Provider<Boolean> d) throws IOException { return Futures.immediateFuture("str with args throwing exception"); }
From source file:org.apache.fluo.core.async.AsyncConditionalWriter.java
@Override public ListenableFuture<Iterator<Result>> apply(Collection<ConditionalMutation> input) { if (input.size() == 0) { return Futures.immediateFuture(Collections.<Result>emptyList().iterator()); }// w w w . j ava 2 s . c o m semaphore.acquire(input.size()); Iterator<Result> iter = cw.write(input.iterator()); return les.submit(new IterTask(iter, input.size())); }
From source file:com.facebook.buck.distributed.RemoteExecutionStorageService.java
@Override public ListenableFuture<Void> fetchToStream(Digest digest, OutputStream outputStream) { try {/*from ww w .ja v a 2 s . c om*/ fetchToStreamInternal(digest, outputStream).get(); return Futures.immediateFuture(null); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw logAndThrowException(digest, e); } catch (ExecutionException e) { throw logAndThrowException(digest, e); } }
From source file:com.facebook.presto.operator.index.IndexLookupSourceFactory.java
@Override public ListenableFuture<LookupSource> createLookupSource() { checkState(taskContext != null, "taskContext not set"); IndexLoader indexLoader = indexLoaderSupplier.get(); indexLoader.setContext(taskContext); return Futures.immediateFuture(new IndexLookupSource(indexLoader)); }