Shuts down the client and closes all connections.

<p>After a call to this method, all returned futures will be failed.

@return A {@link CompletableFuture} that will be completed when the shutdown process is done.
972520
public CompletableFuture<Void> shutdown() {
		final CompletableFuture<Void> newShutdownFuture = new CompletableFuture<>();
		if (clientShutdownFuture.compareAndSet(null, newShutdownFuture)) {

			final List<CompletableFuture<Void>> connectionFutures = new ArrayList<>();

			for (Map.Entry<InetSocketAddress, EstablishedConnection> conn : establishedConnections.entrySet()) {
				if (establishedConnections.remove(conn.getKey(), conn.getValue())) {
					connectionFutures.add(conn.getValue().close());
				}
			}

			for (Map.Entry<InetSocketAddress, PendingConnection> conn : pendingConnections.entrySet()) {
				if (pendingConnections.remove(conn.getKey()) != null) {
					connectionFutures.add(conn.getValue().close());
				}
			}

			CompletableFuture.allOf(
					connectionFutures.toArray(new CompletableFuture<?>[connectionFutures.size()])
			).whenComplete((result, throwable) -> {

				if (throwable != null) {
					LOG.warn("Problem while shutting down the connections at the {}: {}", clientName, throwable);
				}

				if (bootstrap != null) {
					EventLoopGroup group = bootstrap.group();
					if (group != null && !group.isShutdown()) {
						group.shutdownGracefully(0L, 0L, TimeUnit.MILLISECONDS)
								.addListener(finished -> {
									if (finished.isSuccess()) {
										newShutdownFuture.complete(null);
									} else {
										newShutdownFuture.completeExceptionally(finished.cause());
									}
								});
					} else {
						newShutdownFuture.complete(null);
					}
				} else {
					newShutdownFuture.complete(null);
				}
			});

			return newShutdownFuture;
		}
		return clientShutdownFuture.get();
	}
376428
@Override
	public final Promise disconnect() {
		if (client != null) {
			client.close();
			client = null;
		} else if (clusteredClient != null) {
			clusteredClient.close();
			clusteredClient = null;
		}
		return super.disconnect();
	}
902597
public CompletableFuture<Void> shutdownServer() {
		CompletableFuture<Void> shutdownFuture = new CompletableFuture<>();
		if (serverShutdownFuture.compareAndSet(null, shutdownFuture)) {
			log.info("Shutting down {} @ {}", serverName, serverAddress);

			final CompletableFuture<Void> groupShutdownFuture = new CompletableFuture<>();
			if (bootstrap != null) {
				EventLoopGroup group = bootstrap.group();
				if (group != null && !group.isShutdown()) {
					group.shutdownGracefully(0L, 0L, TimeUnit.MILLISECONDS)
							.addListener(finished -> {
								if (finished.isSuccess()) {
									groupShutdownFuture.complete(null);
								} else {
									groupShutdownFuture.completeExceptionally(finished.cause());
								}
							});
				} else {
					groupShutdownFuture.complete(null);
				}
			} else {
				groupShutdownFuture.complete(null);
			}

			final CompletableFuture<Void> handlerShutdownFuture = new CompletableFuture<>();
			if (handler == null) {
				handlerShutdownFuture.complete(null);
			} else {
				handler.shutdown().whenComplete((result, throwable) -> {
					if (throwable != null) {
						handlerShutdownFuture.completeExceptionally(throwable);
					} else {
						handlerShutdownFuture.complete(null);
					}
				});
			}

			final CompletableFuture<Void> queryExecShutdownFuture = CompletableFuture.runAsync(() -> {
				if (queryExecutor != null) {
					ExecutorUtils.gracefulShutdown(10L, TimeUnit.MINUTES, queryExecutor);
				}
			});

			CompletableFuture.allOf(
					queryExecShutdownFuture, groupShutdownFuture, handlerShutdownFuture
			).whenComplete((result, throwable) -> {
				if (throwable != null) {
					shutdownFuture.completeExceptionally(throwable);
				} else {
					shutdownFuture.complete(null);
				}
			});
		}
		return serverShutdownFuture.get();
	}
707301
public CompletableFuture<Void> close() {
    if (open.compareAndSet(true, false)) {
      CompletableFuture<Void> future = new CompletableFuture<>();
      threadContext.execute(() -> {
        synchronized (this) {
          for (Scheduled keepAliveFuture : keepAliveTimers.values()) {
            keepAliveFuture.cancel();
          }
          protocol.unregisterHeartbeatHandler();
        }
        future.complete(null);
      });
      return future;
    }
    return CompletableFuture.completedFuture(null);
  }
