Class IndexingPressureAwareContentAggregator

java.lang.Object
org.elasticsearch.rest.IndexingPressureAwareContentAggregator
All Implemented Interfaces:
Closeable, AutoCloseable, CheckedConsumer<RestChannel,Exception>, Releasable, BaseRestHandler.RequestBodyChunkConsumer, BaseRestHandler.RestChannelConsumer

public class IndexingPressureAwareContentAggregator extends Object implements BaseRestHandler.RequestBodyChunkConsumer
Accumulates a streamed HTTP request body while tracking memory usage via IndexingPressure.

This is intended for indexing-related REST endpoints that receive opaque request bodies (e.g. protobuf) which must be fully accumulated before processing. It provides backpressure by reserving memory up front and rejecting oversized requests with a 413 status.

When accept(RestChannel) is called, the aggregator reserves memory via IndexingPressure.markCoordinatingOperationStarted(int, long, boolean). If the reservation fails (e.g. EsRejectedExecutionException under heavy load), the IndexingPressureAwareContentAggregator.CompletionHandler.onFailure(org.elasticsearch.rest.RestChannel, java.lang.Exception) callback is invoked so the caller can produce a format-appropriate error response (e.g. protobuf).

Once all chunks are accumulated, the reservation is lowered to the actual size and the IndexingPressureAwareContentAggregator.CompletionHandler is invoked with the aggregated content and the pressure reservation (as a Releasable) for the caller to release when appropriate.