private synchronized void checkQuorumWhenAdded(final String nodeID, final long start) { if (clusterMap.containsKey(nodeID)) { checkQuorum(); } else { vertx.setTimer( 200, tid -> { // This can block on a monitor so it needs to run as a worker vertx.executeBlockingInternal( () -> { if (System.currentTimeMillis() - start > 10000) { log.warn("Timed out waiting for group information to appear"); } else if (!stopped) { ContextImpl context = vertx.getContext(); try { // Remove any context we have here (from the timer) otherwise will screw // things up when verticles are deployed ContextImpl.setContext(null); checkQuorumWhenAdded(nodeID, start); } finally { ContextImpl.setContext(context); } } return null; }, null); }); } }
// A node has joined the cluster // synchronize this in case the cluster manager is naughty and calls it concurrently private synchronized void nodeAdded(final String nodeID) { // This is not ideal but we need to wait for the group information to appear - and this will be // shortly // after the node has been added checkQuorumWhenAdded(nodeID, System.currentTimeMillis()); }