private synchronized void nodeLeft(String leftNodeID) { addHaInfoIfLost(); checkQuorum(); if (attainedQuorum) { checkSubs(leftNodeID); // Check for failover String sclusterInfo = clusterMap.get(leftNodeID); if (sclusterInfo == null) { // Clean close - do nothing } else { JsonObject clusterInfo = new JsonObject(sclusterInfo); checkFailover(leftNodeID, clusterInfo); } // We also check for and potentially resume any previous failovers that might have failed // We can determine this if there any ids in the cluster map which aren't in the node list List<String> nodes = clusterManager.getNodes(); for (Map.Entry<String, String> entry: clusterMap.entrySet()) { if (!leftNodeID.equals(entry.getKey()) && !nodes.contains(entry.getKey())) { JsonObject haInfo = new JsonObject(entry.getValue()); checkFailover(entry.getKey(), haInfo); } } } }
private synchronized void checkQuorumWhenAdded(final String nodeID, final long start) { if (clusterMap.containsKey(nodeID)) { checkQuorum(); if (attainedQuorum) { checkSubs(nodeID); } } else { vertx.setTimer(200, tid -> { // This can block on a monitor so it needs to run as a worker vertx.executeBlockingInternal(fut -> { if (System.currentTimeMillis() - start > 10000) { log.warn("Timed out waiting for group information to appear"); } else if (!stopped) { ContextInternal 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((ContextImpl) context); } } fut.complete(); }, null); }); } }
private synchronized void nodeLeft(String leftNodeID) { addHaInfoIfLost(); checkQuorum(); if (attainedQuorum) { checkSubs(leftNodeID); // Check for failover String sclusterInfo = clusterMap.get(leftNodeID); if (sclusterInfo == null) { // Clean close - do nothing } else { JsonObject clusterInfo = new JsonObject(sclusterInfo); checkFailover(leftNodeID, clusterInfo); } // We also check for and potentially resume any previous failovers that might have failed // We can determine this if there any ids in the cluster map which aren't in the node list List<String> nodes = clusterManager.getNodes(); for (Map.Entry<String, String> entry: clusterMap.entrySet()) { if (!leftNodeID.equals(entry.getKey()) && !nodes.contains(entry.getKey())) { JsonObject haInfo = new JsonObject(entry.getValue()); checkFailover(entry.getKey(), haInfo); } } } }
private synchronized void checkQuorumWhenAdded(final String nodeID, final long start) { if (clusterMap.containsKey(nodeID)) { checkQuorum(); if (attainedQuorum) { checkSubs(nodeID); } } else { vertx.setTimer(200, tid -> { // This can block on a monitor so it needs to run as a worker vertx.executeBlockingInternal(fut -> { if (System.currentTimeMillis() - start > 10000) { log.warn("Timed out waiting for group information to appear"); } else if (!stopped) { ContextInternal 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((ContextImpl) context); } } fut.complete(); }, null); }); } }