public TransportRequestHandler( Channel channel, TransportClient reverseClient, RpcHandler rpcHandler) { this.channel = channel; this.reverseClient = reverseClient; this.rpcHandler = rpcHandler; this.streamManager = rpcHandler.getStreamManager(); }
@Override public void channelUnregistered() { if (streamManager != null) { try { streamManager.connectionTerminated(channel); } catch (RuntimeException e) { logger.error("StreamManager connectionTerminated() callback failed.", e); } } rpcHandler.connectionTerminated(reverseClient); }
private void processRpcRequest(final RpcRequest req) { try { rpcHandler.receive( reverseClient, req.message, new RpcResponseCallback() { @Override public void onSuccess(byte[] response) { respond(new RpcResponse(req.requestId, response)); } @Override public void onFailure(Throwable e) { respond(new RpcFailure(req.requestId, Throwables.getStackTraceAsString(e))); } }); } catch (Exception e) { logger.error("Error while invoking RpcHandler#receive() on RPC id " + req.requestId, e); respond(new RpcFailure(req.requestId, Throwables.getStackTraceAsString(e))); } }
@Override public void exceptionCaught(Throwable cause) { rpcHandler.exceptionCaught(cause, reverseClient); }