Remove isLspDbRetreived 34/100734/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Apr 2022 18:20:29 +0000 (20:20 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 23 Apr 2022 04:19:09 +0000 (06:19 +0200)
We are calling this method only from a place where we have
syncOptimization initialized. Eliminate the method and cache its
result in a local boolean.

Change-Id: Id5ebb0fe3d5564c58888d41048d65e9b17a3e840
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 55c987574c8ac2ead149a7727b7351ae3cc900df)

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

index 64a7ee0fc63e179178810ab4f5b84abc6b5b0170..5ceb66cc62b33fcdc3b7a7b602e8c7ee81cd042d 100644 (file)
@@ -137,9 +137,10 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
                 final InetAddress peerAddress = psession.getRemoteAddress();
 
                 this.syncOptimization = new SyncOptimization(psession);
+                final boolean haveLspDbVersion = this.syncOptimization.isDbVersionPresent();
 
                 final TopologyNodeState state =
-                        this.serverSessionManager.takeNodeState(peerAddress, this, isLspDbRetreived());
+                        this.serverSessionManager.takeNodeState(peerAddress, this, haveLspDbVersion);
 
                 // takeNodeState(..) may fail when the server session manager is being restarted
                 // due to configuration change
@@ -171,12 +172,14 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
                 pccBuilder.setIpAddress(IetfInetUtil.INSTANCE.ipAddressNoZoneFor(peerAddress));
                 final InstanceIdentifier<Node1> topologyAugment = state.getNodeId().augmentation(Node1.class);
                 this.pccIdentifier = topologyAugment.child(PathComputationClient.class);
-                final Node initialNodeState = state.getInitialNodeState();
-                final boolean isNodePresent = isLspDbRetreived() && initialNodeState != null;
-                if (isNodePresent) {
-                    loadLspData(initialNodeState, this.lspData, this.lsps, isIncrementalSynchro());
-                    pccBuilder.setReportedLsp(
+
+                if (haveLspDbVersion) {
+                    final Node initialNodeState = state.getInitialNodeState();
+                    if (initialNodeState != null) {
+                        loadLspData(initialNodeState, this.lspData, this.lsps, isIncrementalSynchro());
+                        pccBuilder.setReportedLsp(
                             initialNodeState.augmentation(Node1.class).getPathComputationClient().getReportedLsp());
+                    }
                 }
                 state.storeNode(topologyAugment,
                         new Node1Builder().setPathComputationClient(pccBuilder.build()).build(), psession);
@@ -589,10 +592,6 @@ public abstract class AbstractTopologySessionListener<S, L> implements TopologyS
         return this.syncOptimization != null && this.syncOptimization.isSyncAvoidanceEnabled();
     }
 
-    final boolean isLspDbRetreived() {
-        return this.syncOptimization != null && this.syncOptimization.isDbVersionPresent();
-    }
-
     /**
      * Is Incremental synchronization if LSP-DB-VERSION are included,
      * LSP-DB-VERSION TLV values doesnt match, and  LSP-SYNC-CAPABILITY is enabled.