@Override public void channelActive(ChannelHandlerContext ctx) { component.setCustomMDC(); try { component.extLog.trace("Channel connected: {} {} => {} ({})", new Object[]{protocol, ctx.channel().localAddress(), ctx.channel().remoteAddress(), ctx.channel()}); } finally { MDC.clear(); } }
@Override public void run() { setCustomMDC(); try { channels.monitor(); } finally { MDC.clear(); } } }, monitoringInterval, monitoringInterval, TimeUnit.MILLISECONDS
@Override public void run() { setCustomMDC(); try { channels.monitor(); } finally { MDC.clear(); } } }, monitoringInterval, monitoringInterval, TimeUnit.MILLISECONDS);
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { ByteBuf frame = (ByteBuf) super.decode(ctx, in); if (frame == null) { return null; } component.setCustomMDC(); try { component.extLog.trace("Trying to decode incoming {} bytes of data from {} to {}.", new Object[]{frame.readableBytes(), ctx.channel().remoteAddress(), ctx.channel().localAddress()}); Object o = Serializers.fromBinary(frame, Optional.absent()); component.extLog.trace("Decoded incoming data from {}: {}", ctx.channel().remoteAddress(), o); if (o instanceof AckRequestMsg) { AckRequestMsg arm = (AckRequestMsg) o; component.extLog.trace("Got AckRequest for {}. Replying...", arm.id); NotifyAck an = arm.reply(); ctx.channel().writeAndFlush(new MessageWrapper(an)); return arm.content; } else if (o instanceof Msg) { return o; } else { component.extLog.warn("Got unexpected Stream message type: {} -> {}", o.getClass().getCanonicalName(), o); } return o; } finally { MDC.clear(); } }
@Override public void operationComplete(ChannelFuture future) throws Exception { component.setCustomMDC(); try { if (future.isSuccess()) { notify.prepareResponse(System.currentTimeMillis(), true, System.nanoTime()); if (notify.notifyOfDelivery) { awaitingDelivery.put(notify.getMsgId(), notify); } } else { component.extLog.warn("Sending of message {} did not succeed :( : {}", notify.msg, future.cause()); notify.prepareResponse(System.currentTimeMillis(), false, System.nanoTime()); } component.notify(notify); } finally { MDC.clear(); } } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { component.setCustomMDC(); try { Channel channel = ctx.channel(); SocketAddress address = channel.remoteAddress(); InetSocketAddress inetAddress = null; if (address != null && address instanceof InetSocketAddress) { inetAddress = (InetSocketAddress) address; Address addr = new NettyAddress(inetAddress); component.networkException(new NetworkException("Error in Channel handler to " + addr, addr, protocol, Optional.of(cause))); } component.extLog.error("Error in channel.", cause); //cause.printStackTrace(); component.extLog.error("Closing channel {} due to error.", channel); channel.close(); } finally { MDC.clear(); } } }
@Override protected void encode(ChannelHandlerContext ctx, MessageWrapper msgw, List<Object> outL) throws Exception { component.setCustomMDC(); try {
@Override protected void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { component.setCustomMDC(); try { Object o = Serializers.fromBinary(msg.content(), msg); if (o instanceof AckRequestMsg) { AckRequestMsg arm = (AckRequestMsg) o; ByteBuf buf = ctx.alloc().ioBuffer(NettyNetwork.INITIAL_BUFFER_SIZE, NettyNetwork.SEND_BUFFER_SIZE); component.deliverMessage(arm.content, ctx.channel()); component.extLog.trace("Got AckRequest for {}. Replying...", arm.id); NotifyAck ack = arm.reply(); Serializers.toBinary(ack, buf); DatagramPacket pack = new DatagramPacket(buf, ack.getDestination().asSocket()); component.extLog.trace("Sending Datagram ACK {} ({}bytes)", ack, buf.readableBytes()); ctx.writeAndFlush(pack); } else if (o instanceof Msg) { Msg m = (Msg) o; component.deliverMessage(m, ctx.channel()); } else { component.extLog.warn("Got unexpected Datagram message type: {} -> {}", o.getClass().getCanonicalName(), o); } } catch (Exception e) { // Catch anything...the Serializer could throw any kind of weird exception if you get message that were send by someone else component.extLog.warn("Got weird Datagram message, ignoring it: {}", ByteBufUtil.hexDump(msg.content())); component.extLog.trace("Exception was: \n{}", e); } finally { MDC.clear(); } }
@Override public void operationComplete(ChannelFuture future) throws Exception { synchronized (ChannelManager.this) { component.setCustomMDC(); try { tcpIncompleteChannels.remove(destination.asSocket());
void channelInactive(ChannelHandlerContext ctx, Transport protocol) { component.setCustomMDC(); try { SocketAddress addr = ctx.channel().remoteAddress();
@Override public void operationComplete(ChannelFuture future) throws Exception { synchronized (ChannelManager.this) { component.setCustomMDC(); try { udtIncompleteChannels.remove(destination.asSocket());
component.setCustomMDC(); try { SocketChannel activeC = tcpActiveChannels.get(msg.getSource().asSocket());
component.setCustomMDC(); try { UdtChannel activeC = udtActiveChannels.get(msg.getSource().asSocket());
void checkActive(CheckChannelActive msg, Channel c) { synchronized (this) { component.setCustomMDC(); try { if (c instanceof SocketChannel) {
void disambiguate(DisambiguateConnection msg, Channel c) { synchronized (this) { if (c.isActive()) { // might have been closed by the time we get the lock? component.setCustomMDC(); try { component.extLog.debug("Handling Disamb: {} on {}", msg, c);
void flushAndClose(CloseChannel msg, Channel c) { synchronized (this) { component.setCustomMDC(); try { if (c instanceof SocketChannel) {