msgBody.writeByte(paramsBuffer.writerIndex());
msgBody.writeBytes(paramsBuffer);
- LOG.trace("Open message serialized to: {}", ByteBufUtil.hexDump(bytes));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Open message serialized to: {}", ByteBufUtil.hexDump(bytes));
+ }
MessageUtil.formatMessage(TYPE, msgBody, bytes);
}
@Override
public Open parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
Preconditions.checkArgument(body != null, "Byte array cannot be null.");
- LOG.trace("Started parsing of open message: {}", ByteBufUtil.hexDump(body));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Started parsing of open message: {}", ByteBufUtil.hexDump(body));
+ }
if (body.readableBytes() < MIN_MSG_LENGTH) {
throw BGPDocumentedException.badMessageLength("Open message too small.", messageLength);
private void fillParams(final ByteBuf buffer, final List<BgpParameters> params) throws BGPDocumentedException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Byte array cannot be null or empty.");
- LOG.trace("Started parsing of BGP parameter: {}", ByteBufUtil.hexDump(buffer));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Started parsing of BGP parameter: {}", ByteBufUtil.hexDump(buffer));
+ }
while (buffer.isReadable()) {
if (buffer.readableBytes() <= 2) {
throw new BGPDocumentedException("Malformed parameter encountered (" + buffer.readableBytes() + " bytes left)", BGPError.OPT_PARAM_NOT_SUPPORTED);
LOG.debug("Ignoring BGP Parameter type: {}", paramType);
}
}
- LOG.trace("Parsed BGP parameters: {}", Arrays.toString(params.toArray()));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Parsed BGP parameters: {}", Arrays.toString(params.toArray()));
+ }
}
}
@Override
public Update parseMessageBody(final ByteBuf buffer, final int messageLength) throws BGPDocumentedException {
Preconditions.checkArgument(buffer != null && buffer.readableBytes() != 0, "Byte array cannot be null or empty.");
- LOG.trace("Started parsing of update message: {}", ByteBufUtil.hexDump(buffer));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Started parsing of update message: {}", ByteBufUtil.hexDump(buffer));
+ }
final int withdrawnRoutesLength = buffer.readUnsignedShort();
final UpdateBuilder eventBuilder = new UpdateBuilder();
@Override
public BgpParameters parseParameter(final ByteBuf buffer) throws BGPParsingException, BGPDocumentedException {
Preconditions.checkArgument(buffer != null && buffer.readableBytes() != 0, "Byte array cannot be null or empty.");
- LOG.trace("Started parsing of BGP Capabilities: {}", Arrays.toString(ByteArray.getAllBytes(buffer)));
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Started parsing of BGP Capabilities: {}", Arrays.toString(ByteArray.getAllBytes(buffer)));
+ }
+
final List<OptionalCapabilities> optionalCapas = Lists.newArrayList();
while (buffer.isReadable()) {
final OptionalCapabilities optionalCapa = parseOptionalCapability(buffer);
if (bytes == null) {
throw new IllegalArgumentException("Unhandled capability class" + cap.getImplementedInterface());
}
- LOG.trace("BGP capability serialized to: {}", ByteBufUtil.hexDump(bytes));
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("BGP capability serialized to: {}", ByteBufUtil.hexDump(bytes));
+ }
byteAggregator.writeBytes(bytes);
}
}
package org.opendaylight.protocol.bgp.rib.impl;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
-
import java.util.List;
-
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws BGPDocumentedException,
BGPParsingException {
if (in.isReadable()) {
- LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
+ }
out.add(this.registry.parseMessage(in));
} else {
LOG.trace("No more content in incoming buffer.");
package org.opendaylight.protocol.bgp.rib.impl;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
-
import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
protected void encode(final ChannelHandlerContext ctx, final Notification msg, final ByteBuf out) {
LOG.trace("Encoding message: {}", msg);
this.registry.serializeMessage(msg, out);
- LOG.trace("Encoded message: {}", ByteBufUtil.hexDump(out));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Encoded message: {}", ByteBufUtil.hexDump(out));
+ }
LOG.debug("Message sent to output: {}", msg);
}
}
@Override
public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
- LOG.trace("Received data change to LocRib {}", Arrays.toString(changes.toArray()));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Received data change to LocRib {}", Arrays.toString(changes.toArray()));
+ }
+
/*
* We use two-stage processing here in hopes that we avoid duplicate
* calculations when multiple peers have changed a particular entry.