[
https://issues.apache.org/jira/browse/BEAM-3026?focusedWorklogId=132011&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132011
]
ASF GitHub Bot logged work on BEAM-3026:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Aug/18 18:59
Start Date: 07/Aug/18 18:59
Worklog Time Spent: 10m
Work Description: timrobertson100 commented on a change in pull request
#6146: BEAM-3026 Adding retrying behavior on ElasticSearchIO for 429: Too Many
Requests
URL: https://github.com/apache/beam/pull/6146#discussion_r208348445
##########
File path:
sdks/java/io/elasticsearch/src/main/java/org/apache/beam/sdk/io/elasticsearch/ElasticsearchIO.java
##########
@@ -714,6 +729,57 @@ public void close() throws IOException {
}
}
+ /**
+ * This is the default predicate used to test if a failed ES operation
should be retried. A retry
+ * will be attempted until the maxAttempts or maxDuration is exceeded,
whichever comes first, for
+ * TOO_MANY_REQUESTS(429) exception.
+ */
+ static class DefaultRetryPredicate implements RetryPredicate {
+
+ private int errorCode;
+
+ public DefaultRetryPredicate(@Nonnull int code) {
+ Objects.requireNonNull(code);
+ this.errorCode = code;
+ }
+
+ public DefaultRetryPredicate() {
+ this(429);
+ }
+
+ /**
+ * method identified if the error is 429 returns true.
+ *
+ * @param response
+ * @return
+ */
+ private boolean identify(Response response) {
+ JsonNode searchResult = null;
+ try {
+ searchResult = parseResponse(response);
+ } catch (IOException e) {
+ LOG.warn("Could not identify the response " + response);
Review comment:
Please always use `LOG.warn("Parameterize messages {}", "like this");`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 132011)
Time Spent: 3h 10m (was: 3h)
> Improve retrying in ElasticSearch client
> ----------------------------------------
>
> Key: BEAM-3026
> URL: https://issues.apache.org/jira/browse/BEAM-3026
> Project: Beam
> Issue Type: Improvement
> Components: io-java-elasticsearch
> Reporter: Tim Robertson
> Assignee: Ravi Pathak
> Priority: Major
> Fix For: 2.6.0
>
> Time Spent: 3h 10m
> Remaining Estimate: 0h
>
> Currently an overloaded ES server will result in clients failing fast.
> I suggest implementing backoff pauses. Perhaps something like this:
> {code}
> ElasticsearchIO.ConnectionConfiguration conn =
> ElasticsearchIO.ConnectionConfiguration
> .create(new String[]{"http://...:9200"}, "test", "test")
> .retryWithWaitStrategy(WaitStrategies.exponentialBackoff(1000,
> TimeUnit.MILLISECONDS)
> .retryWithStopStrategy(StopStrategies.stopAfterAttempt(10)
> );
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)