T - The format Requests/Responses are serialized as.public abstract class AbstractHandler<T> extends Object implements Handler<T>
Handlers to extend to inherit functionality common across
serialization strategies.Handler.HandlerResponse<T>| Modifier and Type | Field and Description |
|---|---|
private Service.RpcMetadataResponse |
metadata |
private static String |
NULL_EXCEPTION_MESSAGE |
protected Service |
service |
HANDLER_SERIALIZATION_METRICS_NAME, HTTP_INTERNAL_SERVER_ERROR, HTTP_OK, HTTP_UNAUTHENTICATED, HTTP_UNAUTHORIZED| Constructor and Description |
|---|
AbstractHandler(Service service) |
| Modifier and Type | Method and Description |
|---|---|
Handler.HandlerResponse<T> |
apply(T serializedRequest)
Compute a response for the given request, handling errors generated by that computation.
|
Handler.HandlerResponse<T> |
convertToErrorResponse(Exception e)
Attempts to convert an Exception to an ErrorResponse.
|
private Handler.HandlerResponse<T> |
createErrorResponse(Exception e,
int statusCode) |
(package private) abstract Service.Request |
decode(T serializedRequest) |
(package private) abstract T |
encode(Service.Response response)
Serialize the given
Service.Response per the concrete Handler implementation. |
private String |
getCausalChain(Exception e)
Constructs a message for the summary of an Exception.
|
void |
setRpcMetadata(Service.RpcMetadataResponse metadata)
Sets some general server information to return to the client in all responses.
|
Handler.HandlerResponse<T> |
unauthenticatedErrorResponse(Exception e)
Attempts to convert an Exception to an ErrorResponse with an HTTP status code of
401. |
Handler.HandlerResponse<T> |
unauthorizedErrorResponse(Exception e)
Attempts to convert an Exception to an ErrorResponse with an HTTP stauts code of
403. |
(package private) Service.ErrorResponse |
unwrapException(Exception e)
Unwrap Avatica-specific context about a given exception.
|
private static final String NULL_EXCEPTION_MESSAGE
protected final Service service
private Service.RpcMetadataResponse metadata
public AbstractHandler(Service service)
abstract Service.Request decode(T serializedRequest) throws IOException
IOExceptionabstract T encode(Service.Response response) throws IOException
Service.Response per the concrete Handler implementation.response - The Service.Response to serialize.Service.Response.IOExceptionService.ErrorResponse unwrapException(Exception e)
e - A caught exception throw by Avatica implementation.Service.ErrorResponse.public Handler.HandlerResponse<T> apply(T serializedRequest)
apply in interface Handler<T>serializedRequest - The caller's request.Service.Response with additional context about that response.public Handler.HandlerResponse<T> convertToErrorResponse(Exception e)
e - The exception to convert.public Handler.HandlerResponse<T> unauthenticatedErrorResponse(Exception e)
401.public Handler.HandlerResponse<T> unauthorizedErrorResponse(Exception e)
403.private Handler.HandlerResponse<T> createErrorResponse(Exception e, int statusCode)
private String getCausalChain(Exception e)
e - The Exception to summarize.public void setRpcMetadata(Service.RpcMetadataResponse metadata)
HandlersetRpcMetadata in interface Handler<T>metadata - Server-wide informationCopyright © 2012–2018 The Apache Software Foundation. All rights reserved.