mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-20 11:52:12 +02:00
Added logging to netty
This commit is contained in:
parent
ce2a9586b4
commit
29e5dfd82b
@ -8,11 +8,16 @@ import io.netty.handler.codec.ReplayingDecoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Decoder for inbound messages.
|
||||
*/
|
||||
public class MessageDecoder extends ReplayingDecoder<DecoderState> {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final NettyMessagingService messagingService;
|
||||
|
||||
private static final KryoSerializer SERIALIZER = new KryoSerializer();
|
||||
@ -57,4 +62,10 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> {
|
||||
checkState(false, "Must not be here");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext context, Throwable cause) {
|
||||
log.error("Exception inside channel handling pipeline.", cause);
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.onlab.netty;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -11,6 +14,8 @@ import io.netty.handler.codec.MessageToByteEncoder;
|
||||
@Sharable
|
||||
public class MessageEncoder extends MessageToByteEncoder<InternalMessage> {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
// onosiscool in ascii
|
||||
public static final byte[] PREAMBLE = "onosiscool".getBytes();
|
||||
public static final int HEADER_VERSION = 1;
|
||||
@ -47,4 +52,10 @@ public class MessageEncoder extends MessageToByteEncoder<InternalMessage> {
|
||||
// write payload.
|
||||
out.writeBytes(payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext context, Throwable cause) {
|
||||
log.error("Exception inside channel handling pipeline.", cause);
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
@ -248,6 +248,7 @@ public class NettyMessagingService implements MessagingService {
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext context, Throwable cause) {
|
||||
log.error("Exception inside channel handling pipeline.", cause);
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user