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;
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();
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);
}
@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);
}
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);
}
*
* @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);
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);
}
}