@Test public void testGetClient() throws IOException { RestHighLevelClient client = ESClientManager.getInstance().getClient(); assertNotNull("01", client); boolean ping = false; ping = client.ping(RequestOptions.DEFAULT); assertTrue("02", ping); }
public synchronized RestHighLevelClient getClient() { if (client == null) { logger.info("Connecting to Elasticsearch cluster"); HttpHost[] hosts = getHosts(); RestClientBuilder builder = RestClient.builder(hosts); builder.setRequestConfigCallback( new RestClientBuilder.RequestConfigCallback() { @Override public RequestConfig.Builder customizeRequestConfig( RequestConfig.Builder requestConfigBuilder) { return requestConfigBuilder .setConnectTimeout(5000) .setSocketTimeout(0); } } ); client = new RestHighLevelClient(builder); logger.info("Connected"); } ping(); return client; }
ESClientManager { public synchronized RestHighLevelClient getClient() { if (client == null) { logger.info("Connecting to Elasticsearch cluster"); HttpHost[] hosts = getHosts(); RestClientBuilder builder = RestClient.builder(hosts); builder.setRequestConfigCallback( new RestClientBuilder.RequestConfigCallback() { @Override public RequestConfig.Builder customizeRequestConfig( RequestConfig.Builder requestConfigBuilder) { return requestConfigBuilder .setConnectTimeout(5000) .setSocketTimeout(0); } } ); client = new RestHighLevelClient(builder); logger.info("Connected"); } ping(); return client; } }
ESClientManager { public synchronized RestHighLevelClient getClient() { if (client == null) { logger.info("Connecting to Elasticsearch cluster"); HttpHost[] hosts = getHosts(); RestClientBuilder builder = RestClient.builder(hosts); builder.setRequestConfigCallback( new RestClientBuilder.RequestConfigCallback() { @Override public RequestConfig.Builder customizeRequestConfig( RequestConfig.Builder requestConfigBuilder) { return requestConfigBuilder .setConnectTimeout(5000) .setSocketTimeout(0); } } ); client = new RestHighLevelClient(builder); logger.info("Connected"); } ping(); return client; } private  ESClientManager(ConfigObject config); }
ESClientManager { public synchronized RestHighLevelClient getClient() { if (client == null) { logger.info("Connecting to Elasticsearch cluster"); HttpHost[] hosts = getHosts(); RestClientBuilder builder = RestClient.builder(hosts); builder.setRequestConfigCallback( new RestClientBuilder.RequestConfigCallback() { @Override public RequestConfig.Builder customizeRequestConfig( RequestConfig.Builder requestConfigBuilder) { return requestConfigBuilder .setConnectTimeout(5000) .setSocketTimeout(0); } } ); client = new RestHighLevelClient(builder); logger.info("Connected"); } ping(); return client; } private  ESClientManager(ConfigObject config); static ESClientManager getInstance(); synchronized RestHighLevelClient getClient(); synchronized void closeClient(); }
ESClientManager { public synchronized RestHighLevelClient getClient() { if (client == null) { logger.info("Connecting to Elasticsearch cluster"); HttpHost[] hosts = getHosts(); RestClientBuilder builder = RestClient.builder(hosts); builder.setRequestConfigCallback( new RestClientBuilder.RequestConfigCallback() { @Override public RequestConfig.Builder customizeRequestConfig( RequestConfig.Builder requestConfigBuilder) { return requestConfigBuilder .setConnectTimeout(5000) .setSocketTimeout(0); } } ); client = new RestHighLevelClient(builder); logger.info("Connected"); } ping(); return client; } private  ESClientManager(ConfigObject config); static ESClientManager getInstance(); synchronized RestHighLevelClient getClient(); synchronized void closeClient();  }