@Override public void messageReceived(NioChannel channel, Object msg) throws Exception { if (msg != null && msg instanceof RemotingCommand) { remoting.processMessageReceived(new LtsChannel(channel), (RemotingCommand) msg); } }
@Override public Channel getChannel() { return new LtsChannel(future.channel()); }
@Override public void messageReceived(NioChannel channel, Object msg) throws Exception { if (msg != null && msg instanceof RemotingCommand) { remoting.processMessageReceived(new LtsChannel(channel), (RemotingCommand) msg); } }
@Override public Channel getChannel() { return new LtsChannel(future.channel()); }
@Override protected Object decode(NioChannel ch, byte[] frame) throws Exception { ByteBuffer byteBuffer = ByteBuffer.wrap(frame); try { return codec.decode(byteBuffer); } catch (Exception e) { Channel channel = new LtsChannel(ch); LOGGER.error("decode exception, {}", RemotingHelper.parseChannelRemoteAddr(channel), e); RemotingHelper.closeChannel(channel); throw e; } } }
@Override protected Object decode(NioChannel ch, byte[] frame) throws Exception { ByteBuffer byteBuffer = ByteBuffer.wrap(frame); try { return codec.decode(byteBuffer); } catch (Exception e) { Channel channel = new LtsChannel(ch); LOGGER.error("decode exception, {}", RemotingHelper.parseChannelRemoteAddr(channel), e); RemotingHelper.closeChannel(channel); throw e; } } }
@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 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 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(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 ByteBuffer encode(NioChannel channel, Object msg) { if (msg == null) { LOGGER.error("Message is null"); return null; } if (msg instanceof RemotingCommand) { try { return codec.encode((RemotingCommand) msg); } catch (Exception e) { Channel c = new LtsChannel(channel); LOGGER.error("encode exception, addr={}, remotingCommand={}", RemotingHelper.parseChannelRemoteAddr(c), ((RemotingCommand) msg).toString(), e); RemotingHelper.closeChannel(c); } } else { LOGGER.error("Message is not instance of " + RemotingCommand.class.getName()); } return null; } }
@Override public ByteBuffer encode(NioChannel channel, Object msg) { if (msg == null) { LOGGER.error("Message is null"); return null; } if (msg instanceof RemotingCommand) { try { return codec.encode((RemotingCommand) msg); } catch (Exception e) { Channel c = new LtsChannel(channel); LOGGER.error("encode exception, addr={}, remotingCommand={}", RemotingHelper.parseChannelRemoteAddr(c), ((RemotingCommand) msg).toString(), e); RemotingHelper.closeChannel(c); } } else { LOGGER.error("Message is not instance of " + RemotingCommand.class.getName()); } return null; } }
return; com.github.ltsopensource.remoting.Channel ch = new LtsChannel(channel);
return; com.github.ltsopensource.remoting.Channel ch = new LtsChannel(channel);
@Override public void messageReceived(NioChannel channel, Object msg) throws Exception { if (msg != null && msg instanceof RemotingCommand) { remoting.processMessageReceived(new LtsChannel(channel), (RemotingCommand) msg); } }
@Override public Channel getChannel() { return new LtsChannel(future.channel()); }
@Override protected Object decode(NioChannel ch, byte[] frame) throws Exception { ByteBuffer byteBuffer = ByteBuffer.wrap(frame); try { return codec.decode(byteBuffer); } catch (Exception e) { Channel channel = new LtsChannel(ch); LOGGER.error("decode exception, {}", RemotingHelper.parseChannelRemoteAddr(channel), e); RemotingHelper.closeChannel(channel); throw e; } } }
@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 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 ByteBuffer encode(NioChannel channel, Object msg) { if (msg == null) { LOGGER.error("Message is null"); return null; } if (msg instanceof RemotingCommand) { try { return codec.encode((RemotingCommand) msg); } catch (Exception e) { Channel c = new LtsChannel(channel); LOGGER.error("encode exception, addr={}, remotingCommand={}", RemotingHelper.parseChannelRemoteAddr(c), ((RemotingCommand) msg).toString(), e); RemotingHelper.closeChannel(c); } } else { LOGGER.error("Message is not instance of " + RemotingCommand.class.getName()); } return null; } }