BUG 3054 : Move ShardManager ready check into a single method. 48/19248/8
authorMoiz Raja <moraja@cisco.com>
Tue, 28 Apr 2015 17:58:08 +0000 (10:58 -0700)
committerTom Pantelis <tpanteli@brocade.com>
Sat, 25 Apr 2015 19:38:57 +0000 (15:38 -0400)
Small refactoring to move code which checks for readiness into a
private method instead of duplicating it inline

Change-Id: I60cd603cb015c8602591769f1f931ae8580cfbd8
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 7159b15b0efedb548f7fae5bb1eb9e970bc2e43f)

opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java

index cff44b13cb3edb1756ed6159e95d8fe259f91fde..f32ba4e20cd381c07ddf5023c2ba485d3fe189e5 100644 (file)
@@ -193,19 +193,22 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering {
 
     }
 
+    private void checkReady(){
+        if (isReadyWithLeaderId()) {
+            LOG.info("{}: All Shards are ready - data store {} is ready, available count is {}",
+                    persistenceId(), type, waitTillReadyCountdownLatch.getCount());
+
+            waitTillReadyCountdownLatch.countDown();
+        }
+    }
+
     private void onLeaderStateChanged(LeaderStateChanged leaderStateChanged) {
         LOG.info("{}: Received LeaderStateChanged message: {}", persistenceId(), leaderStateChanged);
 
         ShardInformation shardInformation = findShardInformation(leaderStateChanged.getMemberId());
         if(shardInformation != null) {
             shardInformation.setLeaderId(leaderStateChanged.getLeaderId());
-            if (isReadyWithLeaderId()) {
-                LOG.info("{}: All Shards are ready - data store {} is ready, available count is {}",
-                        persistenceId(), type, waitTillReadyCountdownLatch.getCount());
-
-                waitTillReadyCountdownLatch.countDown();
-            }
-
+            checkReady();
         } else {
             LOG.debug("No shard found with member Id {}", leaderStateChanged.getMemberId());
         }
@@ -249,14 +252,7 @@ public class ShardManager extends AbstractUntypedPersistentActorWithMetering {
         ShardInformation shardInformation = findShardInformation(roleChanged.getMemberId());
         if(shardInformation != null) {
             shardInformation.setRole(roleChanged.getNewRole());
-
-            if (isReadyWithLeaderId()) {
-                LOG.info("{}: All Shards are ready - data store {} is ready, available count is {}",
-                        persistenceId(), type, waitTillReadyCountdownLatch.getCount());
-
-                waitTillReadyCountdownLatch.countDown();
-            }
-
+            checkReady();
             mBean.setSyncStatus(isInSync());
         }
     }