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 Constructor Description SequenceInputStreamResponseHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientResponse<InputStream>
done(ClientResponse<InputStream> clientResponse)
Called after the final handleResponse() or handleChunk() call, signifying that no more data will arrive.void
exceptionCaught(ClientResponse<InputStream> clientResponse, Throwable e)
long
getByteCount()
ClientResponse<InputStream>
handleChunk(ClientResponse<InputStream> clientResponse, org.jboss.netty.handler.codec.http.HttpChunk chunk, long chunkNum)
Called for chunked responses, indicating another HttpChunk has arrived.ClientResponse<InputStream>
handleResponse(org.jboss.netty.handler.codec.http.HttpResponse response, HttpResponseHandler.TrafficCop trafficCop)
Handles the initial HttpResponse object that comes back from Netty.
-
-
-
Method Detail
-
handleResponse
public ClientResponse<InputStream> handleResponse(org.jboss.netty.handler.codec.http.HttpResponse response, HttpResponseHandler.TrafficCop trafficCop)
Description copied from interface:HttpResponseHandler
Handles the initial HttpResponse object that comes back from Netty.- Specified by:
handleResponse
in 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:HttpResponseHandler
Called for chunked responses, indicating another HttpChunk has arrived.- Specified by:
handleChunk
in 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
public ClientResponse<InputStream> done(ClientResponse<InputStream> clientResponse)
Description copied from interface:HttpResponseHandler
Called after the final handleResponse() or handleChunk() call, signifying that no more data will arrive.- Specified by:
done
in 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
public void exceptionCaught(ClientResponse<InputStream> clientResponse, Throwable e)
- Specified by:
exceptionCaught
in interfaceHttpResponseHandler<InputStream,InputStream>
-
getByteCount
public final long getByteCount()
-
-