Merge "MD-SAL StatisticsManager- Stopping statistics thread until i fix all the relev...
[controller.git] / opendaylight / netconf / netconf-util / src / main / java / org / opendaylight / controller / netconf / util / handler / ChunkedFramingMechanismEncoder.java
index 7f710c9f1981fe2feed007aa12cb716075254d23..d8dd7881653b466b24886da068f1d6bab529027b 100644 (file)
@@ -8,10 +8,8 @@
 
 package org.opendaylight.controller.netconf.util.handler;
 
-import org.opendaylight.controller.netconf.util.messages.NetconfMessageFactory;
+import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants;
 import org.opendaylight.controller.netconf.util.messages.NetconfMessageHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -20,27 +18,25 @@ import io.netty.handler.codec.MessageToByteEncoder;
 
 public class ChunkedFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf> {
 
-    private final static Logger logger = LoggerFactory.getLogger(ChunkedFramingMechanismEncoder.class);
-
     private NetconfMessageHeader messageHeader = new NetconfMessageHeader();
 
+    private final static int MAX_CHUNK_SIZE = NetconfMessageConstants.MAX_CHUNK_SIZE;
+
     @Override
     protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception {
-        while (msg.readableBytes() > NetconfMessageFactory.MAX_CHUNK_SIZE) {
-            ByteBuf chunk = Unpooled.buffer(NetconfMessageFactory.MAX_CHUNK_SIZE);
-            chunk.writeBytes(createChunkHeader(NetconfMessageFactory.MAX_CHUNK_SIZE));
-            chunk.writeBytes(msg.readBytes(NetconfMessageFactory.MAX_CHUNK_SIZE));
+        while (msg.readableBytes() > MAX_CHUNK_SIZE) {
+            ByteBuf chunk = Unpooled.buffer(MAX_CHUNK_SIZE);
+            chunk.writeBytes(createChunkHeader(MAX_CHUNK_SIZE));
+            chunk.writeBytes(msg.readBytes(MAX_CHUNK_SIZE));
             ctx.write(chunk);
         }
         out.writeBytes(createChunkHeader(msg.readableBytes()));
         out.writeBytes(msg.readBytes(msg.readableBytes()));
-        out.writeBytes(NetconfMessageFactory.endOfChunk);
-        logger.debug("Output message size is {}", out.readableBytes());
+        out.writeBytes(NetconfMessageConstants.endOfChunk);
     }
 
     private ByteBuf createChunkHeader(int chunkSize) {
         messageHeader.setLength(chunkSize);
-        logger.debug("Chunked data length is {}.", chunkSize);
         return Unpooled.wrappedBuffer(messageHeader.toBytes());
     }