BUG-5141: Failed to send Update Message on reconfigure Peer 77/33777/2
authorClaudio D. Gasparini <cgaspari@cisco.com>
Fri, 29 Jan 2016 10:58:35 +0000 (11:58 +0100)
committerClaudio D. Gasparini <cgaspari@cisco.com>
Sat, 30 Jan 2016 19:33:41 +0000 (19:33 +0000)
Clean up when reconfigurin Peer as we do when we reconnect peer.
Update Log levels on LocRibWriter for skipped change.
Making Debug logs more clear.

Change-Id: Ifb3fa2a0e4dc4633814ce3620f5ac585d01aa575
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRibInWriter.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRibOutListener.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java

index 6c58f1d21fa67b9ac6fc697b0fc1b5c0822795c7..4491b7d3c5844825470c886fb0fded6bbe12110d 100644 (file)
@@ -244,13 +244,15 @@ final class AdjRibInWriter {
     }
 
     void removePeer() {
-        final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
-        tx.delete(LogicalDatastoreType.OPERATIONAL, this.peerPath);
+        if(this.peerPath != null) {
+            final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
+            tx.delete(LogicalDatastoreType.OPERATIONAL, this.peerPath);
 
-        try {
-            tx.submit().checkedGet();
-        } catch (final TransactionCommitFailedException e) {
-            LOG.debug("Failed to remove Peer {}", this.peerPath, e);
+            try {
+                tx.submit().checkedGet();
+            } catch (final TransactionCommitFailedException e) {
+                LOG.debug("Failed to remove Peer {}", this.peerPath, e);
+            }
         }
     }
 
index 2d566f4b8bfc8fd11744c3e96e3d9b4327ec4788..0976f336e9576f39d98b2e8bbf8781f524f89c71 100644 (file)
@@ -84,36 +84,43 @@ final class AdjRibOutListener implements DOMDataTreeChangeListener {
         for (final DataTreeCandidate tc : changes) {
             LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().getModificationType());
             for (final DataTreeCandidateNode child : tc.getRootNode().getChildNodes()) {
-                for (final DataTreeCandidateNode route : this.support.changedRoutes(child)) {
-                    final Update update;
-
-                    switch (route.getModificationType()) {
-                    case UNMODIFIED:
-                        LOG.debug("Skipping unmodified route {}", route.getIdentifier());
-                        continue;
-                    case DELETE:
-                    case DISAPPEARED:
-                        // FIXME: we can batch deletions into a single batch
-                        update = withdraw((MapEntryNode) route.getDataBefore().get());
-                        break;
-                    case APPEARED:
-                    case SUBTREE_MODIFIED:
-                    case WRITE:
-                        update = advertise((MapEntryNode) route.getDataAfter().get());
-                        break;
-                    default:
-                        LOG.warn("Ignoring unhandled modification type {}", route.getModificationType());
-                        continue;
-                    }
-
-                    LOG.debug("Writing update {}", update);
-                    this.session.write(update);
-                }
+                processSupportedFamilyRoutes(child);
             }
         }
         this.session.flush();
     }
 
+    private void processSupportedFamilyRoutes(final DataTreeCandidateNode child) {
+        for (final DataTreeCandidateNode route : this.support.changedRoutes(child)) {
+            processRouteChange(route);
+        }
+    }
+
+    private void processRouteChange(final DataTreeCandidateNode route) {
+        final Update update;
+        switch (route.getModificationType()) {
+        case UNMODIFIED:
+            LOG.debug("Skipping unmodified route {}", route.getIdentifier());
+            return;
+        case DELETE:
+        case DISAPPEARED:
+            // FIXME: we can batch deletions into a single batch
+            update = withdraw((MapEntryNode) route.getDataBefore().get());
+            LOG.debug("Withdrawing routes {}", update);
+            break;
+        case APPEARED:
+        case SUBTREE_MODIFIED:
+        case WRITE:
+            update = advertise((MapEntryNode) route.getDataAfter().get());
+            LOG.debug("Advertising routes {}", update);
+            break;
+        default:
+            LOG.warn("Ignoring unhandled modification type {}", route.getModificationType());
+            return;
+        }
+        this.session.write(update);
+    }
+
     private Attributes routeAttributes(final MapEntryNode route) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("AdjRibOut parsing route {}", NormalizedNodes.toStringTree(route));
index 82465ea39421e197d9b171172b88c645b7c6a8b7..b33657c234edca8f539f5a70da1a737fed5b3947 100644 (file)
@@ -100,9 +100,8 @@ public class BGPPeer implements BGPSessionListener, Peer, AutoCloseable, BGPPeer
 
     @Override
     public synchronized void close() {
-        dropConnection();
+        releaseConnection();
         this.chain.close();
-        // TODO should this perform cleanup ?
     }
 
     @Override
@@ -277,8 +276,8 @@ public class BGPPeer implements BGPSessionListener, Peer, AutoCloseable, BGPPeer
 
     @Override
     public void releaseConnection() {
-        dropConnection();
         cleanup();
+        dropConnection();
     }
 
     @GuardedBy("this")
@@ -349,7 +348,7 @@ public class BGPPeer implements BGPSessionListener, Peer, AutoCloseable, BGPPeer
     @Override
     public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction, final Throwable cause) {
         LOG.error("Transaction chain failed.", cause);
-        dropConnection();
+        releaseConnection();
         this.chain.close();
         this.chain = this.rib.createPeerChain(this);
     }
index 5fbe0a9feec0cf2194eb693ef623e321db8566fc..3cac2a4300350267fdf10be6cfaee2e097f12649 100644 (file)
@@ -169,12 +169,12 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
         final Map<RouteUpdateKey, AbstractRouteEntry> ret, final YangInstanceIdentifier rootPath, final DOMDataWriteTransaction tx) {
         final DataTreeCandidateNode ribIn = rootNode.getModifiedChild(EFFRIBIN_NID);
         if (ribIn == null) {
-            LOG.debug("Skipping change {}", rootNode.getIdentifier());
+            LOG.trace("Skipping change {}", rootNode.getIdentifier());
             return;
         }
         final DataTreeCandidateNode table = ribIn.getModifiedChild(TABLES_NID).getModifiedChild(this.tableKey);
         if (table == null) {
-            LOG.debug("Skipping change {}", rootNode.getIdentifier());
+            LOG.trace("Skipping change {}", rootNode.getIdentifier());
             return;
         }
         initializeTableWithExistenRoutes(table, peerId, rootPath, tx);