Completes futures.
498980
private void completeFutures() {
    long commitIndex = queues.values().stream()
        .map(queue -> queue.ackedIndex)
        .reduce(Math::min)
        .orElse(0L);
    for (long i = context.getCommitIndex() + 1; i <= commitIndex; i++) {
      CompletableFuture<Void> future = futures.remove(i);
      if (future != null) {
        future.complete(null);
      }
    }
    context.setCommitIndex(commitIndex);
  }
714625
@SuppressWarnings("unchecked")
    public void finishJson(final JsonConvert convert, final CompletableFuture future) {
        finish(convert, (Type) null, future);
    }
706134
public void complete() {
        long seqNo = this.operation.getSequenceNumber();
        Preconditions.checkState(seqNo >= 0, "About to complete a CompletableOperation that has no sequence number.");

        this.done = true;
        if (this.successHandler != null) {
            Callbacks.invokeSafely(this.successHandler, null, cex -> log.error("Success Callback invocation failure.", cex));
        }
    }
578660
public static <T> IPromise<List<T>> allMapped(List<IPromise<T>> futures) {
        Promise returned = new Promise();
        Promise res = new Promise();
        awaitSettle(futures, res);
        res.then( (r, e) -> {
            if (r!=null) {
                returned.resolve(((List<Promise>)r).stream().map(p -> p.get()).collect(Collectors.toList()));
            } else {
                returned.complete(null,e);
            }
        });
        return returned;
    }
911372
private void finish(boolean commit)
   {
      for (Synchronization s : syncs)
      {
         s.beforeCompletion();
      }

      if (commit)
      {
         status = Status.STATUS_COMMITTED;
      }
      else
      {
         status = Status.STATUS_ROLLEDBACK;
      }

      for (Synchronization s : syncs)
      {
         s.afterCompletion(status);
      }

      status = Status.STATUS_UNKNOWN;
      syncs.clear();
      resources.clear();
   }
859360
private void onNextAttemptStarted(CompletionStage<Boolean> futureOutcome) {
    assert executor.inEventLoop();
    state = State.ATTEMPT_IN_PROGRESS;
    futureOutcome
        .whenCompleteAsync(this::onNextAttemptCompleted, executor)
        .exceptionally(UncaughtExceptions::log);
  }
1062318
public void close() {

        this.closed = true;

        List<CompletableFuture<?>> closeFutures = new ArrayList<>();
        while (hasConnections()) {
            for (StatefulRedisConnection<String, String> connection : drainConnections()) {
                closeFutures.add(connection.closeAsync());
            }
        }

        Futures.allOf(closeFutures).join();
    }
153374
@SuppressWarnings({ "unchecked", "rawtypes" })
    public static CompletableFuture<Void> allOf(Collection<? extends CompletableFuture<?>> futures) {

        LettuceAssert.notNull(futures, "Futures must not be null");

        return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
    }
1174013
private <T> T complete(CompletableFuture<T> future, int acquirePermits) {
    AtomicBoolean needRelease = new AtomicBoolean(false);
    try {
      return future.thenApply(value -> {
        if (needRelease.get()) {
          if (acquirePermits > 0) {
            asyncSemaphore.release(acquirePermits);
          }
        }
        return value;
      }).get(timeout.toMillis(), TimeUnit.MILLISECONDS);
    } catch (InterruptedException | PrimitiveException.Interrupted e) {
      needRelease.set(acquirePermits > 0);
      Thread.currentThread().interrupt();
      throw new PrimitiveException.Interrupted();
    } catch (TimeoutException | PrimitiveException.Timeout e) {
      needRelease.set(acquirePermits > 0);
      throw new PrimitiveException.Timeout();
    } catch (ExecutionException e) {
      needRelease.set(acquirePermits > 0);
      Throwable cause = Throwables.getRootCause(e);
      if (cause instanceof PrimitiveException) {
        throw (PrimitiveException) cause;
      } else {
        throw new PrimitiveException(cause);
      }
    }
  }
440264
void finish() {
		synchronized (this.monitor) {
			if (!isFinished()) {
				this.logger = DeferredLog.replay(this.logger,
						LogFactory.getLog(getClass()));
				this.finished = true;
			}
		}
	}
122406
public static <T> IPromise<IPromise<T>[]> all(IPromise<T>... futures) {
        Promise res = new Promise();
        awaitSettle(futures, res);
        return res;
    }
1328754
protected boolean completeAppend(boolean succeeded, long lastLogIndex, CompletableFuture<AppendResponse> future) {
    future.complete(logResponse(AppendResponse.builder()
        .withStatus(RaftResponse.Status.OK)
        .withTerm(raft.getTerm())
        .withSucceeded(succeeded)
        .withLastLogIndex(lastLogIndex)
        .build()));
    return succeeded;
  }
221684
private CompletableFuture<List<EpochRecord>> getEpochRecords(String scope, String stream, int epoch, OperationContext context) {
        List<CompletableFuture<EpochRecord>> list = new ArrayList<>();
        list.add(streamMetadataStore.getEpoch(scope, stream, epoch, context, executor));
        list.add(streamMetadataStore.getActiveEpoch(scope, stream, context, true, executor));
        return Futures.allOfWithResults(list);
    }
435950
public static <V> FutureCombiner<V> whenAllComplete(
      Iterable<? extends ListenableFuture<? extends V>> futures) {
    return new FutureCombiner<V>(false, ImmutableList.copyOf(futures));
  }
480248
private CompletableFuture<Void> handleSnapshot() {
    return Futures.allOf(partitions.values().stream()
        .map(partition -> partition.snapshot())
        .collect(Collectors.toList()))
        .thenApply(v -> null);
  }
502342
public VertxCompletableFuture<T> withContext() {
    Context context = Objects.requireNonNull(Vertx.currentContext());
    return withContext(context);
  }
969061
@Override
    public <T> Future<T> unit(final T unit) {
        return new Future<T>(
                              CompletableFuture.completedFuture(unit));
    }