Madan Jampani

Wait for a raft quorum + logging a message to inform about the wait

Change-Id: I6b1e5a6f2a0ca57e0a435877068ba83bc9311953
...@@ -224,16 +224,20 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService { ...@@ -224,16 +224,20 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
224 clusterEventListener = new InternalClusterEventListener(); 224 clusterEventListener = new InternalClusterEventListener();
225 clusterService.addListener(clusterEventListener); 225 clusterService.addListener(clusterEventListener);
226 226
227 - if (clusterService.getNodes().size() < clusterConfig.getMembers().size()) { 227 + final int raftClusterSize = clusterConfig.getMembers().size();
228 + final int raftClusterQuorumSize = (int) (Math.floor(raftClusterSize / 2)) + 1;
229 + if (clusterService.getNodes().size() < raftClusterQuorumSize) {
228 // current cluster size smaller then expected 230 // current cluster size smaller then expected
229 try { 231 try {
230 - if (!clusterEventLatch.await(120, TimeUnit.SECONDS)) { 232 + final int waitTimeSec = 120;
233 + log.info("Waiting for a maximum of {}s for raft cluster quorum to boot up...", waitTimeSec);
234 + if (!clusterEventLatch.await(waitTimeSec, TimeUnit.SECONDS)) {
231 log.info("Starting with {}/{} nodes cluster", 235 log.info("Starting with {}/{} nodes cluster",
232 clusterService.getNodes().size(), 236 clusterService.getNodes().size(),
233 - clusterConfig.getMembers().size()); 237 + raftClusterSize);
234 } 238 }
235 } catch (InterruptedException e) { 239 } catch (InterruptedException e) {
236 - log.info("Interrupted waiting for others", e); 240 + log.info("Interrupted waiting for raft quorum.", e);
237 } 241 }
238 } 242 }
239 } 243 }
......