AmatyaAvadhanula commented on code in PR #12473:
URL: https://github.com/apache/druid/pull/12473#discussion_r857654957


##########
indexing-service/src/main/java/org/apache/druid/indexing/common/config/TaskConfig.java:
##########
@@ -184,14 +228,48 @@ public String getBaseDir()
   }
 
   @JsonProperty
-  public File getBaseTaskDir()
+  public List<StorageLocationConfig> getBaseTaskDirLocations()
+  {
+    return baseTaskDirLocations;
+  }
+
+  public List<StorageLocationConfig> getBaseTaskDirChildrenLocations(String 
child)
+  {
+    return getBaseTaskDirLocations().stream()
+                                    .map(location -> new StorageLocationConfig(
+                                        getChildFileFromLocation(location, 
child),
+                                        location.getMaxSize(),
+                                        location.getFreeSpacePercent()))
+                                    .collect(Collectors.toList());
+  }
+
+  private File getChildFileFromLocation(StorageLocationConfig location, String 
child)
+  {
+    return new File(location.getPath(), child);
+  }
+
+  private StorageLocationConfig getBaseTaskDirLocationForId(String taskId)
+  {
+    if (taskId == null) {
+      return null;
+    }
+    // TODO: consider the size of each of the base locations for distribution
+    // use uniformly RANDOM assignment
+    int index = taskId.hashCode() % baseTaskDirLocations.size();
+    if (index < 0) {
+      index = -(index + 1);
+    }
+    return baseTaskDirLocations.get(index);
+  }
+
+  public File getTaskBaseDir(String taskId)
   {
-    return baseTaskDir;
+    return getBaseTaskDirLocationForId(taskId).getPath();
   }
 
   public File getTaskDir(String taskId)
   {
-    return new File(baseTaskDir, taskId);
+    return new File(getTaskBaseDir(taskId), taskId);

Review Comment:
   Ah yes, sorry. I'll add the check



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to