You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by li...@apache.org on 2020/01/27 13:09:26 UTC
[incubator-dolphinscheduler] branch dev updated: some updates for
TaskQueueZkImpl (#1874)
This is an automated email from the ASF dual-hosted git repository.
lidongdai pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 38eaaa9 some updates for TaskQueueZkImpl (#1874)
38eaaa9 is described below
commit 38eaaa98e689f1a84b416d39ea6e78140d56f2e2
Author: Tboy <gu...@immomo.com>
AuthorDate: Mon Jan 27 21:09:11 2020 +0800
some updates for TaskQueueZkImpl (#1874)
small changes, no need more people review, I will merge.
---
.../common/queue/TaskQueueZkImpl.java | 31 ++++++++--------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/queue/TaskQueueZkImpl.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/queue/TaskQueueZkImpl.java
index 5f834a2..d442c13 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/queue/TaskQueueZkImpl.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/queue/TaskQueueZkImpl.java
@@ -30,7 +30,7 @@ import java.util.*;
/**
* A singleton of a task queue implemented with zookeeper
- * tasks queue implemention
+ * tasks queue implementation
*/
@Service
public class TaskQueueZkImpl implements ITaskQueue {
@@ -72,7 +72,7 @@ public class TaskQueueZkImpl implements ITaskQueue {
} catch (Exception e) {
logger.error("get all tasks from tasks queue exception",e);
}
- return new ArrayList<>();
+ return Collections.emptyList();
}
/**
@@ -196,11 +196,11 @@ public class TaskQueueZkImpl implements ITaskQueue {
}
}
- List<String> taskslist = getTasksListFromTreeSet(tasksNum, taskTreeSet);
+ List<String> tasksList = getTasksListFromTreeSet(tasksNum, taskTreeSet);
- logger.info("consume tasks: {},there still have {} tasks need to be executed", Arrays.toString(taskslist.toArray()), size - taskslist.size());
+ logger.info("consume tasks: {},there still have {} tasks need to be executed", Arrays.toString(tasksList.toArray()), size - tasksList.size());
- return taskslist;
+ return tasksList;
}else{
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
}
@@ -208,7 +208,7 @@ public class TaskQueueZkImpl implements ITaskQueue {
} catch (Exception e) {
logger.error("add task to tasks queue exception",e);
}
- return new ArrayList<String>();
+ return Collections.emptyList();
}
@@ -221,15 +221,15 @@ public class TaskQueueZkImpl implements ITaskQueue {
public List<String> getTasksListFromTreeSet(int tasksNum, Set<String> taskTreeSet) {
Iterator<String> iterator = taskTreeSet.iterator();
int j = 0;
- List<String> taskslist = new ArrayList<>(tasksNum);
+ List<String> tasksList = new ArrayList<>(tasksNum);
while(iterator.hasNext()){
if(j++ >= tasksNum){
break;
}
String task = iterator.next();
- taskslist.add(getOriginTaskFormat(task));
+ tasksList.add(getOriginTaskFormat(task));
}
- return taskslist;
+ return tasksList;
}
/**
@@ -330,22 +330,13 @@ public class TaskQueueZkImpl implements ITaskQueue {
*/
@Override
public Set<String> smembers(String key) {
-
- Set<String> tasksSet = new HashSet<>();
-
try {
List<String> list = zookeeperOperator.getChildrenKeys(getTasksPath(key));
-
- for (String task : list) {
- tasksSet.add(task);
- }
-
- return tasksSet;
+ return new HashSet<>(list);
} catch (Exception e) {
logger.error("get all tasks from tasks queue exception",e);
}
-
- return tasksSet;
+ return Collections.emptySet();
}
/**