Class SequenceInputStreamResponseHandler
java.lang.Object
org.apache.druid.java.util.http.client.response.SequenceInputStreamResponseHandler
- All Implemented Interfaces:
HttpResponseHandler<InputStream,InputStream>
public class SequenceInputStreamResponseHandler
extends Object
implements HttpResponseHandler<InputStream,InputStream>
A HTTP response handler which uses sequence input streams to create a final InputStream.
Any particular instance is encouraged to overwrite a method and call the super if they need extra handling of the
method parameters.
This implementation uses a blocking queue to feed a SequenceInputStream that is terminated whenever the handler's Done
method is called or a throwable is detected.
The resulting InputStream will attempt to terminate normally, but on exception in HttpResponseHandler
may end with an IOException upon read()
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.druid.java.util.http.client.response.HttpResponseHandler
HttpResponseHandler.TrafficCop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondone(ClientResponse<InputStream> clientResponse) Called after the final handleResponse() or handleChunk() call, signifying that no more data will arrive.voidexceptionCaught(ClientResponse<InputStream> clientResponse, Throwable e) final longhandleChunk(ClientResponse<InputStream> clientResponse, org.jboss.netty.handler.codec.http.HttpChunk chunk, long chunkNum) Called for chunked responses, indicating another HttpChunk has arrived.handleResponse(org.jboss.netty.handler.codec.http.HttpResponse response, HttpResponseHandler.TrafficCop trafficCop) Handles the initial HttpResponse object that comes back from Netty.
-
Constructor Details
-
SequenceInputStreamResponseHandler
public SequenceInputStreamResponseHandler()
-
-
Method Details
-
handleResponse
public ClientResponse<InputStream> handleResponse(org.jboss.netty.handler.codec.http.HttpResponse response, HttpResponseHandler.TrafficCop trafficCop) Description copied from interface:HttpResponseHandlerHandles the initial HttpResponse object that comes back from Netty.- Specified by:
handleResponsein interfaceHttpResponseHandler<InputStream,InputStream> - Parameters:
response- response from NettytrafficCop- flow controller, allows resuming suspended reads- Returns:
- response that may be "finished" or "unfinished".
-
handleChunk
public ClientResponse<InputStream> handleChunk(ClientResponse<InputStream> clientResponse, org.jboss.netty.handler.codec.http.HttpChunk chunk, long chunkNum) Description copied from interface:HttpResponseHandlerCalled for chunked responses, indicating another HttpChunk has arrived.- Specified by:
handleChunkin interfaceHttpResponseHandler<InputStream,InputStream> - Parameters:
clientResponse- last response returned by the prior handleResponse() or handleChunk()chunk- the new chunk of datachunkNum- the sequence number of this chunk (increases monotonically)- Returns:
- response that may be "finished" or "unfinished".
-
done
Description copied from interface:HttpResponseHandlerCalled after the final handleResponse() or handleChunk() call, signifying that no more data will arrive.- Specified by:
donein interfaceHttpResponseHandler<InputStream,InputStream> - Parameters:
clientResponse- last response returned by handleResponse() or handleChunk()- Returns:
- response containing an object to hand back to the caller. It must be a "finished" response.
-
exceptionCaught
- Specified by:
exceptionCaughtin interfaceHttpResponseHandler<InputStream,InputStream>
-
getByteCount
public final long getByteCount()
-