/** * Send a deferred response, ignoring errors. */ private void sendDeferedResponse() { try { connection.sendResponse(this); } catch (Exception e) { // For synchronous calls, application code is done once it's returned // from a method. It does not expect to receive an error. // This is equivalent to what happens in synchronous calls when the // Responder is not able to send out the response. LOG.error("Failed to send deferred response. ThreadName=" + Thread .currentThread().getName() + ", CallId=" + callId + ", hostname=" + getHostAddress()); } }
@Override public Void run() throws Exception { if (!connection.channel.isOpen()) { Server.LOG.info(Thread.currentThread().getName() + ": skipped " + this); return null; } Writable value = null; ResponseParams responseParams = new ResponseParams(); try { value = call( rpcKind, connection.protocolName, rpcRequest, timestamp); } catch (Throwable e) { populateResponseParamsOnError(e, responseParams); } if (!isResponseDeferred()) { setupResponse(this, responseParams.returnStatus, responseParams.detailedErr, value, responseParams.errorClass, responseParams.error); sendResponse(); } else { if (LOG.isDebugEnabled()) { LOG.debug("Deferring response for callId: " + this.callId); } } return null; }
@Override void doResponse(Throwable t) throws IOException { RpcCall call = this; if (t != null) { // clone the call to prevent a race with another thread stomping // on the response while being sent. the original call is // effectively discarded since the wait count won't hit zero call = new RpcCall(this); setupResponse(call, RpcStatusProto.FATAL, RpcErrorCodeProto.ERROR_RPC_SERVER, null, t.getClass().getName(), StringUtils.stringifyException(t)); } connection.sendResponse(call); }
sendResponse(); return null;
@Override void doResponse(Throwable t) throws IOException { RpcCall call = this; if (t != null) { // clone the call to prevent a race with another thread stomping // on the response while being sent. the original call is // effectively discarded since the wait count won't hit zero call = new RpcCall(this); setupResponse(call, RpcStatusProto.FATAL, RpcErrorCodeProto.ERROR_RPC_SERVER, null, t.getClass().getName(), StringUtils.stringifyException(t)); } connection.sendResponse(call); }