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_r235324530
##########
File path: fe/src/main/java/org/apache/doris/load/routineload/RoutineLoad.java
##########
@@ -71,23 +78,69 @@ public RoutineLoad() {
idToRunningRoutineLoadJob = Maps.newHashMap();
idToCancelledRoutineLoadJob = Maps.newHashMap();
idToRoutineLoadTask = Maps.newHashMap();
- idToNeedSchedulerRoutineLoadTask = Maps.newHashMap();
+ needSchedulerRoutineLoadTask = Queues.newLinkedBlockingQueue();
+ beIdToConcurrentTasks = Maps.newHashMap();
+ taskIdToJobId = Maps.newHashMap();
lock = new ReentrantReadWriteLock(true);
}
+ public void initBeIdToMaxConcurrentTasks() {
+ if (beIdToMaxConcurrentTasks == null) {
+ beIdToMaxConcurrentTasks =
Catalog.getCurrentSystemInfo().getBackendIds(true)
+ .parallelStream().collect(Collectors.toMap(beId -> beId,
beId -> DEFAULT_BE_CONCURRENT_TASK_NUM));
+ }
+ }
+
public int getTotalMaxConcurrentTaskNum() {
readLock();
try {
- if (beIdToMaxConcurrentTasks == null) {
- beIdToMaxConcurrentTasks =
Catalog.getCurrentSystemInfo().getBackendIds(true)
- .parallelStream().collect(Collectors.toMap(beId ->
beId, beId -> DEFAULT_BE_CONCURRENT_TASK_NUM));
- }
+ initBeIdToMaxConcurrentTasks();
return beIdToMaxConcurrentTasks.values().stream().mapToInt(i ->
i).sum();
} finally {
readUnlock();
}
}
+ public void updateBeIdTaskMaps() {
+ writeLock();
+ try {
+ initBeIdToMaxConcurrentTasks();
+ List<Long> beIds =
Catalog.getCurrentSystemInfo().getBackendIds(true);
+
+ // diff beIds and beIdToMaxConcurrentTasks.keys()
+ List<Long> newBeIds = beIds.parallelStream().filter(entity ->
beIdToMaxConcurrentTasks.get(entity) == null)
+ .collect(Collectors.toList());
+ List<Long> decommissionBeIds =
beIdToMaxConcurrentTasks.keySet().parallelStream()
+ .filter(entity -> !beIds.contains(entity))
+ .collect(Collectors.toList());
+ newBeIds.parallelStream().forEach(entity ->
beIdToMaxConcurrentTasks.put(entity, DEFAULT_BE_CONCURRENT_TASK_NUM));
+ for (long beId : decommissionBeIds) {
+ beIdToMaxConcurrentTasks.remove(beId);
+ beIdToConcurrentTasks.remove(beId);
+ }
+ LOG.info("There are {} backends which participate in routine load
scheduler. "
+ + "There are {} new bes and {} decommission bes
for routine load",
Review comment:
change 'decommission'
----------------------------------------------------------------
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]