Class AbstractMeteredStorageObject

java.lang.Object
org.elasticsearch.xpack.esql.datasources.spi.AbstractMeteredStorageObject
All Implemented Interfaces:
StorageObject

public abstract class AbstractMeteredStorageObject extends Object implements StorageObject
Base for the leaf StorageObject providers (S3, GCS, Azure, HTTP, local): owns the counters field and the metrics() accessor that each used to re-declare identically, plus the shared native-async read completion handling (onReadComplete(java.util.concurrent.CompletableFuture<T>, java.util.function.BiConsumer<T, java.lang.Throwable>) / deliverRead(org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.esql.datasources.spi.DirectReadBuffer>, org.elasticsearch.xpack.esql.datasources.spi.DirectReadBuffer, long)). Subclasses keep their provider-specific orchestration (failure mapping, status checks, buffer allocation) inline. Decorators do not extend this; they forward metrics() to their delegate.
  • Field Details

  • Constructor Details

    • AbstractMeteredStorageObject

      public AbstractMeteredStorageObject()
  • Method Details

    • metrics

      public final StorageObjectMetrics metrics()
      Description copied from interface: StorageObject
      Returns cumulative I/O counters for reads against this object.

      Implementations that don't track I/O return StorageObjectMetrics.ZERO. Decorator wrappers must delegate to the wrapped object so counters are attributed to the underlying store, not the wrapper layer.

      Specified by:
      metrics in interface StorageObject
    • attachMetrics

      public final void attachMetrics(ExternalSourceMetrics metrics, String scheme)
      Description copied from interface: StorageObject
      Attaches the node telemetry sink and the storage scheme dimension so that this object's read/retry events are published to ExternalSourceMetrics (in addition to the profile counters surfaced by StorageObject.metrics()). Called once by the operator wiring when it opens the object. The default is a no-op for objects that don't track I/O; decorator wrappers must forward to the wrapped object so the metrics attach to the underlying store, not the wrapper layer.
      Specified by:
      attachMetrics in interface StorageObject
    • onReadComplete

      protected static <T> CompletableFuture<T> onReadComplete(CompletableFuture<T> future, BiConsumer<T,Throwable> handler)
      Attaches handler to a native-async read future and returns the future. The underlying client (the AWS SDK, HttpClient, the Azure reactive client) hands us a CompletableFuture, which captures any Error a completion callback throws into the future it returns rather than letting it propagate. The handler is wrapped so a fatal error is rethrown to the uncaught-exception handler via ExceptionsHelper.maybeDieOnAnotherThread(java.lang.Throwable) instead of being swallowed.
    • deliverRead

      protected final void deliverRead(ActionListener<DirectReadBuffer> listener, DirectReadBuffer buffer, long startNanos)
      Hands a successfully-read buffer to listener, recording the byte count and elapsed time. If delivery throws, closes the buffer so its breaker charge does not outlive the failed hand-off, then propagates.