BGPCEP-738: fix unbind pcep stats 51/66751/1
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Fri, 22 Dec 2017 22:15:11 +0000 (23:15 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Sat, 23 Dec 2017 12:14:48 +0000 (13:14 +0100)
by doing it when session is finished
 or topology is closed.

Change-Id: I5f46f1e2bfb7f37a9fad6d3101177c8f127ba67a
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
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/Stateful07TopologySessionListener.java

index ec6f2489aee7c5a2683a89d92c0ebc755c1ca8bb..68f4eb7179c63be642cee6a8614381d0fe7bebc1 100755 (executable)
@@ -102,6 +102,7 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
     private final Map<String, ReportedLsp> lspData = new HashMap<>();
     private final ServerSessionManager serverSessionManager;
     private InstanceIdentifier<PathComputationClient> pccIdentifier;
+    @GuardedBy("this")
     private TopologyNodeState nodeState;
     private AtomicBoolean synced = new AtomicBoolean(false);
     private PCEPSession session;
@@ -228,18 +229,13 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
     /**
      * Tear down the given PCEP session. It's OK to call this method even after the session
      * is already down. It always clear up the current session status.
-     *
-     * @param session
      */
     @GuardedBy("this")
     private synchronized void tearDown(final PCEPSession session) {
 
         requireNonNull(session);
         this.serverSessionManager.releaseNodeState(this.nodeState, session, isLspDbPersisted());
-        if (this.nodeState != null) {
-            this.serverSessionManager.unbind(this.nodeState.getNodeId());
-            this.nodeState = null;
-        }
+        clearNodeState();
 
         try {
             if (this.session != null) {
@@ -322,13 +318,21 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
     }
 
     @Override
-    public void close() {
+    public synchronized void close() {
+        clearNodeState();
         if (this.session != null) {
             LOG.info("Closing session {}", session);
             this.session.close(TerminationReason.UNKNOWN);
         }
     }
 
+    private synchronized void clearNodeState() {
+        if (this.nodeState != null) {
+            this.serverSessionManager.unbind(this.nodeState.getNodeId());
+            this.nodeState = null;
+        }
+    }
+
     final synchronized PCEPRequest removeRequest(final S id) {
         final PCEPRequest ret = this.requests.remove(id);
         if (ret != null) {
index aca77eefd7a51da7189920fa9f9ba9083c8fd98c..2f4f6da26ad45714388dac73a8a0b0e39a57676c 100644 (file)
@@ -105,8 +105,6 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
 
     /**
      * Creates a new stateful topology session listener for given server session manager.
-     *
-     * @param serverSessionManager
      */
     Stateful07TopologySessionListener(final ServerSessionManager serverSessionManager) {
         super(serverSessionManager);