Improved logging in BGP. 32/6932/2
authorDana Kutenicsova <dkutenic@cisco.com>
Tue, 13 May 2014 13:54:51 +0000 (15:54 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Wed, 14 May 2014 11:32:09 +0000 (13:32 +0200)
Change-Id: Id9d8f726a4ca255280be0ea31e1b217af64c72ee
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
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
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionNegotiator.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSynchronization.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/AbstractTopologyBuilder.java

index 44f41f651e0bc7a6cce00b3402e3fe80db6c3321..95f2dd43ff6d8fa4ee3987af192fd27ead48bc30 100644 (file)
@@ -89,12 +89,12 @@ public final class BGPNotificationMessageParser implements MessageParser, Messag
                if (body.readableBytes() != 0) {
                        data = ByteArray.readAllBytes(body);
                }
-               LOG.trace("Notification message was parsed: err = {}, data = {}.", BGPError.forValue(errorCode, errorSubcode),
-                               Arrays.toString(data));
                final NotifyBuilder builder = new NotifyBuilder().setErrorCode((short) errorCode).setErrorSubcode((short) errorSubcode);
                if (data != null) {
                        builder.setData(data);
                }
+               LOG.debug("BGP Notification message was parsed: err = {}, data = {}.", BGPError.forValue(errorCode, errorSubcode),
+                               Arrays.toString(data));
                return builder.build();
        }
 }
index 9e30fa1827b29c8088222e815b90fe0da27740d2..d38d6fa7afac49ccd1ed05049db194524b3cccf7 100644 (file)
@@ -164,7 +164,7 @@ public final class BGPOpenMessageParser implements MessageParser, MessageSeriali
                if (optLength > 0) {
                        fillParams(body.slice(body.readerIndex(), optLength), optParams);
                }
-               LOG.trace("Open message was parsed: AS = {}, holdTimer = {}, bgpId = {}, optParams = {}", as, holdTime, bgpId, optParams);
+               LOG.debug("BGP Open message was parsed: AS = {}, holdTimer = {}, bgpId = {}, optParams = {}", as, holdTime, bgpId, optParams);
                return new OpenBuilder().setMyAsNumber(as.getValue().intValue()).setHoldTimer(holdTime).setBgpIdentifier(bgpId).setBgpParameters(
                                optParams).build();
        }
index 05802cb6ffd0504904b78b59628bc18096041980..d5630d451779eb5cf38943a8886402be810aafbb 100644 (file)
@@ -93,7 +93,8 @@ public class BGPUpdateMessageParser implements MessageParser {
                if (nlri != null && !nlri.isEmpty()) {
                        eventBuilder.setNlri(new NlriBuilder().setNlri(nlri).build());
                }
-               LOG.trace("Update message was parsed.");
-               return eventBuilder.build();
+               Update msg = eventBuilder.build();
+               LOG.debug("BGP Update message was parsed {}.", msg);
+               return msg;
        }
 }
index 4dd5820f44f8e14e000d936ffdbd20bdd600e1af..8fb2721c83f10847be5826469c9f0c4bb537a9c0 100644 (file)
@@ -115,7 +115,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
                this.stateTimer = Preconditions.checkNotNull(timer);
                this.channel = Preconditions.checkNotNull(channel);
                this.holdTimerValue = (remoteOpen.getHoldTimer() < localHoldTimer) ? remoteOpen.getHoldTimer() : localHoldTimer;
-               LOG.info("HoldTimer new value: {}", this.holdTimerValue);
+               LOG.info("BGP HoldTimer new value: {}", this.holdTimerValue);
                this.keepAlive = this.holdTimerValue / 3;
                this.asNumber = AsNumberUtil.advertizedAsNumber(remoteOpen);
 
