Search in sources :

Example 1 with JestHttpClient

use of io.searchbox.client.http.JestHttpClient in project gerrit by GerritCodeReview.

the class JestClientBuilder method build.

JestHttpClient build() {
    JestClientFactory factory = new JestClientFactory();
    Builder builder = new HttpClientConfig.Builder(cfg.urls).multiThreaded(true).discoveryEnabled(false).connTimeout((int) cfg.connectionTimeout).maxConnectionIdleTime(cfg.maxConnectionIdleTime, cfg.maxConnectionIdleUnit).maxTotalConnection(cfg.maxTotalConnection).readTimeout(cfg.readTimeout).requestCompressionEnabled(cfg.requestCompression).discoveryFrequency(1L, TimeUnit.MINUTES);
    if (cfg.username != null && cfg.password != null) {
        builder.defaultCredentials(cfg.username, cfg.password);
    }
    factory.setHttpClientConfig(builder.build());
    return (JestHttpClient) factory.getObject();
}
Also used : Builder(io.searchbox.client.config.HttpClientConfig.Builder) JestClientFactory(io.searchbox.client.JestClientFactory) JestHttpClient(io.searchbox.client.http.JestHttpClient)

Example 2 with JestHttpClient

use of io.searchbox.client.http.JestHttpClient in project spring-boot by spring-projects.

the class JestAutoConfigurationTests method customizerOverridesAutoConfig.

@Test
public void customizerOverridesAutoConfig() {
    load(BuilderCustomizer.class, "spring.elasticsearch.jest.uris=http://localhost:9200");
    JestHttpClient client = (JestHttpClient) this.context.getBean(JestClient.class);
    assertThat(client.getGson()).isSameAs(this.context.getBean(BuilderCustomizer.class).getGson());
}
Also used : JestClient(io.searchbox.client.JestClient) JestHttpClient(io.searchbox.client.http.JestHttpClient) Test(org.junit.Test)

Example 3 with JestHttpClient

use of io.searchbox.client.http.JestHttpClient in project spring-boot by spring-projects.

the class JestAutoConfigurationTests method customGson.

@Test
public void customGson() {
    load(CustomGson.class, "spring.elasticsearch.jest.uris=http://localhost:9200");
    JestHttpClient client = (JestHttpClient) this.context.getBean(JestClient.class);
    assertThat(client.getGson()).isSameAs(this.context.getBean("customGson"));
}
Also used : JestClient(io.searchbox.client.JestClient) JestHttpClient(io.searchbox.client.http.JestHttpClient) Test(org.junit.Test)

Aggregations

JestHttpClient (io.searchbox.client.http.JestHttpClient)3 JestClient (io.searchbox.client.JestClient)2 Test (org.junit.Test)2 JestClientFactory (io.searchbox.client.JestClientFactory)1 Builder (io.searchbox.client.config.HttpClientConfig.Builder)1