Package org.elasticsearch.client
Class HeapBufferedAsyncResponseConsumer
- java.lang.Object
-
- org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<HttpResponse>
-
- org.elasticsearch.client.HeapBufferedAsyncResponseConsumer
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Cancellable,HttpAsyncResponseConsumer<HttpResponse>
public class HeapBufferedAsyncResponseConsumer extends AbstractAsyncResponseConsumer<HttpResponse>
Default implementation ofHttpAsyncResponseConsumer. Buffers the whole response content in heap memory, meaning that the size of the buffer is equal to the content-length of the response. Limits the size of responses that can be read based on a configurable argument. Throws an exception in case the entity is longer than the configured buffer limit.
-
-
Constructor Summary
Constructors Constructor Description HeapBufferedAsyncResponseConsumer(int bufferLimit)Creates a new instance of this consumer with the provided buffer limit
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected HttpResponsebuildResult(HttpContext context)intgetBufferLimit()Get the limit of the buffer.protected ByteBufferAllocatorgetByteBufferAllocator()Returns the instance ofByteBufferAllocatorto use for content buffering.protected voidonContentReceived(ContentDecoder decoder, IOControl ioctrl)protected voidonEntityEnclosed(HttpEntity entity, ContentType contentType)protected voidonResponseReceived(HttpResponse response)protected voidreleaseResources()-
Methods inherited from class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer
cancel, close, consumeContent, failed, getContentType, getException, getResult, isDone, onClose, responseCompleted, responseReceived
-
-
-
-
Method Detail
-
getBufferLimit
public int getBufferLimit()
Get the limit of the buffer.
-
onResponseReceived
protected void onResponseReceived(HttpResponse response) throws HttpException, IOException
- Specified by:
onResponseReceivedin classAbstractAsyncResponseConsumer<HttpResponse>- Throws:
HttpExceptionIOException
-
onEntityEnclosed
protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException
- Specified by:
onEntityEnclosedin classAbstractAsyncResponseConsumer<HttpResponse>- Throws:
IOException
-
getByteBufferAllocator
protected ByteBufferAllocator getByteBufferAllocator()
Returns the instance ofByteBufferAllocatorto use for content buffering. Allows to plug in anyByteBufferAllocatorimplementation.
-
onContentReceived
protected void onContentReceived(ContentDecoder decoder, IOControl ioctrl) throws IOException
- Specified by:
onContentReceivedin classAbstractAsyncResponseConsumer<HttpResponse>- Throws:
IOException
-
buildResult
protected HttpResponse buildResult(HttpContext context) throws Exception
- Specified by:
buildResultin classAbstractAsyncResponseConsumer<HttpResponse>- Throws:
Exception
-
releaseResources
protected void releaseResources()
- Specified by:
releaseResourcesin classAbstractAsyncResponseConsumer<HttpResponse>
-
-