Handle TopologyNodeState release properly 32/96032/1
authorOleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
Mon, 26 Apr 2021 23:58:43 +0000 (02:58 +0300)
committerRobert Varga <nite@hq.sk>
Mon, 10 May 2021 10:30:32 +0000 (10:30 +0000)
- Close transaction chain when PCEP session goes down
- Remove NodeState from the corresponding map in SessionManager properly

JIRA: BGPCEP-920
Change-Id: Ica9dc0a6f43420b5b57694252cb13d2b5350b103
Signed-off-by: Deepthi V V <dvv@luminanetworks.com>
Signed-off-by: Oleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3bf063839d01f6c4b80aa4c02ea85d80feae8bfd)

pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/ServerSessionManager.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/TopologyNodeState.java

index a85730af250a2b05b5eabbd4779c02d7bd420e76..272205b72697dfed68a2b501f4a0fb5577fbdc0f 100644 (file)
@@ -343,6 +343,7 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
     private void clearNodeState() {
         if (this.nodeState != null) {
             this.serverSessionManager.unbind(this.nodeState.getNodeId());
+            LOG.debug("Clear Node state: {}", this.nodeState.getNodeId());
             this.nodeState = null;
         }
     }
index eaa343a295560f4dece1d21127cdea09212ad5ad..9d8b59ea59e770be9d25ff2e88f533fedc38397d 100644 (file)
@@ -126,7 +126,9 @@ final class ServerSessionManager implements PCEPSessionListenerFactory, Topology
             LOG.error("Session Manager has already been closed.");
             return;
         }
-        this.nodes.remove(createNodeId(session.getRemoteAddress()));
+        final NodeId nodeId = createNodeId(session.getRemoteAddress());
+        this.nodes.remove(nodeId);
+        this.state.remove(nodeId);
         if (nodeState != null) {
             LOG.debug("Node {} unbound", nodeState.getNodeId());
             nodeState.released(persistNode);
index 63abe010df709615013064193ed4e86f3b05483e..9e40babe17e8269ae279f494857bc12218e49b46 100644 (file)
@@ -101,6 +101,7 @@ final class TopologyNodeState implements AutoCloseable, TransactionChainListener
             }, MoreExecutors.directExecutor());
         }
 
+        close();
         this.lastReleased = System.nanoTime();
     }
 
@@ -150,6 +151,7 @@ final class TopologyNodeState implements AutoCloseable, TransactionChainListener
         // FIXME: flip internal state, so that the next attempt to update fails, triggering node reconnect
         LOG.error("Unexpected transaction failure in node {} transaction {}",
                 this.nodeId, transaction.getIdentifier(), cause);
+        close();
     }
 
     @Override
@@ -176,7 +178,7 @@ final class TopologyNodeState implements AutoCloseable, TransactionChainListener
 
             @Override
             public void onFailure(final Throwable throwable) {
-                LOG.trace("Put topology Node failed {}, value {}", TopologyNodeState.this.nodeId, node, throwable);
+                LOG.error("Put topology Node failed {}, value {}", TopologyNodeState.this.nodeId, node, throwable);
             }
         }, MoreExecutors.directExecutor());
     }
@@ -202,4 +204,4 @@ final class TopologyNodeState implements AutoCloseable, TransactionChainListener
             }
         }, MoreExecutors.directExecutor());
     }
-}
\ No newline at end of file
+}