Skip to content

Commit 0fc7086

Browse files
committed
Create ES ConfigOption MAX_RETRIES_IN_MILLIS
The ES RestClient does [not support](elastic/elasticsearch#21789 (comment)) a per request timeout configuration, however it does at least support a timeout configuration option `maxRetriesInMillis` that will timeout the overall request, including retries. It can be useful for others to configure this timeout, especially given the fact that users can configure their gremlin-script-execution timeout. Issues: JanusGraph#688 Signed-off-by: David Pitera <[email protected]>
1 parent b75fc6c commit 0fc7086

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

janusgraph-es/src/main/java/org/janusgraph/diskstorage/es/ElasticSearchIndex.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ public class ElasticSearchIndex implements IndexProvider {
122122
"This string should be formatted as a natural number followed by the lowercase letter " +
123123
"\"s\", e.g. 3s or 60s.", ConfigOption.Type.MASKABLE, "30s");
124124

125+
public static final ConfigOption<Integer> MAX_RETRY_TIMEOUT =
126+
new ConfigOption<>(ELASTICSEARCH_NS, "max-retry-timeout",
127+
"Sets the maximum timeout (in milliseconds) to honour in case of multiple retries of the same request " +
128+
"sent using the ElasticSearch Rest Client by JanusGraph.", ConfigOption.Type.MASKABLE, Integer.class);
129+
125130
public static final ConfigOption<String> BULK_REFRESH =
126131
new ConfigOption<>(ELASTICSEARCH_NS, "bulk-refresh",
127132
"Elasticsearch bulk API refresh setting used to control when changes made by this request are made " +

janusgraph-es/src/main/java/org/janusgraph/diskstorage/es/ElasticSearchSetup.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.google.common.base.Preconditions;
1919
import org.apache.http.HttpHost;
2020
import org.elasticsearch.client.RestClient;
21+
import org.elasticsearch.client.RestClientBuilder;
2122
import org.janusgraph.diskstorage.configuration.ConfigNamespace;
2223
import org.janusgraph.diskstorage.configuration.Configuration;
2324
import org.janusgraph.diskstorage.es.rest.RestElasticSearchClient;
@@ -66,7 +67,11 @@ public Connection connect(Configuration config) throws IOException {
6667
log.debug("Configured remote host: {} : {}", hostname, hostport);
6768
hosts.add(new HttpHost(hostname, hostport, "http"));
6869
}
69-
RestClient rc = RestClient.builder(hosts.toArray(new HttpHost[hosts.size()])).build();
70+
final RestClientBuilder rcb = RestClient.builder(hosts.toArray(new HttpHost[hosts.size()]));
71+
if (config.has(ElasticSearchIndex.MAX_RETRY_TIMEOUT)) {
72+
rcb.setMaxRetryTimeoutMillis(config.get(ElasticSearchIndex.MAX_RETRY_TIMEOUT));
73+
}
74+
final RestClient rc = rcb.build();
7075

7176
final int scrollKeepAlive = config.get(ElasticSearchIndex.ES_SCROLL_KEEP_ALIVE);
7277
Preconditions.checkArgument(scrollKeepAlive >= 1, "Scroll Keep alive should be greater or equals than 1");

0 commit comments

Comments
 (0)