Search in sources :

Example 6 with Message

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

the class CallRunner method run.

public void run() {
    try {
        if (call.disconnectSince() >= 0) {
            if (RpcServer.LOG.isDebugEnabled()) {
                RpcServer.LOG.debug(Thread.currentThread().getName() + ": skipped " + call);
            }
            return;
        }
        call.setStartTime(System.currentTimeMillis());
        if (call.getStartTime() > call.getDeadline()) {
            RpcServer.LOG.warn("Dropping timed out call: " + call);
            return;
        }
        this.status.setStatus("Setting up call");
        this.status.setConnection(call.getRemoteAddress().getHostAddress(), call.getRemotePort());
        if (RpcServer.LOG.isTraceEnabled()) {
            User remoteUser = call.getRequestUser();
            RpcServer.LOG.trace(call.toShortString() + " executing as " + ((remoteUser == null) ? "NULL principal" : remoteUser.getName()));
        }
        Throwable errorThrowable = null;
        String error = null;
        Pair<Message, CellScanner> resultPair = null;
        RpcServer.CurCall.set(call);
        TraceScope traceScope = null;
        try {
            if (!this.rpcServer.isStarted()) {
                InetSocketAddress address = rpcServer.getListenerAddress();
                throw new ServerNotRunningYetException("Server " + (address != null ? address : "(channel closed)") + " is not running yet");
            }
            if (call.getTraceInfo() != null) {
                String serviceName = call.getService() != null ? call.getService().getDescriptorForType().getName() : "";
                String methodName = (call.getMethod() != null) ? call.getMethod().getName() : "";
                String traceString = serviceName + "." + methodName;
                traceScope = Trace.startSpan(traceString, call.getTraceInfo());
            }
            // make the call
            resultPair = this.rpcServer.call(call, this.status);
        } catch (TimeoutIOException e) {
            RpcServer.LOG.warn("Can not complete this request in time, drop it: " + call);
            return;
        } catch (Throwable e) {
            RpcServer.LOG.debug(Thread.currentThread().getName() + ": " + call.toShortString(), e);
            errorThrowable = e;
            error = StringUtils.stringifyException(e);
            if (e instanceof Error) {
                throw (Error) e;
            }
        } finally {
            if (traceScope != null) {
                traceScope.close();
            }
            RpcServer.CurCall.set(null);
            if (resultPair != null) {
                this.rpcServer.addCallSize(call.getSize() * -1);
                sucessful = true;
            }
        }
        // return back the RPC request read BB we can do here. It is done by now.
        call.cleanup();
        // Set the response
        Message param = resultPair != null ? resultPair.getFirst() : null;
        CellScanner cells = resultPair != null ? resultPair.getSecond() : null;
        call.setResponse(param, cells, errorThrowable, error);
        call.sendResponseIfReady();
        this.status.markComplete("Sent response");
        this.status.pause("Waiting for a call");
    } catch (OutOfMemoryError e) {
        if (this.rpcServer.getErrorHandler() != null) {
            if (this.rpcServer.getErrorHandler().checkOOME(e)) {
                RpcServer.LOG.info(Thread.currentThread().getName() + ": exiting on OutOfMemoryError");
                return;
            }
        } else {
            // rethrow if no handler
            throw e;
        }
    } catch (ClosedChannelException cce) {
        InetSocketAddress address = rpcServer.getListenerAddress();
        RpcServer.LOG.warn(Thread.currentThread().getName() + ": caught a ClosedChannelException, " + "this means that the server " + (address != null ? address : "(channel closed)") + " was processing a request but the client went away. The error message was: " + cce.getMessage());
    } catch (Exception e) {
        RpcServer.LOG.warn(Thread.currentThread().getName() + ": caught: " + StringUtils.stringifyException(e));
    } finally {
        if (!sucessful) {
            this.rpcServer.addCallSize(call.getSize() * -1);
        }
        cleanup();
    }
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) User(org.apache.hadoop.hbase.security.User) Message(org.apache.hadoop.hbase.shaded.com.google.protobuf.Message) InetSocketAddress(java.net.InetSocketAddress) TraceScope(org.apache.htrace.TraceScope) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) CellScanner(org.apache.hadoop.hbase.CellScanner) ClosedChannelException(java.nio.channels.ClosedChannelException) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) CallDroppedException(org.apache.hadoop.hbase.CallDroppedException)

Aggregations

Message (org.apache.hadoop.hbase.shaded.com.google.protobuf.Message)6 IOException (java.io.IOException)3 CellScanner (org.apache.hadoop.hbase.CellScanner)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 Builder (org.apache.hadoop.hbase.shaded.com.google.protobuf.Message.Builder)2 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)2 ExceptionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.ExceptionResponse)2 ResponseHeader (org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.ResponseHeader)2 RemoteException (org.apache.hadoop.ipc.RemoteException)2 ByteBufInputStream (io.netty.buffer.ByteBufInputStream)1 InterruptedIOException (java.io.InterruptedIOException)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1 CallDroppedException (org.apache.hadoop.hbase.CallDroppedException)1 TimeoutIOException (org.apache.hadoop.hbase.exceptions.TimeoutIOException)1 IPCUtil.createRemoteException (org.apache.hadoop.hbase.ipc.IPCUtil.createRemoteException)1 User (org.apache.hadoop.hbase.security.User)1 MethodDescriptor (org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.MethodDescriptor)1 Pair (org.apache.hadoop.hbase.util.Pair)1