1197709
public CompletableFuture<Void> delete() {
    return server.stop().thenCompose(v -> client.stop()).thenRun(() -> {
      if (server != null) {
        server.delete();
      }
    });
  }
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();
    }
142317
private CompletableFuture<TableBucket> getNextBucket() {
        val fromBatch = getNextBucketFromExistingBatch();
        if (fromBatch != null) {
            return CompletableFuture.completedFuture(fromBatch);
        }

        val canContinue = new AtomicBoolean(true);
        return Futures.loop(canContinue::get, this::fetchNextTableBuckets, canContinue::set, this.executor)
                .thenApply(v -> getNextBucketFromExistingBatch());
    }
577105
public CompletableFuture<Void> close() {
    CompletableFuture[] futures = new CompletableFuture[connections.size()];

    for (CompletableFuture<Connection> future : this.connectionFutures.values()) {
      future.cancel(false);
    }

    int i = 0;
    for (Connection connection : connections.values()) {
      futures[i++] = connection.close();
    }

    return CompletableFuture.allOf(futures);
  }
903555
protected CompletableFuture<ExecutionResult> onFailureAsync(ExecutionResult result, Scheduler scheduler,
      FailsafeFuture<Object> future) {
    return CompletableFuture.completedFuture(onFailure(result));
  }
328010
public static <T> Throwable getException(CompletableFuture<T> future) {
        try {            
            future.getNow(null);
            return null;
        } catch (Exception e) {
            return Exceptions.unwrap(e);
        }
    }
917987
public static <T> CompletableFuture<T> failedFuture(Throwable exception) {
        CompletableFuture<T> result = new CompletableFuture<>();
        result.completeExceptionally(exception);
        return result;
    }
85809
private synchronized CompletableFuture<Void> join() {
    joinFuture = new CompletableFuture<>();

    context.getThreadContext().executor().execute(() -> {
      // Transition the server to the appropriate state for the local member type.
      context.transition(member.type());

      // Attempt to join the cluster. If the local member is ACTIVE then failing to join the cluster
      // will result in the member attempting to get elected. This allows initial clusters to form.
      List<MemberState> activeMembers = getActiveMemberStates();
      if (!activeMembers.isEmpty()) {
        join(getActiveMemberStates().iterator());
      } else {
        joinFuture.complete(null);
      }
    });

    return joinFuture.whenComplete((result, error) -> joinFuture = null);
  }
708802
@Override
    public Future<M> getDataFuture() {
        try {
            return FutureProcessor.completedFuture(getData());
        } catch (NotAvailableException ex) {
            CompletableFuture future = new CompletableFuture();
            future.completeExceptionally(ex);
            return future;
        }
    }
447973
@SuppressWarnings("unchecked")
  public CompletableFuture<A> connect() {
    return registry.createPrimitive(name(), type())
        .thenApply(v -> (A) this);
  }
290577
public CompletableFuture<Void> shutdown() {
    if (!started) {
      return Futures.exceptionalFuture(new IllegalStateException("Server not running"));
    }

    CompletableFuture<Void> future = new AtomixFuture<>();
    context.getThreadContext().execute(() -> {
      started = false;
      context.transition(Role.INACTIVE);
      future.complete(null);
    });

    return future.whenCompleteAsync((result, error) -> {
      context.close();
      started = false;
    });
  }
848608
public CompletableFuture<Void> closeAsync() {

        List<CompletableFuture<?>> close = new ArrayList<>(this.connections.size());
        List<RedisURI> toRemove = new ArrayList<>(this.connections.size());

        this.closed = true;

        for (Map.Entry<RedisURI, StatefulRedisConnection<String, String>> entry : this.connections.entrySet()) {

            toRemove.add(entry.getKey());
            close.add(entry.getValue().closeAsync());
        }

        for (RedisURI redisURI : toRemove) {
            this.connections.remove(redisURI);
        }

        return Futures.allOf(close);
    }
306986
public static <T> CompletableFuture<T> orTimeout(CompletableFuture<T> future, long timeout, TimeUnit timeUnit) {
		return orTimeout(future, timeout, timeUnit, Executors.directExecutor());
	}