@Override
    public void init(ClickHouseConfig config) {
        log.debug("Initializing new client: %d", this.hashCode());
        ClickHouseChecker.nonNull(config, ClickHouseConfig.TYPE_NAME);
        measureRequestTime = config.getBoolOption(ClickHouseClientOption.MEASURE_REQUEST_TIME);
        lock.writeLock().lock();
        try {
            Collection<ClickHouseProtocol> protocols = getSupportedProtocols();
            this.config = new ClickHouseConfig(config.getAllOptions(), config.getDefaultCredentials(),
                    config.getNodeSelector() != ClickHouseNodeSelector.EMPTY || protocols.isEmpty()
                            ? config.getNodeSelector()
                            : ClickHouseNodeSelector.of(protocols, null),
                    config.getMetricRegistry().orElse(null));
            if (this.executor == null) { // only initialize once
                int threads = config.getMaxThreadsPerClient();
                long threadTTL = config.getLongOption(ClickHouseClientOption.MAX_CORE_THREAD_TTL);
                this.executor = threads < 1 ? ClickHouseClient.getExecutorService()
                        : ClickHouseUtils.newThreadPool(this, threads, threads, config.getMaxQueuedRequests(), threadTTL, true);
            }

            initialized = true;
        } 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