protected void tryToFinishOffChannel(Channel channel) { Pair<RequestContext, AtomicLong> slave; slave = unmapSlave(channel); if (slave == null) { return; } tryToFinishOffChannel(channel, slave.first()); }
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { super.channelDisconnected(ctx, e); if (!ctx.getChannel().isConnected()) { tryToFinishOffChannel(ctx.getChannel()); } }
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { super.channelClosed(ctx, e); if (!ctx.getChannel().isOpen()) { tryToFinishOffChannel(ctx.getChannel()); } channelGroup.remove(e.getChannel()); }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception { try { ChannelBuffer message = (ChannelBuffer) event.getMessage(); handleRequest(message, event.getChannel()); } catch (Throwable e) { msgLog.error("Error handling request", e); // Attempt to reply to the client ChunkingChannelBuffer buffer = newChunkingBuffer(event.getChannel()); buffer.clear(/* failure = */ true); writeFailureResponse(e, buffer); ctx.getChannel().close(); tryToFinishOffChannel(ctx.getChannel()); throw Exceptions.launderedException(e); } }