protected final T getConnection(ClickHouseRequest<?> request) {
        ClickHouseNode newNode = ClickHouseChecker.nonNull(request, "request").getServer();
        lock.readLock().lock();
        try {
            ensureInitialized();
            if (checkConnection(connection, newNode, server, request)) {
                return connection;
            }
        } finally {
            lock.readLock().unlock();
        }

        lock.writeLock().lock();
        try {
            server = newNode;
            log.debug("Connecting to: %s", newNode);
            connection = newConnection(connection, server, request);
            log.debug("Connection established: %s", connection);

            return connection;
        } finally {
            lock.writeLock().unlock();
        }
    }
Gets a connection according to the given request.

@param request non-null request
@return non-null connection
@throws CompletionException when error occured
clickhouse-client/src/main/java/com/clickhouse/client/AbstractClient.java