use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestClientBuilder in project pancm_project by xuwujing.
the class EsScriptSearchTest method init.
/*
* 初始化服务
*/
private static void init() {
RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost(elasticIp, elasticPort));
client = new RestHighLevelClient(restClientBuilder);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestClientBuilder in project logging-log4j2 by apache.
the class LogstashIT method createClient.
private static RestHighLevelClient createClient() throws IOException {
// Instantiate the client.
LOGGER.info("instantiating the ES client");
final HttpHost httpHost = new HttpHost(HOST_NAME, MavenHardcodedConstants.ES_PORT);
final RestClientBuilder clientBuilder = RestClient.builder(httpHost);
final RestHighLevelClient client = new RestHighLevelClient(clientBuilder);
// Verify the connection.
LOGGER.info("verifying the ES connection");
final ClusterHealthResponse healthResponse = client.cluster().health(new ClusterHealthRequest(), RequestOptions.DEFAULT);
Assertions.assertThat(healthResponse.getStatus()).isNotEqualTo(ClusterHealthStatus.RED);
// Delete the index.
LOGGER.info("deleting the ES index");
final DeleteIndexRequest deleteRequest = new DeleteIndexRequest(MavenHardcodedConstants.ES_INDEX_NAME);
try {
final AcknowledgedResponse deleteResponse = client.indices().delete(deleteRequest, RequestOptions.DEFAULT);
Assertions.assertThat(deleteResponse.isAcknowledged()).isTrue();
} catch (ElasticsearchStatusException error) {
Assertions.assertThat(error).satisfies(ignored -> Assertions.assertThat(error.status()).isEqualTo(RestStatus.NOT_FOUND));
}
return client;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestClientBuilder in project flink by apache.
the class Elasticsearch7ApiCallBridge method createClient.
@Override
public RestHighLevelClient createClient(Map<String, String> clientConfig) {
RestClientBuilder builder = RestClient.builder(httpHosts.toArray(new HttpHost[httpHosts.size()]));
restClientFactory.configureRestClientBuilder(builder);
RestHighLevelClient rhlClient = new RestHighLevelClient(builder);
return rhlClient;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestClientBuilder in project flink by apache.
the class Elasticsearch6ApiCallBridge method createClient.
@Override
public RestHighLevelClient createClient(Map<String, String> clientConfig) {
RestClientBuilder builder = RestClient.builder(httpHosts.toArray(new HttpHost[httpHosts.size()]));
restClientFactory.configureRestClientBuilder(builder);
RestHighLevelClient rhlClient = new RestHighLevelClient(builder);
return rhlClient;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestClientBuilder in project graylog2-server by Graylog2.
the class RestHighLevelClientProvider method buildClient.
private RestHighLevelClient buildClient(List<URI> hosts, Duration connectTimeout, Duration socketTimeout, int maxTotalConnections, int maxTotalConnectionsPerRoute, boolean useExpectContinue, boolean muteElasticsearchDeprecationWarnings, CredentialsProvider credentialsProvider) {
final HttpHost[] esHosts = hosts.stream().map(uri -> new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme())).toArray(HttpHost[]::new);
final RestClientBuilder restClientBuilder = RestClient.builder(esHosts).setRequestConfigCallback(requestConfig -> requestConfig.setConnectTimeout(Math.toIntExact(connectTimeout.toMilliseconds())).setSocketTimeout(Math.toIntExact(socketTimeout.toMilliseconds())).setExpectContinueEnabled(useExpectContinue).setAuthenticationEnabled(true)).setHttpClientConfigCallback(httpClientConfig -> {
httpClientConfig.setMaxConnTotal(maxTotalConnections).setMaxConnPerRoute(maxTotalConnectionsPerRoute).setDefaultCredentialsProvider(credentialsProvider);
if (muteElasticsearchDeprecationWarnings) {
httpClientConfig.addInterceptorFirst(new ElasticsearchFilterDeprecationWarningsInterceptor());
}
return httpClientConfig;
});
return new RestHighLevelClient(restClientBuilder);
}
Aggregations