Skip to content
Merged

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import org.apache.druid.segment.incremental.ParseExceptionReport;
import org.apache.druid.segment.incremental.RowIngestionMetersFactory;
import org.apache.druid.segment.indexing.DataSchema;
import org.apache.druid.utils.CollectionUtils;
import org.joda.time.DateTime;
import org.joda.time.Duration;

Expand Down Expand Up @@ -4309,24 +4310,22 @@ public void setPartitionIdsForTests(
}

/**
* Get all active tasks from metadata storage
* Get all active tasks either from memory or metadata store, if not cached.
*
* @return map from taskId to Task
*/
private Map<String, Task> getActiveTaskMap()
{
final ImmutableMap.Builder<String, Task> activeTaskMap = ImmutableMap.builder();
final Optional<TaskQueue> taskQueue = taskMaster.getTaskQueue();
final List<Task> tasks;
if (taskQueue.isPresent()) {
tasks = taskQueue.get().getActiveTasksForDatasource(dataSource);
return taskQueue.get().getActiveTasksForDatasource(dataSource);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably remove line 4296 and 4298 and fold them inside the else at 4301. The resulting method would be much leaner.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified.

} else {
tasks = taskStorage.getActiveTasksByDatasource(dataSource);
}
for (Task task : tasks) {
activeTaskMap.put(task.getId(), task);
return CollectionUtils.toMap(
taskStorage.getActiveTasksByDatasource(dataSource),
Task::getId,
task -> task
);
}
return activeTaskMap.build();
}

/**
Expand Down
Loading