Package org.elasticsearch.action.support
Class ListenerTimeouts
java.lang.Object
org.elasticsearch.action.support.ListenerTimeouts
public class ListenerTimeouts
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description ListenerTimeouts()
-
Method Summary
Modifier and Type Method Description static <Response> ActionListener<Response>
wrapWithTimeout(ThreadPool threadPool, ActionListener<Response> listener, org.elasticsearch.common.unit.TimeValue timeout, java.lang.String executor, java.lang.String listenerName)
Wraps a listener with a listener that can timeout.static <Response> ActionListener<Response>
wrapWithTimeout(ThreadPool threadPool, org.elasticsearch.common.unit.TimeValue timeout, java.lang.String executor, ActionListener<Response> listener, java.util.function.Consumer<ActionListener<Response>> onTimeout)
Wraps a listener with a listener that can timeout.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ListenerTimeouts
public ListenerTimeouts()
-
-
Method Details
-
wrapWithTimeout
public static <Response> ActionListener<Response> wrapWithTimeout(ThreadPool threadPool, ActionListener<Response> listener, org.elasticsearch.common.unit.TimeValue timeout, java.lang.String executor, java.lang.String listenerName)Wraps a listener with a listener that can timeout. After the timeout period theActionListener.onFailure(Exception)
will be called with aElasticsearchTimeoutException
if the listener has not already been completed.- Parameters:
threadPool
- used to schedule the timeoutlistener
- to that can timeouttimeout
- period before listener failedexecutor
- to use for scheduling timeoutlistenerName
- name of the listener for timeout exception- Returns:
- the wrapped listener that will timeout
-
wrapWithTimeout
public static <Response> ActionListener<Response> wrapWithTimeout(ThreadPool threadPool, org.elasticsearch.common.unit.TimeValue timeout, java.lang.String executor, ActionListener<Response> listener, java.util.function.Consumer<ActionListener<Response>> onTimeout)Wraps a listener with a listener that can timeout. After the timeout period the onTimeout Runnable will be called.- Parameters:
threadPool
- used to schedule the timeouttimeout
- period before listener failedexecutor
- to use for scheduling timeoutlistener
- to that can timeoutonTimeout
- consumer will be called and the resulting wrapper will be passed to it as a parameter- Returns:
- the wrapped listener that will timeout
-