kangkaisen commented on a change in pull request #1613: Refactor alter job
process
URL: https://github.com/apache/incubator-doris/pull/1613#discussion_r312053102
##########
File path: fe/src/main/java/org/apache/doris/task/AgentBatchTask.java
##########
@@ -101,6 +104,47 @@ public int getTaskNum() {
return num;
}
+ // return true only if all tasks are finished.
+ // NOTICE that even if AgentTask.isFinished() return false, it does not
mean that task is not finished.
+ // this depends on caller's logic. See comments on 'isFinished' member.
+ public boolean isFinished() {
+ for (List<AgentTask> tasks : this.backendIdToTasks.values()) {
+ for (AgentTask agentTask : tasks) {
+ if (!agentTask.isFinished()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ // return the limit number of unfinished tasks.
+ public List<AgentTask> getUnfinishedTasks(int limit) {
+ List<AgentTask> res = Lists.newArrayList();
+ for (List<AgentTask> tasks : this.backendIdToTasks.values()) {
+ for (AgentTask agentTask : tasks) {
+ if (!agentTask.isFinished()) {
+ if (res.size() < limit) {
+ res.add(agentTask);
+ }
Review comment:
```suggestion
} else {
break;
}
```
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]