Class BidirectionalBatchExchangeBase

java.lang.Object
org.elasticsearch.compute.operator.exchange.BidirectionalBatchExchangeBase
All Implemented Interfaces:
Closeable, AutoCloseable, Releasable
Direct Known Subclasses:
BidirectionalBatchExchangeClient, BidirectionalBatchExchangeServer

public abstract class BidirectionalBatchExchangeBase extends Object implements Releasable
Base class for bidirectional batch exchange handlers. Contains common fields and exchange ID construction logic shared by BidirectionalBatchExchangeServer and BidirectionalBatchExchangeClient.
  • Field Details

    • sessionId

      protected final String sessionId
    • exchangeService

      protected final ExchangeService exchangeService
    • executor

      protected final Executor executor
    • maxBufferSize

      protected final int maxBufferSize
    • transportService

      protected final TransportService transportService
    • task

      protected final Task task
    • settings

      protected final Settings settings
  • Constructor Details

    • BidirectionalBatchExchangeBase

      protected BidirectionalBatchExchangeBase(String sessionId, ExchangeService exchangeService, Executor executor, int maxBufferSize, TransportService transportService, Task task, Settings settings)
      Base constructor for bidirectional batch exchange handlers.
      Parameters:
      sessionId - the session ID (used for logging and identification)
  • Method Details

    • logExchangeFailure

      public static void logExchangeFailure(org.apache.logging.log4j.Logger logger, org.apache.logging.log4j.Level nonCancellationLevel, Exception failure, String message, Object... params)
      Logs an exchange failure at nonCancellationLevel, unless it is a cancellation. Cancellations are expected teardown (for example the query reached its LIMIT and the exchange was closed early via a synthesized "client stopped" error, or the task was cancelled), so they are logged at DEBUG to keep genuine failures visible. Shared by the client, the server, and the operator driving them, so the caller supplies its own logger.
      Parameters:
      logger - the logger to log to (the caller's own logger)
      nonCancellationLevel - the level to log at when the failure is not a cancellation
      failure - the failure that decides the log level (cancellations are logged at DEBUG)
      message - a parameterized log message template
      params - the parameters for the message template; a trailing Throwable is logged with its stack trace
    • buildClientToServerId

      protected static String buildClientToServerId(String sessionId)
      Constructs the client-to-server exchange ID from the session ID.
    • buildServerToClientId

      protected static String buildServerToClientId(String sessionId)
      Constructs the server-to-client exchange ID from the session ID.
    • connectRemoteSink

      protected void connectRemoteSink(DiscoveryNode node, String exchangeId, ExchangeSourceHandler sourceHandler, ActionListener<Void> listener, String errorMessagePrefix)
      Connects a remote sink to a source handler via transport. This is a common pattern used by both server and client to establish transport-based connections for bidirectional exchange.

      Always uses failFast=true so the source handler aborts immediately on sink failure. The caller collects the real error via the listener and an EsqlRefCountingListener whose FailureCollector picks it over the generic TaskCancelledException thrown by the aborted source.