From 8200a3f15ab5c7de0ea8e4d356ce968c6380e42a Mon Sep 17 00:00:00 2001 From: xiangzihao <460888207@qq.com> Date: Fri, 18 Feb 2022 21:46:52 +0800 Subject: [PATCH] add try catch (#8433) --- .../master/registry/ServerNodeManager.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java index 02f7f980cc..c9c9ce5d3d 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java @@ -188,26 +188,30 @@ public class ServerNodeManager implements InitializingBean { @Override public void run() { - // sync worker node info - Map newWorkerNodeInfo = registryClient.getServerMaps(NodeType.WORKER, true); - syncAllWorkerNodeInfo(newWorkerNodeInfo); - - // sync worker group nodes from database - List workerGroupList = workerGroupMapper.queryAllWorkerGroup(); - if (CollectionUtils.isNotEmpty(workerGroupList)) { - for (WorkerGroup wg : workerGroupList) { - String workerGroup = wg.getName(); - Set 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 newWorkerNodeInfo = registryClient.getServerMaps(NodeType.WORKER, true); + syncAllWorkerNodeInfo(newWorkerNodeInfo); + + // sync worker group nodes from database + List workerGroupList = workerGroupMapper.queryAllWorkerGroup(); + if (CollectionUtils.isNotEmpty(workerGroupList)) { + for (WorkerGroup wg : workerGroupList) { + String workerGroup = wg.getName(); + Set 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); } } }