code: private CompletableFuture<Connection> connect() {
      // If the address selector has been reset then reset the connection.
      if (selector.state() == AddressSelector.State.RESET && connection != null) {
        if (connectFuture != null) {
          return connectFuture;
        }
  
        CompletableFuture<Connection> future = new OrderedCompletableFuture<>();
        future.whenComplete((r, e) -> this.connectFuture = null);
        this.connectFuture = future;
  
        Connection oldConnection = this.connection;
        this.connection = null;
        oldConnection.close();
        connect(future);
        return future;
      }
  
      // If a connection was already established then use that connection.
      if (connection != null) {
        return CompletableFuture.completedFuture(connection);
      }
  
      // If a connection is currently being established then piggyback on the connect future.
      if (connectFuture != null) {
        return connectFuture;
      }
  
      // Create a new connect future and connect to the first server in the cluster.
      CompletableFuture<Connection> future = new OrderedCompletableFuture<>();
      future.whenComplete((r, e) -> this.connectFuture = null);
      this.connectFuture = future;
      reset().connect(future);
      return future;
    }
docs: Connects to the cluster.