Wait for a raft quorum + logging a message to inform about the wait
Change-Id: I6b1e5a6f2a0ca57e0a435877068ba83bc9311953
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
index 2c0ff14..3f59ec7 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
@@ -224,16 +224,20 @@
clusterEventListener = new InternalClusterEventListener();
clusterService.addListener(clusterEventListener);
- if (clusterService.getNodes().size() < clusterConfig.getMembers().size()) {
+ final int raftClusterSize = clusterConfig.getMembers().size();
+ final int raftClusterQuorumSize = (int) (Math.floor(raftClusterSize / 2)) + 1;
+ if (clusterService.getNodes().size() < raftClusterQuorumSize) {
// current cluster size smaller then expected
try {
- if (!clusterEventLatch.await(120, TimeUnit.SECONDS)) {
+ final int waitTimeSec = 120;
+ log.info("Waiting for a maximum of {}s for raft cluster quorum to boot up...", waitTimeSec);
+ if (!clusterEventLatch.await(waitTimeSec, TimeUnit.SECONDS)) {
log.info("Starting with {}/{} nodes cluster",
clusterService.getNodes().size(),
- clusterConfig.getMembers().size());
+ raftClusterSize);
}
} catch (InterruptedException e) {
- log.info("Interrupted waiting for others", e);
+ log.info("Interrupted waiting for raft quorum.", e);
}
}
}