@Override public void onSuccess(V value) throws Exception { future.success(); }
/** * Marks this future as successfully completed. * <p> * This is a shortcut for {@code success(null)}, which further shows, that the matter of successful * completion is important, not the resulting object of a computation. * * @return <tt>this</tt> for fluent method chaining */ public Future success() { success(null); return this; }
@Override public void onSuccess(@Nullable Object value) throws Exception { semaphore.release(); if (!completionFuture.isCompleted()) { if (promisesOpen.decrementAndGet() == 0) { completionFuture.success(); } } }
private static <I, O> void processChain(Iterator<I> iter, Function<I, Promise<O>> toPromiseHandler, BiConsumer<I, O> resultConsumer, Future completionFuture) { if (!iter.hasNext()) { completionFuture.success(); return; } I item = iter.next(); toPromiseHandler.apply(item).onSuccess(result -> { resultConsumer.accept(item, result); processChain(iter, toPromiseHandler, resultConsumer, completionFuture); }).onFailure(completionFuture::fail); }
protected void startup() { try (Operation op = new Operation(() -> "IndexLifecycle.startClient", Duration.ofSeconds(15))) { startClient(); } schema = new Schema(this); schema.load(); try (Operation op = new Operation(() -> "IndexLifecycle.updateMappings", Duration.ofSeconds(30))) { updateMappings(); } ready = true; readyFuture.success(); delayLineTimer = new Timer("index-delay"); delayLineTimer.schedule(new DelayLineHandler(), 1000, 1000); }
@Override public void started() { if (!elastic.isConfigured()) { return; } Elastic.LOG.INFO("Elastic is starting up and checking the database schema..."); int numSuccess = 0; int numFailed = 0; for (EntityDescriptor ed : mixing.getDesciptors()) { if (ElasticEntity.class.isAssignableFrom(ed.getType())) { if (setupEntity(ed)) { numSuccess++; } else { numFailed++; } } } Elastic.LOG.INFO("Setup completed: Updated %s indices / %s failures occurred", numSuccess, numFailed); elastic.readyFuture.success(); }
@Override public void run() { try { Watch w = Watch.start(); try { if (ctx == null) { CallContext.initialize(); } else { CallContext.setCurrent(ctx); } TaskContext.get().setSystem(SYSTEM_ASYNC).setSubSystem(category).setJob(String.valueOf(jobNumber)); runnable.run(); promise.success(null); } finally { CallContext.detach(); durationAverage.addValue(w.elapsedMillis()); } } catch (Exception t) { Exceptions.handle(Tasks.LOG, t); promise.fail(t); } }
readyFuture.success();