AmatyaAvadhanula commented on code in PR #13476:
URL: https://github.com/apache/druid/pull/13476#discussion_r1045442636
##########
indexing-service/src/main/java/org/apache/druid/indexing/worker/executor/ExecutorLifecycle.java:
##########
@@ -108,7 +108,7 @@ public void start() throws InterruptedException
// pod twice, no need to lock.
if (taskExecutorConfig.isParentStreamDefined()) {
// Avoid running the same task twice on the same machine by locking the
task base directory.
- final File taskLockFile = taskConfig.getTaskLockFile(task.getId());
+ final File taskLockFile =
Preconditions.checkNotNull(taskExecutorConfig.getLockFile(), "lockFile");
Review Comment:
Done
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/BaseRestorableTaskRunner.java:
##########
@@ -173,24 +184,32 @@ public Collection<TaskRunnerWorkItem> getKnownTasks()
@GuardedBy("tasks")
protected void saveRunningTasks()
{
- final File restoreFile = getRestoreFile();
- final List<String> theTasks = new ArrayList<>();
+ final Map<File, List<String>> theTasks = new HashMap<>();
for (TaskRunnerWorkItem forkingTaskRunnerWorkItem : tasks.values()) {
- theTasks.add(forkingTaskRunnerWorkItem.getTaskId());
+ final String taskId = forkingTaskRunnerWorkItem.getTaskId();
+ final File restoreFile = getRestoreFile(taskId);
+ theTasks.computeIfAbsent(restoreFile, k -> new ArrayList<>())
+ .add(taskId);
}
- try {
- Files.createParentDirs(restoreFile);
- jsonMapper.writeValue(restoreFile, new TaskRestoreInfo(theTasks));
- }
- catch (Exception e) {
- LOG.warn(e, "Failed to save tasks to restore file[%s]. Skipping this
save.", restoreFile);
+ for (Map.Entry<File, List<String>> entry : theTasks.entrySet()) {
+ final File restoreFile = entry.getKey();
+ final TaskRestoreInfo taskRestoreInfo = new
TaskRestoreInfo(entry.getValue());
+ try {
+ Files.createParentDirs(restoreFile);
+ jsonMapper.writeValue(restoreFile, taskRestoreInfo);
+ LOG.info("Save restore file at [%s] for tasks [%s]",
+ restoreFile.getAbsoluteFile(),
Arrays.toString(theTasks.get(restoreFile).toArray()));
+ }
+ catch (Exception e) {
+ LOG.warn(e, "Failed to save tasks to restore file[%s]. Skipping this
save.", restoreFile);
+ }
}
}
- protected File getRestoreFile()
+ private File getRestoreFile(String taskId)
{
- return new File(taskConfig.getBaseTaskDir(), TASK_RESTORE_FILENAME);
+ return new File(taskConfig.getOrSelectTaskDir(taskId),
TASK_RESTORE_FILENAME);
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.
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]