@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { super.channelInactive(ctx); LOGGER.info("channel inactive for ClientProxyHandler at :[{}]",ctx.channel()); }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { super.channelActive(ctx); LOGGER.info("channel active for ClientProxyHandler at :[{}]",ctx.channel()); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (LOG.isTraceEnabled()) { promise.addListener((future) -> { LOG.trace("write {}", future.isSuccess() ? "complete" : "failed"); }); } super.write(ctx, msg, promise); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { // read message and track if it was keepAlive if (msg instanceof HttpRequest) { final HttpRequest request = (HttpRequest) msg; if (persistentConnection) { pendingResponses += 1; persistentConnection = isKeepAlive(request); } } super.channelRead(ctx, msg); }
@Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { if (State.ChannelSubscribed == state) { super.channelRegistered(ctx); } else { state = State.Registered; } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise future) throws Exception { if (LOGGER.isInfoEnabled()) { LOGGER.info(ctx + " will closed"); } super.close(ctx, future); }
@Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { if (State.ChannelSubscribed == state) { super.channelUnregistered(ctx); } else { unregistered = true; } }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { // Track when there's an inflight request. if (evt instanceof HttpLifecycleChannelHandler.StartEvent) { requestInflight.set(Boolean.TRUE); } else if (evt instanceof HttpLifecycleChannelHandler.CompleteEvent) { requestInflight.set(Boolean.FALSE); } super.userEventTriggered(ctx, evt); }
@Override public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception { logger.trace(format(ctx, "CONNECT(" + remoteAddress + ", " + localAddress + ')')); super.connect(ctx, remoteAddress, localAddress, promise); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { inPackets.incrementAndGet(); if (msg instanceof ByteBuf) { inSize.addAndGet(((ByteBuf) msg).readableBytes()); } else if (msg instanceof DatagramPacket) { inSize.addAndGet(((DatagramPacket) msg).content().readableBytes()); } super.channelRead(ctx, msg); }
@Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { // Initialize early if channel is active already. if (ctx.channel().isActive()) { initialize(ctx); } super.channelRegistered(ctx); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { updatePromise(ctx, "closed"); super.close(ctx, promise); }
@Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { logger.trace(format(ctx, "UNREGISTERED")); super.channelUnregistered(ctx); }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof PooledConnectionReleaseEvent) { cancelTimeoutSchedule(ctx); } super.userEventTriggered(ctx, evt); }
@Override public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception { final String local = localAddress == null ? "UNKNOWN" : RemoteHelper.parseSocketAddressAddress(localAddress); final String remote = remoteAddress == null ? "UNKNOWN" : RemoteHelper.parseSocketAddressAddress(remoteAddress); LOGGER.debug("NettyConnectManageHandler", "NETTY CLIENT PIPELINE: CONNECT {} => {}", local, remote); super.connect(ctx, remoteAddress, localAddress, promise); }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { destroy(); super.channelInactive(ctx); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { super.write(ctx, msg, promise); NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(), url, handler); try { handler.sent(channel, msg); } finally { NettyChannel.removeChannelIfDisconnected(ctx.channel()); } }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { // This method will be invoked only if this handler was added // before channelActive() event is fired. If a user adds this handler // after the channelActive() event, initialize() will be called by beforeAdd(). initialize(ctx); super.channelActive(ctx); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { log(ctx, false, msg); super.channelRead(ctx, msg); }
@Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { setUserDefinedWritability(ctx, true); super.channelRegistered(ctx); }