org.apache.calcite.avatica.remote

## Class ProtobufHandler

- java.lang.Object
- - org.apache.calcite.avatica.remote.AbstractHandler<byte[]>
  - - org.apache.calcite.avatica.remote.ProtobufHandler

All Implemented Interfaces:
  Handler<byte[]>

    public class ProtobufHandler
    extends AbstractHandler<byte[]>

Dispatches serialized protocol buffer messages to the provided `Service` by converting them to the POJO Request. Returns back the serialized protocol buffer response.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.calcite.avatica.remote.Handler

`Handler.HandlerResponse<T>`

### Field Summary

Fields
`private MetricsSystem` `metrics`
`private Timer` `serializationTimer`
`private ProtobufTranslation` `translation`

### Fields inherited from class org.apache.calcite.avatica.remote.AbstractHandler

`service`

### Fields inherited from interface org.apache.calcite.avatica.remote.Handler

`HANDLER_SERIALIZATION_METRICS_NAME, HTTP_INTERNAL_SERVER_ERROR, HTTP_OK, HTTP_UNAUTHENTICATED, HTTP_UNAUTHORIZED`

### Constructor Summary

Constructors
Constructor and Description
`ProtobufHandler(Service service, ProtobufTranslation translation, MetricsSystem metrics)`

### Method Summary

All Methods Instance Methods Concrete Methods
`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.

### Methods inherited from class org.apache.calcite.avatica.remote.AbstractHandler

`convertToErrorResponse, setRpcMetadata, unauthenticatedErrorResponse, unauthorizedErrorResponse, unwrapException`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### translation

    private final ProtobufTranslation translation

#### metrics

    private final MetricsSystem metrics

#### serializationTimer

    private final Timer serializationTimer

### Constructor Detail

#### ProtobufHandler

    public ProtobufHandler(Service service,
                           ProtobufTranslation translation,
                           MetricsSystem metrics)

### Method Detail

#### apply

    public Handler.HandlerResponse<byte[]> apply(byte[] requestBytes)

Description copied from class: `AbstractHandler`
Compute a response for the given request, handling errors generated by that computation.

Specified by:
  `apply` in interface `Handler<byte[]>`
Overrides:
  `apply` in class `AbstractHandler<byte[]>`
Parameters:
  `requestBytes` - The caller's request.
Returns:
  A `Service.Response` with additional context about that response.

#### decode

    Service.Request decode(byte[] serializedRequest)
                    throws IOException

Specified by:
  `decode` in class `AbstractHandler<byte[]>`
Throws:
  `IOException`

#### encode

    byte[] encode(Service.Response response)
           throws IOException

Description copied from class: `AbstractHandler`
Serialize the given `Service.Response` per the concrete `Handler` implementation.

Specified by:
  `encode` in class `AbstractHandler<byte[]>`
Parameters:
  `response` - The `Service.Response` to serialize.
Returns:
  A serialized representation of the `Service.Response`.
Throws:
  `IOException`