QiuMM commented on a change in pull request #7066: Support assign tasks to run 
on different tiers of MiddleManagers
URL: https://github.com/apache/incubator-druid/pull/7066#discussion_r332020155
 
 

 ##########
 File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/setup/WorkerSelectUtils.java
 ##########
 @@ -95,6 +95,79 @@ public static ImmutableWorkerInfo selectWorker(
     }
   }
 
+  /**
+   * Helper for {@link WorkerSelectStrategy} implementations.
+   *
+   * @param allWorkers     map of all workers, in the style provided to {@link 
WorkerSelectStrategy}
+   * @param workerTierSpec worker tier spec, or null
+   * @param workerSelector function that receives a list of eligible workers: 
version is high enough, worker can run
+   *                       the task, and worker satisfies the worker tier 
spec. may return null.
+   *
+   * @return selected worker from "allWorkers", or null.
+   */
+  @Nullable
+  public static ImmutableWorkerInfo selectWorker(
+      final Task task,
+      final Map<String, ImmutableWorkerInfo> allWorkers,
+      final WorkerTaskRunnerConfig workerTaskRunnerConfig,
+      @Nullable final WorkerTierSpec workerTierSpec,
+      final Function<ImmutableMap<String, ImmutableWorkerInfo>, 
ImmutableWorkerInfo> workerSelector
+  )
+  {
+    // Workers that could potentially run this task, ignoring workerTierSpec.
+    final Map<String, ImmutableWorkerInfo> runnableWorkers = allWorkers
+        .values()
+        .stream()
+        .filter(worker -> worker.canRunTask(task)
+                          && 
worker.isValidVersion(workerTaskRunnerConfig.getMinWorkerVersion()))
+        .collect(Collectors.toMap(w -> w.getWorker().getHost(), 
Function.identity()));
+
+    // select worker according to worker tier spec
+    if (workerTierSpec != null && workerTierSpec.getTierMap() != null) {
+      final WorkerTierSpec.TierConfig tierConfig = workerTierSpec.getTierMap()
+                                                                 .getOrDefault(
+                                                                     
task.getType(),
+                                                                     new 
WorkerTierSpec.TierConfig(null, null)
 
 Review comment:
   Fixed.

----------------------------------------------------------------
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]

Reply via email to