public class ProtobufHandler extends AbstractHandler<byte[]>
Service
by converting them to the POJO Request. Returns back the serialized protocol
buffer response.Handler.HandlerResponse<T>| Modifier and Type | Field and Description |
|---|---|
private MetricsSystem |
metrics |
private Timer |
serializationTimer |
private ProtobufTranslation |
translation |
serviceHANDLER_SERIALIZATION_METRICS_NAME, HTTP_INTERNAL_SERVER_ERROR, HTTP_OK, HTTP_UNAUTHENTICATED, HTTP_UNAUTHORIZED| Constructor and Description |
|---|
ProtobufHandler(Service service,
ProtobufTranslation translation,
MetricsSystem metrics) |
| Modifier and Type | Method and Description |
|---|---|
Handler.HandlerResponse<byte[]> |
apply(byte[] requestBytes)
Compute a response for the given request, handling errors generated by that computation.
|
(package private) Service.Request |
decode(byte[] serializedRequest) |
(package private) byte[] |
encode(Service.Response response)
Serialize the given
Service.Response per the concrete Handler implementation. |
convertToErrorResponse, setRpcMetadata, unauthenticatedErrorResponse, unauthorizedErrorResponse, unwrapExceptionprivate final ProtobufTranslation translation
private final MetricsSystem metrics
private final Timer serializationTimer
public ProtobufHandler(Service service, ProtobufTranslation translation, MetricsSystem metrics)
public Handler.HandlerResponse<byte[]> apply(byte[] requestBytes)
AbstractHandlerapply in interface Handler<byte[]>apply in class AbstractHandler<byte[]>requestBytes - The caller's request.Service.Response with additional context about that response.Service.Request decode(byte[] serializedRequest) throws IOException
decode in class AbstractHandler<byte[]>IOExceptionbyte[] encode(Service.Response response) throws IOException
AbstractHandlerService.Response per the concrete Handler implementation.encode in class AbstractHandler<byte[]>response - The Service.Response to serialize.Service.Response.IOExceptionCopyright © 2012–2017 The Apache Software Foundation. All rights reserved.