@Override
    public void connect() {
        final ElasticSearch oldOne = es.get();

        final ElasticSearchBuilder cb =
            ElasticSearch
                .builder()
                .endpoints(clusterNodes.split(","))
                .protocol(protocol)
                .connectTimeout(connectTimeout)
                .responseTimeout(responseTimeout)
                .socketTimeout(socketTimeout)
                .numHttpClientThread(numHttpClientThread)
                .healthyListener(healthy -> {
                    if (healthy) {
                        healthChecker.health();
                    } else {
                        healthChecker.unHealth("No healthy endpoint");
                    }
                });

        if (!Strings.isNullOrEmpty(trustStorePath)) {
            cb.trustStorePath(trustStorePath);
        }
        if (!Strings.isNullOrEmpty(trustStorePass)) {
            cb.trustStorePass(trustStorePass);
        }
        if (!Strings.isNullOrEmpty(user)) {
            cb.username(user);
        }
        if (!Strings.isNullOrEmpty(password)) {
            cb.password(password);
        }

        final ElasticSearch newOne = cb.build();
        // Only swap the old / new after the new one established a new connection.
        final CompletableFuture<ElasticSearchVersion> f = newOne.connect();
        f.whenComplete((ignored, exception) -> {
            if (exception != null) {
                log.error("Failed to recreate ElasticSearch client based on config", exception);
                return;
            }
            if (es.compareAndSet(oldOne, newOne)) {
                oldOne.close();
            } else {
                newOne.close();
            }
        });
        f.join();
    }
ElasticSearchClient connects to the ES server by using ES client APIs.
oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ElasticSearchClient.java