You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2020/11/28 09:39:08 UTC

[GitHub] [incubator-dolphinscheduler] CalvinKirs commented on a change in pull request #4120: [Improvement][API] ignore noNodeException when get worker groups

CalvinKirs commented on a change in pull request #4120:
URL: https://github.com/apache/incubator-dolphinscheduler/pull/4120#discussion_r532011276



##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java
##########
@@ -120,30 +121,46 @@
         return result;
     }
 
-
     /**
-     *  get worker groups
+     * get worker groups
      *
      * @param isPaging whether paging
      * @return WorkerGroup list
      */
     private List<WorkerGroup> getWorkerGroups(boolean isPaging) {
-        String workerPath = zookeeperCachedOperator.getZookeeperConfig().getDsRoot()+"/nodes" +"/worker";
-        List<String> workerGroupList = zookeeperCachedOperator.getChildrenKeys(workerPath);
+
+        String workerPath = zookeeperCachedOperator.getZookeeperConfig().getDsRoot() + "/nodes" + "/worker";
+        List<WorkerGroup> workerGroups = new ArrayList<>();
+        List<String> workerGroupList;
+        try {
+            workerGroupList = zookeeperCachedOperator.getChildrenKeys(workerPath);
+        } catch (Exception e) {
+            if (e.getMessage().contains(noNodeExceptionRegex)) {

Review comment:
       It's best to pull it out here, and the code will be more readable.
   抽离这里的判断




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org