public AsyncRpcResult(CompletableFuture<Object> future, boolean registerCallback) { this(future, new CompletableFuture<>(), registerCallback); }
public AsyncRpcResult(CompletableFuture<Object> future, boolean registerCallback) { this(future, new CompletableFuture<>(), registerCallback); }
@Override public void start() { if (this.started.compareAndSet(false, true)) { this.future = new CompletableFuture<>(); } }
@Override public void start() { if (this.started.compareAndSet(false, true)) { this.future = new CompletableFuture<>(); } }
/** * Returns a {@link CompletableFuture} that has failed with the exception * provided as argument. * @param throwable the exception to fail the future with. * @return The failed future. */ public static <T> CompletableFuture<T> getFailedFuture(Throwable throwable) { CompletableFuture<T> failedAttempt = new CompletableFuture<>(); failedAttempt.completeExceptionally(throwable); return failedAttempt; } }
@Override public CompletableFuture<Collection<Slice>> finish() { CompletableFuture<Collection<Slice>> cf = new CompletableFuture<>(); cf.complete(Collections.emptyList()); return cf; }
@Override public CompletableFuture<V> completable() { if (this.executionException != null) { CompletableFuture<V> completable = new CompletableFuture<>(); completable.completeExceptionally(exposedException(this.executionException)); return completable; } else { return CompletableFuture.completedFuture(this.value); } }
@Override public CompletableFuture<Collection<Slice>> finish() { finishFuture = new CompletableFuture<>(); return finishFuture; }
@Override public CompletableFuture<?> appendPage(Page page) { future = new CompletableFuture<>(); return future; }
@Override public CompletableFuture<KvStateResponse> handleRequest( final long requestId, final KvStateRequest request) { CompletableFuture<KvStateResponse> response = new CompletableFuture<>(); executeActionAsync(response, request, false); return response; }
public FutureAdapter(ResponseFuture future) { this.future = future; this.resultFuture = new CompletableFuture<>(); future.setCallback(new ResponseCallback() { @Override public void done(Object response) { Result result = (Result) response; FutureAdapter.this.resultFuture.complete(result); V value = null; try { value = (V) result.recreate(); } catch (Throwable t) { FutureAdapter.this.completeExceptionally(t); } FutureAdapter.this.complete(value); } @Override public void caught(Throwable exception) { FutureAdapter.this.completeExceptionally(exception); } }); }
public FutureAdapter(ResponseFuture future) { this.future = future; this.resultFuture = new CompletableFuture<>(); future.setCallback(new ResponseCallback() { @Override public void done(Object response) { Result result = (Result) response; FutureAdapter.this.resultFuture.complete(result); V value = null; try { value = (V) result.recreate(); } catch (Throwable t) { FutureAdapter.this.completeExceptionally(t); } FutureAdapter.this.complete(value); } @Override public void caught(Throwable exception) { FutureAdapter.this.completeExceptionally(exception); } }); }
@Override public CompletableFuture<V> completable() { if (this.executionException != null) { CompletableFuture<V> completable = new CompletableFuture<>(); completable.completeExceptionally(exposedException(this.executionException)); return completable; } else { return CompletableFuture.completedFuture(this.value); } }
public StreamRecordQueueEntry(StreamRecord<?> streamRecord) { super(streamRecord); hasTimestamp = streamRecord.hasTimestamp(); timestamp = streamRecord.getTimestamp(); resultFuture = new CompletableFuture<>(); }
@RequestMapping(params = "completableFutureWithImmediateValue") public CompletableFuture<Person> getCompletableFutureWithImmediateValue() { CompletableFuture<Person> future = new CompletableFuture<>(); future.complete(new Person("Joe")); return future; }
@MessageMapping("completable-future") public CompletableFuture<String> handleCompletableFuture() { this.future = new CompletableFuture<>(); return this.future; }
private synchronized void finishProcessingExpectedRecords() { checkState(expectedRecord.isDone()); checkState(!recordsProcessed.isDone()); recordsProcessed.complete(null); expectedRecord = new CompletableFuture<>(); recordsProcessed = new CompletableFuture<>(); }
@Test public void CompletableFutureToPublisher() { CompletableFuture<Integer> future = new CompletableFuture<>(); future.complete(1); Object target = getAdapter(CompletableFuture.class).toPublisher(future); assertTrue("Expected Mono Publisher: " + target.getClass().getName(), target instanceof Mono); assertEquals(Integer.valueOf(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000))); }
private synchronized List<ConnectorSplit> getBatch(int maxSize) { // take up to maxSize elements from the queue List<ConnectorSplit> elements = new ArrayList<>(maxSize); queue.drainTo(elements, maxSize); // if the queue is empty and the current future is finished, create a new one so // a new readers can be notified when the queue has elements to read if (queue.isEmpty() && !closed) { if (notEmptyFuture.isDone()) { notEmptyFuture = new CompletableFuture<>(); } } return ImmutableList.copyOf(elements); }
private Tuple2<JobID, Integer> callModify(String[] args) throws Exception { final CompletableFuture<Tuple2<JobID, Integer>> rescaleJobFuture = new CompletableFuture<>(); final TestingClusterClient clusterClient = new TestingClusterClient(rescaleJobFuture, getConfiguration()); final MockedCliFrontend cliFrontend = new MockedCliFrontend(clusterClient); cliFrontend.modify(args); assertThat(rescaleJobFuture.isDone(), Matchers.is(true)); return rescaleJobFuture.get(); }