Merge branch 'stable-2.15'

* stable-2.15:
  Elasticsearch: Allow to configure REST client's retry timeout
  ElasticConfiguration: Make hosts private
  config-gerrit: Fix formatting of elasticsearch.name.hostname

Change-Id: I76d072aab5506a3896a45adc92211020afc98c91
This commit is contained in:
David Pursehouse
2018-07-03 12:58:56 +09:00
3 changed files with 19 additions and 56 deletions

View File

@@ -37,15 +37,11 @@ class ElasticConfiguration {
private static final String DEFAULT_PROTOCOL = "http";
private final Config cfg;
private final List<HttpHost> hosts;
final List<HttpHost> hosts;
final String username;
final String password;
final boolean requestCompression;
final long connectionTimeout;
final long maxConnectionIdleTime;
final int maxTotalConnection;
final int readTimeout;
final int maxRetryTimeout;
final String prefix;
@Inject
@@ -53,15 +49,9 @@ class ElasticConfiguration {
this.cfg = cfg;
this.username = cfg.getString("elasticsearch", null, "username");
this.password = cfg.getString("elasticsearch", null, "password");
this.requestCompression = cfg.getBoolean("elasticsearch", null, "requestCompression", false);
this.connectionTimeout =
cfg.getTimeUnit("elasticsearch", null, "connectionTimeout", 3000, TimeUnit.MILLISECONDS);
this.maxConnectionIdleTime =
cfg.getTimeUnit(
"elasticsearch", null, "maxConnectionIdleTime", 3000, TimeUnit.MILLISECONDS);
this.maxTotalConnection = cfg.getInt("elasticsearch", null, "maxTotalConnection", 1);
this.readTimeout =
(int) cfg.getTimeUnit("elasticsearch", null, "readTimeout", 3000, TimeUnit.MICROSECONDS);
this.maxRetryTimeout =
(int)
cfg.getTimeUnit("elasticsearch", null, "maxRetryTimeout", 30000, TimeUnit.MILLISECONDS);
this.prefix = Strings.nullToEmpty(cfg.getString("elasticsearch", null, "prefix"));
Set<String> subsections = cfg.getSubsections("elasticsearch");
@@ -88,6 +78,10 @@ class ElasticConfiguration {
return cfg;
}
HttpHost[] getHosts() {
return hosts.toArray(new HttpHost[hosts.size()]);
}
String getIndexName(String name, int schemaVersion) {
return String.format("%s%s_%04d", prefix, name, schemaVersion);
}