Class ExchangeSinkHandler

java.lang.Object
org.elasticsearch.compute.operator.exchange.ExchangeSinkHandler

public final class ExchangeSinkHandler extends Object
An ExchangeSinkHandler receives pages and status from its ExchangeSinks, which are created using createExchangeSink(Runnable)} method. Pages and status can then be retrieved asynchronously by ExchangeSourceHandlers using the fetchPageAsync(boolean, ActionListener) method.
See Also:
  • Constructor Details

    • ExchangeSinkHandler

      public ExchangeSinkHandler(BlockFactory blockFactory, int maxBufferSize, LongSupplier nowInMillis)
  • Method Details

    • fetchPageAsync

      public void fetchPageAsync(boolean sourceFinished, ActionListener<ExchangeResponse> listener)
      Fetches pages and the sink status asynchronously.
      Parameters:
      sourceFinished - if true, then this handler can finish as sources have enough pages.
      listener - the listener that will be notified when pages are ready or this handler is finished
      See Also:
    • addCompletionListener

      public void addCompletionListener(ActionListener<Void> listener)
      Add a listener, which will be notified when this exchange sink handler is completed. An exchange sink handler is consider completed when all associated sinks are completed and the output pages are fetched.
    • isFinished

      public boolean isFinished()
      Returns true if an exchange is finished
    • createExchangeSink

      public ExchangeSink createExchangeSink(Runnable onPageFetched)
      Create a new exchange sink for exchanging data
      Parameters:
      onPageFetched - a Runnable that will be called when a page is fetched.
      See Also:
    • bufferSize

      public int bufferSize()
      Returns the number of pages available in the buffer. This method should be used for testing only.