You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/05/17 19:37:40 UTC

[GitHub] [incubator-druid] himanshug commented on a change in pull request #7066: Support assign tasks to run on different tiers of MiddleManagers

himanshug 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_r285257388
 
 

 ##########
 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()));
 
 Review comment:
   nit: would be nice to extract this into a separate method from both versions of `selectWorker(..)` as this is a mouthful.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org