Remove isLspDbRetreived 81/100681/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Apr 2022 18:20:29 +0000 (20:20 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Apr 2022 18:20:29 +0000 (20:20 +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>
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java

index 2fa800fd934468f5e14868feec6fb523442540de..d076894c97a91a0045da2aaec487dc2d9da9e3fd 100644 (file)
@@ -136,9 +136,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
@@ -170,12 +171,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);
@@ -588,10 +591,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.