X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fhandler%2FNetconfMessageAggregator.java;h=a2486050f9368e7ff37314a1e65e38e7134406ed;hp=131c3d71a57c9df779302ca4ff352e10f53841e6;hb=6fd408a04fe4a3611843e2246ece6d7c34b76903;hpb=e6bcd06e610be274e8f2df901b61789bb17c442a diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageAggregator.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageAggregator.java index 131c3d71a5..a2486050f9 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageAggregator.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageAggregator.java @@ -8,26 +8,26 @@ package org.opendaylight.controller.netconf.util.handler; -import java.util.List; - +import com.google.common.base.Charsets; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.ByteToMessageDecoder; import org.opendaylight.controller.netconf.util.messages.FramingMechanism; -import org.opendaylight.controller.netconf.util.messages.NetconfMessageFactory; +import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; +import java.util.List; public class NetconfMessageAggregator extends ByteToMessageDecoder { private final static Logger logger = LoggerFactory.getLogger(NetconfMessageAggregator.class); - private byte[] eom = NetconfMessageFactory.endOfMessage; + private byte[] eom = NetconfMessageConstants.endOfMessage; public NetconfMessageAggregator(FramingMechanism framingMechanism) { if (framingMechanism == FramingMechanism.CHUNK) { - eom = NetconfMessageFactory.endOfChunk; + eom = NetconfMessageConstants.endOfChunk; } } @@ -35,13 +35,17 @@ public class NetconfMessageAggregator extends ByteToMessageDecoder { protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { int index = indexOfSequence(in, eom); if (index == -1) { - logger.debug("Message is not complete, read agian."); + logger.debug("Message is not complete, read again."); + if (logger.isTraceEnabled()) { + String str = in.toString(Charsets.UTF_8); + logger.trace("Message read so far: {}", str); + } ctx.read(); } else { ByteBuf msg = in.readBytes(index); in.readBytes(eom.length); in.discardReadBytes(); - logger.debug("Message is complete. {}", msg.readableBytes()); + logger.debug("Message is complete."); out.add(msg); } }