Module org.elasticsearch.compute
Class ExchangeSourceHandler
java.lang.Object
org.elasticsearch.compute.operator.exchange.ExchangeSourceHandler
An
ExchangeSourceHandler asynchronously fetches pages and status from multiple RemoteSinks
and feeds them to its ExchangeSource, which are created using the createExchangeSource()) method.
RemoteSinks are added using the addRemoteSink(RemoteSink, boolean, Runnable, int, ActionListener)) method.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionExchangeSourceHandler(int maxBufferSize, Executor fetchExecutor) Creates a new ExchangeSourceHandler. -
Method Summary
Modifier and TypeMethodDescriptionorg.elasticsearch.core.ReleasableLinks this exchange source with an empty/dummy remote sink.voidaddRemoteSink(RemoteSink remoteSink, boolean failFast, Runnable onPageFetched, int instances, ActionListener<Void> listener) Add a remote sink as a new data source of this handler.Create a newExchangeSourcefor exchanging datavoidfinishEarly(boolean drainingPages, ActionListener<Void> listener) Gracefully terminates the exchange source early by instructing all remote exchange sinks to stop their computations.boolean
-
Constructor Details
-
ExchangeSourceHandler
Creates a new ExchangeSourceHandler.- Parameters:
maxBufferSize- the maximum size of the exchange buffer. A larger buffer reduces ``pauses`` but uses more memory, which could otherwise be allocated for other purposes.fetchExecutor- the executor used to fetch pages.
-
-
Method Details
-
isFinished
public boolean isFinished() -
createExchangeSource
Create a newExchangeSourcefor exchanging data- See Also:
-
addRemoteSink
public void addRemoteSink(RemoteSink remoteSink, boolean failFast, Runnable onPageFetched, int instances, ActionListener<Void> listener) Add a remote sink as a new data source of this handler. The handler will start fetching data from this remote sink intermediately.- Parameters:
remoteSink- the remote sinkfailFast- determines how failures in this remote sink are handled: - Iffalse, failures from this remote sink will not cause the exchange source to abort. Callers must handle these failures notified vialistener. - Iftrue, failures from this remote sink will cause the exchange source to abort.onPageFetched- a callback that will be called when a page is fetched from the remote sinkinstances- the number of concurrent ``clients`` that this handler should use to fetch pages. More clients reduce latency, but add overhead.listener- a listener that will be notified when the sink fails or completes. Callers must handle failures notified via this listener.- See Also:
-
addEmptySink
public org.elasticsearch.core.Releasable addEmptySink()Links this exchange source with an empty/dummy remote sink. The purpose of this is to prevent this exchange source from finishing until we have performed other async actions, such as linking actual remote sinks.- Returns:
- a Releasable that should be called when the caller no longer needs to prevent the exchange source from completing.
-
finishEarly
Gracefully terminates the exchange source early by instructing all remote exchange sinks to stop their computations. This can happen when the exchange source has accumulated enough data (e.g., reaching the LIMIT) or when users want to see the current result immediately.- Parameters:
drainingPages- whether to discard pages already fetched in the exchange
-