ES5: Correct RestClient.FailureListener behaviour & retry logic


#1

Hi,

I have been using the ES5 RestClient which I am building as follows:

RestClient.builder(hosts)
.setFailureListener(failureListener)
.build();

The failureListener that I have created simply logs a message that there has been a failure as follows:

Host [http://localhost:9200] failure

When the above failure occurs (for a bulk indexing test I have been running) it will later be followed by a timeout:

java.io.IOException: listener timeout after waiting for [10000] ms
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:616)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:212)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:184)

After a failure will the RestClient be in a usable state? Should I rebuild a new RestClient after a failure or perhaps do something in the onFailure method to recover?

If I want to add retry logic what is the best way to do this? Should I add retry logic around RestClient or can the RestClient provide it? Sounds a bit hacky, but if I provided a list of two identical hosts (&port) would the RestClient retry on the 'other' host if the first one failed?

Cheers,

Stuart


(Nik Everett) #2

It'll be fine. If you have multiple nodes or are using the sniffer then for certain failures it'll remove the node from the list and try another node, iirc.

If you want to retry on the same node then I'd implement the retry logic outside of the REST client.


#3

Great, thanks for the clarification.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.