@@ -157,7 +157,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
 
        @Override
        public synchronized void close() {
-               LOG.debug("Closing session: {}", this);
+               LOG.info("Closing session: {}", this);
                if (this.state != State.Idle) {
                        this.sendMessage(new NotifyBuilder().setErrorCode(BGPError.CEASE.getCode()).build());
                        this.channel.close();
@@ -187,7 +187,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
                                        new BGPTerminationReason(BGPError.forValue(((Notify) msg).getErrorCode(), ((Notify) msg).getErrorSubcode())));
                } else if (msg instanceof Keepalive) {
                        // Keepalives are handled internally
-                       LOG.debug("Received KeepAlive messsage.");
+                       LOG.trace("Received KeepAlive messsage.");
                        this.kaCounter++;
                        if (this.kaCounter >= 2) {
                                this.sync.kaReceived();
index d2580f525d58bff9366d98cac1a764621c968f3e..52cbc1897d2d8957fd4528e912432a5248d32d4f 100644 (file)
@@ -126,10 +126,11 @@ public final class BGPSessionNegotiator extends AbstractSessionNegotiator<Notifi
                case Finished:
                case Idle:
                        this.sendMessage(buildErrorNotify(BGPError.FSM_ERROR));
-                       // FIXME: is something missing here? (at least an explanation why fall-through is okay
+                       return;
                case OpenConfirm:
                        if (msg instanceof Keepalive) {
                                negotiationSuccessful(this.session);
+                               LOG.info("BGP Session with peer {} established successfully.", this.channel);
                        } else if (msg instanceof Notify) {
                                final Notify ntf = (Notify) msg;
                                negotiationFailed(new BGPDocumentedException("Peer refusal", BGPError.forValue(ntf.getErrorCode(), ntf.getErrorSubcode())));
@@ -159,7 +160,7 @@ public final class BGPSessionNegotiator extends AbstractSessionNegotiator<Notifi
        private void handleOpen(final Open openObj) {
                final AsNumber as = AsNumberUtil.advertizedAsNumber(openObj);
                if (!this.remoteAs.equals(as)) {
-                       LOG.info("Unexpected remote AS number. Expecting {}, got {}", this.remoteAs, as);
+                       LOG.warn("Unexpected remote AS number. Expecting {}, got {}", this.remoteAs, as);
                        this.sendMessage(buildErrorNotify(BGPError.BAD_PEER_AS));
                        negotiationFailed(new BGPDocumentedException("Peer AS number mismatch", BGPError.BAD_PEER_AS));
                        this.state = State.Finished;
@@ -169,7 +170,7 @@ public final class BGPSessionNegotiator extends AbstractSessionNegotiator<Notifi
                final List<BgpParameters> prefs = openObj.getBgpParameters();
                if (prefs != null && !prefs.isEmpty()) {
                        if (!prefs.containsAll(this.localPref.getParams())) {
-                               LOG.info("Open message session parameters differ, session still accepted.");
+                               LOG.info("BGP Open message session parameters differ, session still accepted.");
                        }
                        this.sendMessage(new KeepaliveBuilder().build());
                        this.session = new BGPSessionImpl(this.timer, this.listener, this.channel, openObj, this.localPref.getHoldTime());
index cae1d3a153e41db723ed028a1ad1ca4228e8bcb2..c9dc64e1fcb8516361d03c293c045045bf6b5b4d 100644 (file)
@@ -117,6 +117,7 @@ public class BGPSynchronization {
                        if (!s.getEor()) {
                                if (!s.getUpd()) {
                                        s.setEorTrue();
+                                       LOG.info("BGP Synchronization finished for table {} ", entry.getKey());
                                        final Update up = generateEOR(entry.getKey());
                                        LOG.debug("Sending synchronization message: {}", up);
                                        this.listener.onMessage(this.session, up);
index b133c143d5d2bfa7c929cf6478bd5f731f6a5b02..de32c9b73c38cdffd649e0f9e6113d207d332f96 100644 (file)
@@ -59,13 +59,13 @@ TopologyReference {
                final TopologyKey tk = new TopologyKey(Preconditions.checkNotNull(topologyId));
                this.topology = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, tk).toInstance();
 
-               LOG.debug("Initiating topology builder from {} at {}", locRibReference, topology);
+               LOG.debug("Initiating topology builder from {} at {}", locRibReference, this.topology);
 
                DataModificationTransaction t = dataProvider.beginTransaction();
-               Object o = t.readOperationalData(topology);
-               Preconditions.checkState(o == null, "Data provider conflict detected on object {}", topology);
+               Object o = t.readOperationalData(this.topology);
+               Preconditions.checkState(o == null, "Data provider conflict detected on object {}", this.topology);
 
-               t.putOperationalData(topology, new TopologyBuilder().setKey(tk).setServerProvided(Boolean.TRUE).setTopologyTypes(types).build());
+               t.putOperationalData(this.topology, new TopologyBuilder().setKey(tk).setServerProvided(Boolean.TRUE).setTopologyTypes(types).build());
                Futures.addCallback(JdkFutureAdapters.listenInPoolThread(t.commit()), new FutureCallback<RpcResult<TransactionStatus>>() {
                        @Override
                        public void onSuccess(final RpcResult<TransactionStatus> result) {
@@ -74,13 +74,13 @@ TopologyReference {
 
                        @Override
                        public void onFailure(final Throwable t) {
-                               LOG.error("Failed to initiate topology {} by listener {}", topology, AbstractTopologyBuilder.this, t);
+                               LOG.error("Failed to initiate topology {} by listener {}", AbstractTopologyBuilder.this.topology, AbstractTopologyBuilder.this, t);
                        }
                });
        }
 
        public final InstanceIdentifier<Tables> tableInstanceIdentifier(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
-               return locRibReference.getInstanceIdentifier().builder().child(LocRib.class).child(Tables.class, new TablesKey(afi, safi)).toInstance();
+               return this.locRibReference.getInstanceIdentifier().builder().child(LocRib.class).child(Tables.class, new TablesKey(afi, safi)).toInstance();
        }
 
        protected abstract void createObject(DataModification<InstanceIdentifier<?>, DataObject> trans, InstanceIdentifier<T> id, T value);
@@ -101,7 +101,7 @@ TopologyReference {
                if (id != null) {
                        out.add(id);
                } else {
-                       LOG.info("Identifier {} in {} set does not contain listening class {}, ignoring it", i, set, this.idClass);
+                       LOG.debug("Identifier {} in {} set does not contain listening class {}, ignoring it", i, set, this.idClass);
                }
        }