@Override public void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (e.getMessage() instanceof HttpResponse) { HttpResponse response = (HttpResponse) e.getMessage(); Integer id = ids.poll(); if (id != null && id.intValue() != NO_ID && !response.headers().contains(SpdyHttpHeaders.Names.STREAM_ID)) { SpdyHttpHeaders.setStreamId(response, id); } } super.writeRequested(ctx, e); }
messageReceived(ctx, (MessageEvent) e); } else if (e instanceof WriteCompletionEvent) { WriteCompletionEvent evt = (WriteCompletionEvent) e; writeComplete(ctx, evt); } else if (e instanceof ChildChannelStateEvent) { ChildChannelStateEvent evt = (ChildChannelStateEvent) e; if (evt.getChildChannel().isOpen()) { childChannelOpen(ctx, evt); } else { childChannelClosed(ctx, evt); case OPEN: if (Boolean.TRUE.equals(evt.getValue())) { channelOpen(ctx, evt); } else { channelClosed(ctx, evt); channelBound(ctx, evt); } else { channelUnbound(ctx, evt); channelConnected(ctx, evt); } else { channelDisconnected(ctx, evt); channelInterestChanged(ctx, evt); break; default:
@Override public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { if (e instanceof IdleStateEvent) { channelIdle(ctx, (IdleStateEvent) e); } else { super.handleUpstream(ctx, e); } }
writeRequested(ctx, (MessageEvent) e); } else if (e instanceof ChannelStateEvent) { ChannelStateEvent evt = (ChannelStateEvent) e; case OPEN: if (!Boolean.TRUE.equals(evt.getValue())) { closeRequested(ctx, evt); bindRequested(ctx, evt); } else { unbindRequested(ctx, evt); connectRequested(ctx, evt); } else { disconnectRequested(ctx, evt); setInterestOpsRequested(ctx, evt); break; default:
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (e.getMessage() instanceof HttpMessage) { boolean contains = ((HttpMessage) e.getMessage()).headers().contains(SpdyHttpHeaders.Names.STREAM_ID); if (!contains) { ids.add(NO_ID); } else { ids.add(SpdyHttpHeaders.getStreamId((HttpMessage) e.getMessage())); } } else if (e.getMessage() instanceof SpdyRstStreamFrame) { // remove id from the queue ids.remove(((SpdyRstStreamFrame) e.getMessage()).getStreamId()); } super.messageReceived(ctx, e); }
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { connections.decrementAndGet(); super.channelDisconnected(ctx, e); }
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { // Clean-up the previous encoder if not cleaned up correctly. finishEncode(); super.channelClosed(ctx, e); }
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { checkAttachment(ctx); setWritable(ctx, true); super.channelConnected(ctx, e); }
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { stamp(e.getChannel()); super.channelOpen(ctx, e); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { super.exceptionCaught(ctx, e); logger.error("exceptionCaught", e.getCause()); }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { stamp(e.getChannel()); super.messageReceived(ctx, e); }
@Override public void channelDisconnected(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception { super.channelDisconnected(ctx, e); httpKeepAliveTask.unregisterKeepAliveHandler(this); channel = null; }
/** * Fail all buffered writes that are left. See * <a href="https://github.com/netty/netty/issues/308>#308</a> for more details. */ @Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Throwable cause = null; for (;;) { MessageEvent ev = queue.poll(); if (ev == null) { break; } if (cause == null) { cause = new ClosedChannelException(); } ev.getFuture().setFailure(cause); } if (cause != null) { Channels.fireExceptionCaught(ctx.getChannel(), cause); } super.channelClosed(ctx, e); }
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { connections.incrementAndGet(); totalConnections++; super.channelConnected(ctx, e); }
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { super.channelOpen(ctx, e); ctx.getPipeline().remove(this); } };
@Override public void exceptionCaught(final ChannelHandlerContext ctx, final ExceptionEvent evt) throws Exception { super.exceptionCaught(ctx, evt); s_logger.log(Level.WARNING, "Handler raised exception", evt.getCause()); } }
@Override public void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws Exception { super.writeRequested(ctx, e); NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler); try { handler.sent(channel, e.getMessage()); } finally { NettyChannel.removeChannelIfDisconnected(ctx.getChannel()); } }
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent evt) throws Exception { synchronized(this) { m_messageTriggeredException = false; } super.messageReceived(ctx, evt); }
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { if (DEBUG) { log.info("Channel disconnected: " + e.getChannel().toString()); } super.channelDisconnected(ctx, e); }
@Override public void channelClosed(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception { if (task != null) { task.close(); } super.channelClosed(ctx, e); }