Search in sources :

Example 1 with MethodDescriptor

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.MethodDescriptor in project hbase by apache.

the class RpcServer method call.

/**
   * This is a server side method, which is invoked over RPC. On success
   * the return response has protobuf response payload. On failure, the
   * exception name and the stack trace are returned in the protobuf response.
   */
@Override
public Pair<Message, CellScanner> call(RpcCall call, MonitoredRPCHandler status) throws IOException {
    try {
        MethodDescriptor md = call.getMethod();
        Message param = call.getParam();
        status.setRPC(md.getName(), new Object[] { param }, call.getReceiveTime());
        // TODO: Review after we add in encoded data blocks.
        status.setRPCPacket(param);
        status.resume("Servicing call");
        //get an instance of the method arg type
        HBaseRpcController controller = new HBaseRpcControllerImpl(call.getCellScanner());
        controller.setCallTimeout(call.getTimeout());
        Message result = call.getService().callBlockingMethod(md, controller, param);
        long receiveTime = call.getReceiveTime();
        long startTime = call.getStartTime();
        long endTime = System.currentTimeMillis();
        int processingTime = (int) (endTime - startTime);
        int qTime = (int) (startTime - receiveTime);
        int totalTime = (int) (endTime - receiveTime);
        if (LOG.isTraceEnabled()) {
            LOG.trace(CurCall.get().toString() + ", response " + TextFormat.shortDebugString(result) + " queueTime: " + qTime + " processingTime: " + processingTime + " totalTime: " + totalTime);
        }
        // Use the raw request call size for now.
        long requestSize = call.getSize();
        long responseSize = result.getSerializedSize();
        if (call.isClientCellBlockSupported()) {
            // Include the payload size in HBaseRpcController
            responseSize += call.getResponseCellSize();
        }
        metrics.dequeuedCall(qTime);
        metrics.processedCall(processingTime);
        metrics.totalCall(totalTime);
        metrics.receivedRequest(requestSize);
        metrics.sentResponse(responseSize);
        // log any RPC responses that are slower than the configured warn
        // response time or larger than configured warning size
        boolean tooSlow = (processingTime > warnResponseTime && warnResponseTime > -1);
        boolean tooLarge = (responseSize > warnResponseSize && warnResponseSize > -1);
        if (tooSlow || tooLarge) {
            // when tagging, we let TooLarge trump TooSmall to keep output simple
            // note that large responses will often also be slow.
            logResponse(param, md.getName(), md.getName() + "(" + param.getClass().getName() + ")", (tooLarge ? "TooLarge" : "TooSlow"), status.getClient(), startTime, processingTime, qTime, responseSize);
        }
        return new Pair<>(result, controller.cellScanner());
    } catch (Throwable e) {
        // need to pass it over the wire.
        if (e instanceof ServiceException) {
            if (e.getCause() == null) {
                LOG.debug("Caught a ServiceException with null cause", e);
            } else {
                e = e.getCause();
            }
        }
        // increment the number of requests that were exceptions.
        metrics.exception(e);
        if (e instanceof LinkageError)
            throw new DoNotRetryIOException(e);
        if (e instanceof IOException)
            throw (IOException) e;
        LOG.error("Unexpected throwable object ", e);
        throw new IOException(e.getMessage(), e);
    }
}
Also used : Message(org.apache.hadoop.hbase.shaded.com.google.protobuf.Message) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) MethodDescriptor(org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.MethodDescriptor) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) Pair(org.apache.hadoop.hbase.util.Pair)

Aggregations

IOException (java.io.IOException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 MethodDescriptor (org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.MethodDescriptor)1 Message (org.apache.hadoop.hbase.shaded.com.google.protobuf.Message)1 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)1 Pair (org.apache.hadoop.hbase.util.Pair)1