|
|
@ -131,16 +131,12 @@ public class ZookeeperNodeManager implements InitializingBean { |
|
|
|
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) { |
|
|
|
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) { |
|
|
|
logger.info("worker group node : {} added.", path); |
|
|
|
logger.info("worker group node : {} added.", path); |
|
|
|
String group = parseGroup(path); |
|
|
|
String group = parseGroup(path); |
|
|
|
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>()); |
|
|
|
|
|
|
|
Set<String> previousNodes = new HashSet<>(workerNodes); |
|
|
|
|
|
|
|
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group); |
|
|
|
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group); |
|
|
|
logger.info("currentNodes : {}", currentNodes); |
|
|
|
logger.info("currentNodes : {}", currentNodes); |
|
|
|
syncWorkerGroupNodes(group, currentNodes); |
|
|
|
syncWorkerGroupNodes(group, currentNodes); |
|
|
|
} else if (event.getType() == TreeCacheEvent.Type.NODE_REMOVED) { |
|
|
|
} else if (event.getType() == TreeCacheEvent.Type.NODE_REMOVED) { |
|
|
|
logger.info("worker group node : {} down.", path); |
|
|
|
logger.info("worker group node : {} down.", path); |
|
|
|
String group = parseGroup(path); |
|
|
|
String group = parseGroup(path); |
|
|
|
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>()); |
|
|
|
|
|
|
|
Set<String> previousNodes = new HashSet<>(workerNodes); |
|
|
|
|
|
|
|
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group); |
|
|
|
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group); |
|
|
|
syncWorkerGroupNodes(group, currentNodes); |
|
|
|
syncWorkerGroupNodes(group, currentNodes); |
|
|
|
alertDao.sendServerStopedAlert(1, path, "WORKER"); |
|
|
|
alertDao.sendServerStopedAlert(1, path, "WORKER"); |
|
|
@ -175,12 +171,10 @@ public class ZookeeperNodeManager implements InitializingBean { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) { |
|
|
|
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) { |
|
|
|
logger.info("master node : {} added.", path); |
|
|
|
logger.info("master node : {} added.", path); |
|
|
|
Set<String> previousNodes = new HashSet<>(masterNodes); |
|
|
|
|
|
|
|
Set<String> currentNodes = registryCenter.getMasterNodesDirectly(); |
|
|
|
Set<String> currentNodes = registryCenter.getMasterNodesDirectly(); |
|
|
|
syncMasterNodes(currentNodes); |
|
|
|
syncMasterNodes(currentNodes); |
|
|
|
} else if (event.getType() == TreeCacheEvent.Type.NODE_REMOVED) { |
|
|
|
} else if (event.getType() == TreeCacheEvent.Type.NODE_REMOVED) { |
|
|
|
logger.info("master node : {} down.", path); |
|
|
|
logger.info("master node : {} down.", path); |
|
|
|
Set<String> previousNodes = new HashSet<>(masterNodes); |
|
|
|
|
|
|
|
Set<String> currentNodes = registryCenter.getMasterNodesDirectly(); |
|
|
|
Set<String> currentNodes = registryCenter.getMasterNodesDirectly(); |
|
|
|
syncMasterNodes(currentNodes); |
|
|
|
syncMasterNodes(currentNodes); |
|
|
|
alertDao.sendServerStopedAlert(1, path, "MASTER"); |
|
|
|
alertDao.sendServerStopedAlert(1, path, "MASTER"); |
|
|
|