@Override public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception { final String local = localAddress == null ? "UNKNOW" : localAddress.toString(); final String remote = remoteAddress == null ? "UNKNOW" : remoteAddress.toString(); LOGGER.info("CLIENT : CONNECT {} => {}", local, remote); super.connect(ctx, remoteAddress, localAddress, promise); if (channelEventListener != null) { assert remoteAddress != null; putRemotingEvent(new RemotingEvent(RemotingEventType.CONNECT, remoteAddress .toString(), new NettyChannel(ctx))); } }
@Override public void sessionOpened(IoSession session) throws Exception { Channel channel = new MinaChannel(session); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("{}: sessionOpened, the channel[{}]", sideType, remoteAddress); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.CONNECT, remoteAddress, channel)); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelInactive, the channel[{}]", remoteAddress); super.channelInactive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelActive, the channel[{}]", remoteAddress); super.channelActive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CONNECT, remoteAddress, channel)); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelInactive, the channel[{}]", remoteAddress); super.channelInactive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override public void sessionOpened(IoSession session) throws Exception { Channel channel = new MinaChannel(session); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("{}: sessionOpened, the channel[{}]", sideType, remoteAddress); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.CONNECT, remoteAddress, channel)); } }
@Override public void sessionClosed(IoSession session) throws Exception { com.github.ltsopensource.remoting.Channel channel = new MinaChannel(session); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("{}: sessionClosed, the channel[{}]", sideType, remoteAddress); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.warn("SERVER: exceptionCaught {}", remoteAddress, cause); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel)); } RemotingHelper.closeChannel(channel); } }
@Override public void channelConnected(NioChannel channel) { Channel ch = new LtsChannel(channel); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ch); LOGGER.info("{}: channelConnected, the channel[{}]", sideType, remoteAddress); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.CONNECT, remoteAddress, ch)); } }
@Override public void sessionClosed(IoSession session) throws Exception { com.github.ltsopensource.remoting.Channel channel = new MinaChannel(session); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("{}: sessionClosed, the channel[{}]", sideType, remoteAddress); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.warn("CLIENT : exceptionCaught {}", remoteAddress); LOGGER.warn("CLIENT : exceptionCaught exception.", cause); closeChannel(channel); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel)); } }
@Override public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("CLIENT : DISCONNECT {}", remoteAddress); closeChannel(channel); super.disconnect(ctx, promise); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override public void exceptionCaught(NioChannel channel, Exception cause) { Channel ch = new LtsChannel(channel); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ch); LOGGER.warn(sideType + ": exceptionCaught {}", remoteAddress, cause); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, ch)); } RemotingHelper.closeChannel(ch); }
@Override public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("CLIENT : DISCONNECT {}", remoteAddress); closeChannel(channel); super.disconnect(ctx, promise); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("CLIENT : CLOSE {}", remoteAddress); closeChannel(channel); super.close(ctx, promise); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override public void exceptionCaught(IoSession session, Throwable cause) throws Exception { com.github.ltsopensource.remoting.Channel channel = new MinaChannel(session); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.warn("{}: exceptionCaught {}. ", sideType, remoteAddress, cause); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel)); } RemotingHelper.closeChannel(channel); }
@Override public void exceptionCaught(NioChannel channel, Exception cause) { Channel ch = new LtsChannel(channel); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ch); LOGGER.warn(sideType + ": exceptionCaught {}", remoteAddress, cause); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, ch)); } RemotingHelper.closeChannel(ch); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.warn("CLIENT : exceptionCaught {}", remoteAddress); LOGGER.warn("CLIENT : exceptionCaught exception.", cause); closeChannel(channel); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel)); } }
@Override public void exceptionCaught(IoSession session, Throwable cause) throws Exception { com.github.ltsopensource.remoting.Channel channel = new MinaChannel(session); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.warn("{}: exceptionCaught {}. ", sideType, remoteAddress, cause); if (remoting.getChannelEventListener() != null) { remoting.putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel)); } RemotingHelper.closeChannel(channel); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("CLIENT : CLOSE {}", remoteAddress); closeChannel(channel); super.close(ctx, promise); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }