Pavlin Radoslavov

Adding-back "Wait for a raft quorum + logging a message to inform about the wait"

This reverts commit 17319764.

Change-Id: I6e5e4d5ef5e06930c80ca96a4e1e9de7d71eee70
...@@ -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 }
......