本文整理汇总了Java中io.searchbox.client.JestClientFactory类的典型用法代码示例。如果您正苦于以下问题:Java JestClientFactory类的具体用法?Java JestClientFactory怎么用?Java JestClientFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JestClientFactory类属于io.searchbox.client包,在下文中一共展示了JestClientFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createClient
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
@Override
public JestClient createClient() {
if (client == null) {
JestClientFactory factory = new JestClientFactory();
HttpClientConfig.Builder builder = new HttpClientConfig.Builder(serverUris);
builder.maxTotalConnection(maxTotalConnections);
builder.defaultMaxTotalConnectionPerRoute(defaultMaxTotalConnectionsPerRoute);
builder.connTimeout(connTimeout);
builder.readTimeout(readTimeout);
builder.discoveryEnabled(discoveryEnabled);
builder.multiThreaded(true);
factory.setHttpClientConfig(builder.build());
client = factory.getObject();
}
return client;
}
示例2: jestClient
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
/**
* Create the client which connects to Elasticsearch. Connects to localhost if we are not running
* in the cloud.
*
* @return The configured {@link JestClient}
* @throws Exception if the connection params cannot be resolved from the environment in the cloud
*/
@Bean
public JestClient jestClient(String elasticSearchConnectionUrl, Gson gson) throws Exception {
int readTimeout = metadataManagementProperties.getElasticsearchClient()
.getReadTimeout();
// Configuration
HttpClientConfig clientConfig =
new HttpClientConfig.Builder(elasticSearchConnectionUrl).readTimeout(readTimeout)
.multiThreaded(true)
.gson(gson)
.build();
// Construct a new Jest client according to configuration via factory
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(clientConfig);
return factory.getObject();
}
示例3: build
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
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();
}
示例4: getClient
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
protected static JestClient getClient(ElasticsearchConfig config) {
JestClientFactory jestFactory = new JestClientFactory();
HttpClientConfig.Builder httpClientBuilder = new HttpClientConfig.Builder(config.getHTTPURL());
//Although we have a single writer thread per system producer, we set multiThreaded as true so that Jest
//will used a pooled connection manager which re-establishes connections after they go stale
httpClientBuilder.multiThreaded(true);
httpClientBuilder.connTimeout(config.getConnectTimeoutMs());
httpClientBuilder.readTimeout(config.getReadTimeoutMs());
if (config.getAuthType().equals(ElasticsearchConfig.AuthType.BASIC)) {
String user = config.getBasicAuthUser();
String password = config.getBasicAuthPassword();
if (user == null || password == null) {
throw new SamzaException("Please specify a user and password for HTTP basic auth");
}
httpClientBuilder.defaultCredentials(user, password);
}
jestFactory.setHttpClientConfig(httpClientBuilder.build());
return jestFactory.getObject();
}
示例5: jestClient
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
@Bean
public JestClient jestClient() {
Gson gson = new GsonBuilder().registerTypeAdapter(DateTime.class, new com.google.gson.JsonDeserializer<DateTime>() {
@Override
public DateTime deserialize(JsonElement json, java.lang.reflect.Type typeOfT, com.google.gson.JsonDeserializationContext context)
throws JsonParseException {
return new DateTime(json.getAsString());
}
}).create();
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
.Builder(connectionUrl)
.gson(gson)
.multiThreaded(true)
.discoveryFrequency(60, TimeUnit.SECONDS)
.build());
return factory.getObject();
}
示例6: initialize
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
/**
* Initialize this operator and create Elasticsearch client to send get requests to.
* @param context OperatorContext for this operator.
* @throws Exception Operator failure, will cause the enclosing PE to terminate.
*/
@Override
public synchronized void initialize(OperatorContext context) throws Exception {
super.initialize(context);
// Construct a new Jest client according to configuration via factory
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
.Builder(hostName + ":" + hostPort)
.multiThreaded(true)
.build());
client = factory.getObject();
}
示例7: ElasticSearchServiceImpl
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
public ElasticSearchServiceImpl(){
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
.Builder("http://localhost:9200")
.multiThreaded(true)
//Per default this implementation will create no more than 2 concurrent connections per given route
.defaultMaxTotalConnectionPerRoute(4)
// and no more 20 connections in total
.maxTotalConnection(60)
.build());
client = factory.getObject();
}
示例8: getClient
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
private static JestClient getClient(String serverUri) {
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig.Builder(serverUri).connTimeout(10000).readTimeout(10000)
.multiThreaded(true).build());
JestClient client = factory.getObject();
return client;
}
示例9: init
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
@Override
public void init() throws Exception {
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
.Builder("http://127.0.0.1:9200")
//.multiThreaded(true)
.build());
client = factory.getObject();
}
示例10: init
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
@PostConstruct
public void init() {
JestClientFactory factory = new JestClientFactory();
String elasticSearchUrl = settingsServiceBean.getValueForKey(SettingsServiceBean.Key.ElasticSearchUrl,
"http://localhost:9200");
factory.setHttpClientConfig(new HttpClientConfig.Builder(elasticSearchUrl)
.multiThreaded(true)
.build());
client = factory.getObject();
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:11,代码来源:UsageLogSearchServiceBean.java
示例11: init
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
@PostConstruct
public void init(){
JestClientFactory factory = new JestClientFactory();
String elasticSearchUrl = settingsServiceBean.getValueForKey(SettingsServiceBean.Key.ElasticSearchUrl,
"http://localhost:9200");
factory.setHttpClientConfig(new HttpClientConfig.Builder(elasticSearchUrl)
.multiThreaded(true)
.build());
client = factory.getObject();
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:11,代码来源:UsageLogIndexServiceBean.java
示例12: createJestClient
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
/**
* Create Jest client with URI
* @param uri URI of Elasticsearch
* @return JestClient
*/
private JestClient createJestClient(String uri) {
HttpClientConfig.Builder builder = new HttpClientConfig.Builder(uri)
.maxTotalConnection(properties.getMaxTotalConnection())
.defaultMaxTotalConnectionPerRoute(properties.getDefaultMaxTotalConnectionPerRoute())
.readTimeout(properties.getReadTimeout())
.multiThreaded(properties.getMultiThreaded());
if (StringUtils.hasText(this.properties.getUsername())) {
builder.defaultCredentials(this.properties.getUsername(), this.properties.getPassword());
}
String proxyHost = this.properties.getProxy().getHost();
if (StringUtils.hasText(proxyHost)) {
Integer proxyPort = this.properties.getProxy().getPort();
Assert.notNull(proxyPort, "Proxy port must not be null");
builder.proxy(new HttpHost(proxyHost, proxyPort));
}
List<HttpClientConfigBuilderCustomizer> configBuilderCustomizers = builderCustomizers != null ? builderCustomizers.getIfAvailable() : new ArrayList<>();
if (!CollectionUtils.isEmpty(configBuilderCustomizers)) {
logger.info("Custom HttpClientConfigBuilderCustomizers detected. Applying these to the HttpClientConfig builder.");
configBuilderCustomizers.stream().forEach(customizer -> customizer.customize(builder));
logger.info("Custom HttpClientConfigBuilderCustomizers applied.");
}
JestClientFactory factory = jestClientFactory != null ? jestClientFactory : new JestClientFactory();
factory.setHttpClientConfig(builder.build());
return factory.getObject();
}
示例13: initializeJestClient
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
private JestClient initializeJestClient(ElasticsearchConfiguration esConfig) {
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
.Builder(esConfig.getElasticsearchProtocol() + "://" + esConfig.getElasticsearchAddress() + ":" + esConfig.getElasticsearchPort())
.multiThreaded(true)
.readTimeout(JEST_READ_TIMEOUT)
.build());
logger.info("Creating Jest client to handle all ES operations");
return factory.getObject();
}
示例14: ElasticsearchService
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
@Autowired
public ElasticsearchService(C2monClientProperties properties) {
this.timeSeriesIndex = properties.getElasticsearch().getIndexPrefix() + "-tag*";
this.configIndex = properties.getElasticsearch().getTagConfigIndex();
this.alarmIndex = properties.getElasticsearch().getIndexPrefix() + "-alarm*";
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig.Builder(properties.getElasticsearch().getUrl())
.multiThreaded(true)
.build());
client = factory.getObject();
}
示例15: jestClient
import io.searchbox.client.JestClientFactory; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public JestClient jestClient() {
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(createHttpClientConfig());
return factory.getObject();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:JestAutoConfiguration.java