Package org.elasticsearch.client
Class HeapBufferedAsyncResponseConsumer
java.lang.Object
org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>
org.elasticsearch.client.HeapBufferedAsyncResponseConsumer
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.http.concurrent.Cancellable,org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
public class HeapBufferedAsyncResponseConsumer
extends org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>
Default implementation of
HttpAsyncResponseConsumer. 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
ConstructorsConstructorDescriptionHeapBufferedAsyncResponseConsumer(int bufferLimit) Creates a new instance of this consumer with the provided buffer limit -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.http.HttpResponsebuildResult(org.apache.http.protocol.HttpContext context) intGet the limit of the buffer.protected org.apache.http.nio.util.ByteBufferAllocatorReturns the instance ofByteBufferAllocatorto use for content buffering.protected voidonContentReceived(org.apache.http.nio.ContentDecoder decoder, org.apache.http.nio.IOControl ioctrl) protected voidonEntityEnclosed(org.apache.http.HttpEntity entity, org.apache.http.entity.ContentType contentType) protected voidonResponseReceived(org.apache.http.HttpResponse httpResponse) protected voidMethods inherited from class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer
cancel, close, consumeContent, failed, getContentType, getException, getResult, isDone, onClose, responseCompleted, responseReceived
-
Constructor Details
-
HeapBufferedAsyncResponseConsumer
public HeapBufferedAsyncResponseConsumer(int bufferLimit) Creates a new instance of this consumer with the provided buffer limit
-
-
Method Details
-
getBufferLimit
public int getBufferLimit()Get the limit of the buffer. -
onResponseReceived
protected void onResponseReceived(org.apache.http.HttpResponse httpResponse) throws org.apache.http.HttpException, IOException - Specified by:
onResponseReceivedin classorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>- Throws:
org.apache.http.HttpExceptionIOException
-
onEntityEnclosed
protected void onEntityEnclosed(org.apache.http.HttpEntity entity, org.apache.http.entity.ContentType contentType) throws IOException - Specified by:
onEntityEnclosedin classorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>- Throws:
IOException
-
getByteBufferAllocator
protected org.apache.http.nio.util.ByteBufferAllocator getByteBufferAllocator()Returns the instance ofByteBufferAllocatorto use for content buffering. Allows to plug in anyByteBufferAllocatorimplementation. -
onContentReceived
protected void onContentReceived(org.apache.http.nio.ContentDecoder decoder, org.apache.http.nio.IOControl ioctrl) throws IOException - Specified by:
onContentReceivedin classorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>- Throws:
IOException
-
buildResult
protected org.apache.http.HttpResponse buildResult(org.apache.http.protocol.HttpContext context) throws Exception - Specified by:
buildResultin classorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>- Throws:
Exception
-
releaseResources
protected void releaseResources()- Specified by:
releaseResourcesin classorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<org.apache.http.HttpResponse>
-