@Override public Channel getChannel() { return new NettyChannel(channelFuture.channel()); }
@Override public boolean isClosed() { return !isOpen(); }
@Override public Channel getChannel() { return new NettyChannel(channelFuture.channel()); }
@Override public boolean isClosed() { return !isOpen(); }
@Override protected void channelRead0(ChannelHandlerContext ctx, RemotingCommand msg) throws Exception { processMessageReceived(new NettyChannel(ctx), msg); } }
@Override public boolean isClosed() { return !isOpen(); }
@Override protected void channelRead0(ChannelHandlerContext ctx, RemotingCommand msg) throws Exception { processMessageReceived(new NettyChannel(ctx), msg); } }
@Override protected void channelRead0(ChannelHandlerContext ctx, RemotingCommand msg) throws Exception { processMessageReceived(new NettyChannel(ctx), msg); } }
@Override protected void channelRead0(ChannelHandlerContext ctx, RemotingCommand msg) throws Exception { processMessageReceived(new NettyChannel(ctx), msg); } }
@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 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 channelUnregistered(ChannelHandlerContext ctx) throws Exception { final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(new NettyChannel(ctx)); LOGGER.info("SERVER : channelUnregistered, the channel[{}]", remoteAddress); super.channelUnregistered(ctx); }
@Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(new NettyChannel(ctx)); LOGGER.info("SERVER : channelUnregistered, the channel[{}]", remoteAddress); super.channelUnregistered(ctx); }
@Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(new NettyChannel(ctx)); LOGGER.info("SERVER : channelRegistered {}", remoteAddress); super.channelRegistered(ctx); }
@Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(new NettyChannel(ctx)); LOGGER.info("SERVER : channelRegistered {}", remoteAddress); super.channelRegistered(ctx); }
@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 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 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 encode(ChannelHandlerContext ctx, RemotingCommand remotingCommand, ByteBuf out) throws Exception { if (remotingCommand == null) { LOGGER.error("Message is null"); return; } try { ByteBuffer byteBuffer = codec.encode(remotingCommand); out.writeBytes(byteBuffer); } catch (Exception e) { Channel channel = new NettyChannel(ctx); LOGGER.error("encode exception, addr={}, remotingCommand={}", RemotingHelper.parseChannelRemoteAddr(channel), remotingCommand.toString(), e); RemotingHelper.closeChannel(channel); } } }