Package org.apache.druid.frame.file
Class FrameFileHttpResponseHandler
- java.lang.Object
-
- org.apache.druid.frame.file.FrameFileHttpResponseHandler
-
- All Implemented Interfaces:
HttpResponseHandler<FrameFilePartialFetch,FrameFilePartialFetch>
public class FrameFileHttpResponseHandler extends Object implements HttpResponseHandler<FrameFilePartialFetch,FrameFilePartialFetch>
AnHttpResponseHandler
that streams data into aReadableByteChunksFrameChannel
. It is not required that the request actually fetches an entire frame file. The return object for this handler,FrameFilePartialFetch
, allows callers to tell how much of the file was read in a particular request. This handler implements backpressure throughFrameFilePartialFetch.backpressureFuture()
. This allows callers to back off from issuing the next request, if appropriate. However: the handler does not implement backpressure through theHttpResponseHandler.TrafficCop
mechanism. Therefore, it is important that each request retrieve a modest amount of data. The last fetch must be empty (zero content bytes) and must have the headerHEADER_LAST_FETCH_NAME
set toHEADER_LAST_FETCH_VALUE
. Under these conditions,FrameFilePartialFetch.isLastFetch()
returns true.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.druid.java.util.http.client.response.HttpResponseHandler
HttpResponseHandler.TrafficCop
-
-
Field Summary
Fields Modifier and Type Field Description static String
HEADER_LAST_FETCH_NAME
static String
HEADER_LAST_FETCH_VALUE
-
Constructor Summary
Constructors Constructor Description FrameFileHttpResponseHandler(ReadableByteChunksFrameChannel channel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientResponse<FrameFilePartialFetch>
done(ClientResponse<FrameFilePartialFetch> clientResponse)
Called after the final handleResponse() or handleChunk() call, signifying that no more data will arrive.void
exceptionCaught(ClientResponse<FrameFilePartialFetch> clientResponse, Throwable e)
ClientResponse<FrameFilePartialFetch>
handleChunk(ClientResponse<FrameFilePartialFetch> clientResponse, org.jboss.netty.handler.codec.http.HttpChunk chunk, long chunkNum)
Called for chunked responses, indicating another HttpChunk has arrived.ClientResponse<FrameFilePartialFetch>
handleResponse(org.jboss.netty.handler.codec.http.HttpResponse response, HttpResponseHandler.TrafficCop trafficCop)
Handles the initial HttpResponse object that comes back from Netty.
-
-
-
Field Detail
-
HEADER_LAST_FETCH_NAME
public static final String HEADER_LAST_FETCH_NAME
- See Also:
- Constant Field Values
-
HEADER_LAST_FETCH_VALUE
public static final String HEADER_LAST_FETCH_VALUE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FrameFileHttpResponseHandler
public FrameFileHttpResponseHandler(ReadableByteChunksFrameChannel channel)
-
-
Method Detail
-
handleResponse
public ClientResponse<FrameFilePartialFetch> 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<FrameFilePartialFetch,FrameFilePartialFetch>
- Parameters:
response
- response from NettytrafficCop
- flow controller, allows resuming suspended reads- Returns:
- response that may be "finished" or "unfinished".
-
handleChunk
public ClientResponse<FrameFilePartialFetch> handleChunk(ClientResponse<FrameFilePartialFetch> 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<FrameFilePartialFetch,FrameFilePartialFetch>
- 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<FrameFilePartialFetch> done(ClientResponse<FrameFilePartialFetch> 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<FrameFilePartialFetch,FrameFilePartialFetch>
- 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<FrameFilePartialFetch> clientResponse, Throwable e)
- Specified by:
exceptionCaught
in interfaceHttpResponseHandler<FrameFilePartialFetch,FrameFilePartialFetch>
-
-