morningman commented on a change in pull request #333: Add distributor which
allocate task to be fairly
URL: https://github.com/apache/incubator-doris/pull/333#discussion_r235332160
##########
File path: fe/src/main/java/org/apache/doris/load/routineload/RoutineLoad.java
##########
@@ -107,37 +160,88 @@ public void addRoutineLoadTasks(List<RoutineLoadTask>
routineLoadTaskList) {
}
}
- public Map<Long, RoutineLoadTask> getIdToRoutineLoadTask() {
+ public Map<Long, RoutineLoadTaskInfo> getIdToRoutineLoadTask() {
return idToRoutineLoadTask;
}
- public void addNeedSchedulerRoutineLoadTasks(List<RoutineLoadTask>
routineLoadTaskList) {
+ public void addNeedSchedulerRoutineLoadTasks(List<RoutineLoadTaskInfo>
routineLoadTaskList, long routineLoadJobId) {
writeLock();
try {
-
idToNeedSchedulerRoutineLoadTask.putAll(routineLoadTaskList.parallelStream().collect(
- Collectors.toMap(task -> task.getSignature(), task ->
task)));
+ routineLoadTaskList.parallelStream().forEach(entity ->
needSchedulerRoutineLoadTask.add(entity));
+ routineLoadTaskList.parallelStream().forEach(entity ->
+ taskIdToJobId.put(entity.getSignature(),
routineLoadJobId));
} finally {
writeUnlock();
}
}
- public void removeRoutineLoadTasks(List<RoutineLoadTask> routineLoadTasks)
{
+ public void removeRoutineLoadTasks(List<RoutineLoadTaskInfo>
routineLoadTasks) {
if (routineLoadTasks != null) {
writeLock();
try {
routineLoadTasks.parallelStream().forEach(task ->
idToRoutineLoadTask.remove(task.getSignature()));
routineLoadTasks.parallelStream().forEach(task ->
-
idToNeedSchedulerRoutineLoadTask.remove(task.getSignature()));
+ needSchedulerRoutineLoadTask.remove(task));
+ routineLoadTasks.parallelStream().forEach(task ->
taskIdToJobId.remove(task.getSignature()));
} finally {
writeUnlock();
}
}
}
- public Map<Long, RoutineLoadTask> getIdToNeedSchedulerRoutineLoadTasks() {
+ public int getTotalIdleTaskNum() {
+ readLock();
+ try {
+ int result = 0;
+ initBeIdToMaxConcurrentTasks();
+ for (Map.Entry<Long, Integer> entry :
beIdToMaxConcurrentTasks.entrySet()) {
+ if (beIdToConcurrentTasks.get(entry.getKey()) == null) {
+ result += entry.getValue();
+ } else {
+ result += entry.getValue() -
beIdToConcurrentTasks.get(entry.getKey());
+ }
+ }
+ return result;
+ } finally {
+ readUnlock();
+ }
+ }
+
+ public long getMinTaskBeId() {
+ readLock();
+ try {
+ long result = 0L;
+ int maxIdelTaskNum = 0;
+ initBeIdToMaxConcurrentTasks();
+ for (Map.Entry<Long, Integer> entry :
beIdToMaxConcurrentTasks.entrySet()) {
+ if (beIdToConcurrentTasks.get(entry.getKey()) == null) {
+ result = maxIdelTaskNum < entry.getValue() ?
entry.getKey() : result;
+ maxIdelTaskNum = Math.max(maxIdelTaskNum,
entry.getValue());
Review comment:
check all 'idel' misspelling, please...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]