BGP.parser.impl.messages: minor changes 74/22274/4
authorIveta Halanova <iveta.halanova@pantheon.sk>
Tue, 9 Jun 2015 08:18:05 +0000 (10:18 +0200)
committerIveta Halanova <iveta.halanova@pantheon.sk>
Thu, 11 Jun 2015 11:36:29 +0000 (13:36 +0200)
KeepaliveMsgParser - made final
NotifyMsgParser:
- Log just-built ByteBuf
- Reordered line - getData()
OpenMsgParser - log just-built ByteBuf
UpdateMsgParser - made final

Change-Id: I09283ee4505dfa5f8c747d7bfc12fc6a701efa96
Signed-off-by: Iveta Halanova <iveta.halanova@pantheon.sk>
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPKeepAliveMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPNotificationMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPOpenMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPUpdateMessageParser.java

index 2d6cb7cc0403d236694c9910d37dd16d22a7f14a..0898497766b53eb62cef6c9588f3345f6e0bd9e6 100644 (file)
@@ -8,10 +8,8 @@
 package org.opendaylight.protocol.bgp.parser.impl.message;
 
 import com.google.common.base.Preconditions;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
 import org.opendaylight.protocol.bgp.parser.spi.MessageSerializer;
@@ -20,7 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.KeepaliveBuilder;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
-public class BGPKeepAliveMessageParser implements MessageParser, MessageSerializer {
+public final class BGPKeepAliveMessageParser implements MessageParser, MessageSerializer {
     public static final int TYPE = 4;
     private static final Keepalive KEEPALIVE_MSG = new KeepaliveBuilder().build();
     private static final ByteBuf KEEPALIVE_BYTES = Unpooled.buffer();
index 3079f66d4ed98a81b894415e53f10d47432fd8ce..643d0214f8f88e03e7a81006d396415308b1e22f 100644 (file)
@@ -47,14 +47,16 @@ public final class BGPNotificationMessageParser implements MessageParser, Messag
         final Notify ntf = (Notify) msg;
         LOG.trace("Started serializing Notification message: {}", ntf);
 
-        final byte[] data = ntf.getData();
         final ByteBuf msgBody = Unpooled.buffer();
         msgBody.writeByte(ntf.getErrorCode());
         msgBody.writeByte(ntf.getErrorSubcode());
+        final byte[] data = ntf.getData();
         if (data != null) {
             msgBody.writeBytes(data);
         }
-        LOG.trace("Notification message serialized to: {}", ByteBufUtil.hexDump(bytes));
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Notification message serialized to: {}", ByteBufUtil.hexDump(msgBody));
+        }
         MessageUtil.formatMessage(TYPE, msgBody, bytes);
     }
 
@@ -69,7 +71,9 @@ public final class BGPNotificationMessageParser implements MessageParser, Messag
     @Override
     public Notify parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
         Preconditions.checkArgument(body != null, "Byte buffer cannot be null.");
-        LOG.trace("Started parsing of notification message: {}", ByteBufUtil.hexDump(body));
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Started parsing of notification message: {}", ByteBufUtil.hexDump(body));
+        }
         if (body.readableBytes() < ERROR_SIZE) {
             throw BGPDocumentedException.badMessageLength("Notification message too small.", messageLength);
         }
index 7101cfa46ff36cc22b9c25d3b94854e5ea72a9eb..b5435ea0097c8976fc42529f14797cfae5dd92bd 100644 (file)
@@ -92,7 +92,7 @@ public final class BGPOpenMessageParser implements MessageParser, MessageSeriali
         msgBody.writeBytes(paramsBuffer);
 
         if (LOG.isTraceEnabled()) {
-            LOG.trace("Open message serialized to: {}", ByteBufUtil.hexDump(bytes));
+            LOG.trace("Open message serialized to: {}", ByteBufUtil.hexDump(msgBody));
         }
         MessageUtil.formatMessage(TYPE, msgBody, bytes);
     }
index 2cf0c93a09497729e83e8c581a428820cd9f512c..80257c91ffa5a3f8096293ab903133c8e3ea49da 100644 (file)
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
  *
  * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.3">BGP-4 Update Message Format</a>
  */
-public class BGPUpdateMessageParser implements MessageParser, MessageSerializer {
+public final class BGPUpdateMessageParser implements MessageParser, MessageSerializer {
     public static final int TYPE = 2;
 
     private static final Logger LOG = LoggerFactory.getLogger(BGPUpdateMessageParser.class);
@@ -132,7 +132,9 @@ public class BGPUpdateMessageParser implements MessageParser, MessageSerializer
                 messageBody.writeBytes(Ipv4Util.bytesForPrefixBegin(prefix));
             }
         }
-        LOG.trace("Update message serialized to {}", ByteBufUtil.hexDump(messageBody));
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Update message serialized to {}", ByteBufUtil.hexDump(messageBody));
+        }
         MessageUtil.formatMessage(TYPE, messageBody, bytes);
     }
 }