|
|
|
@ -188,26 +188,30 @@ public class ServerNodeManager implements InitializingBean {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
// sync worker node info
|
|
|
|
|
Map<String, String> newWorkerNodeInfo = registryClient.getServerMaps(NodeType.WORKER, true); |
|
|
|
|
syncAllWorkerNodeInfo(newWorkerNodeInfo); |
|
|
|
|
|
|
|
|
|
// sync worker group nodes from database
|
|
|
|
|
List<WorkerGroup> workerGroupList = workerGroupMapper.queryAllWorkerGroup(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(workerGroupList)) { |
|
|
|
|
for (WorkerGroup wg : workerGroupList) { |
|
|
|
|
String workerGroup = wg.getName(); |
|
|
|
|
Set<String> nodes = new HashSet<>(); |
|
|
|
|
String[] addrs = wg.getAddrList().split(Constants.COMMA); |
|
|
|
|
for (String addr : addrs) { |
|
|
|
|
if (newWorkerNodeInfo.containsKey(addr)) { |
|
|
|
|
nodes.add(addr); |
|
|
|
|
try { |
|
|
|
|
// sync worker node info
|
|
|
|
|
Map<String, String> newWorkerNodeInfo = registryClient.getServerMaps(NodeType.WORKER, true); |
|
|
|
|
syncAllWorkerNodeInfo(newWorkerNodeInfo); |
|
|
|
|
|
|
|
|
|
// sync worker group nodes from database
|
|
|
|
|
List<WorkerGroup> workerGroupList = workerGroupMapper.queryAllWorkerGroup(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(workerGroupList)) { |
|
|
|
|
for (WorkerGroup wg : workerGroupList) { |
|
|
|
|
String workerGroup = wg.getName(); |
|
|
|
|
Set<String> nodes = new HashSet<>(); |
|
|
|
|
String[] addrs = wg.getAddrList().split(Constants.COMMA); |
|
|
|
|
for (String addr : addrs) { |
|
|
|
|
if (newWorkerNodeInfo.containsKey(addr)) { |
|
|
|
|
nodes.add(addr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!nodes.isEmpty()) { |
|
|
|
|
syncWorkerGroupNodes(workerGroup, nodes); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!nodes.isEmpty()) { |
|
|
|
|
syncWorkerGroupNodes(workerGroup, nodes); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.error("WorkerNodeInfoAndGroupDbSyncTask error:", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|