github-advanced-security[bot] commented on code in PR #20735:
URL: https://github.com/apache/druid/pull/20735#discussion_r4380426938


##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java:
##########
@@ -927,36 +927,19 @@
     }
   }
 
-  private Map<String, RowKey> getCurrentTaskDatasources()
+  public Map<RowKey, Long> getRunningTaskCount()
   {
-    return activeTasks.values().stream()
-                      .filter(entry -> !entry.isComplete)
-                      .map(TaskEntry::getTask)
-                      .collect(Collectors.toMap(Task::getId, 
TaskQueue::getMetricKey));
+    return getTaskCountByMetricKey(taskRunner.getRunningTasks());
   }
 
-  public Map<RowKey, Long> getRunningTaskCount()
+  public Map<RowKey, Long> getPendingTaskCount()
   {
-    final Map<String, RowKey> taskDatasources = getCurrentTaskDatasources();
-    return taskRunner.getRunningTasks()
-                     .stream()
-                     .collect(Collectors.toMap(
-                         e -> taskDatasources.getOrDefault(e.getTaskId(), 
RowKey.empty()),
-                         e -> 1L,
-                         Long::sum
-                     ));
+    return getTaskCountByMetricKey(taskRunner.getPendingTasks());
   }
 
-  public Map<RowKey, Long> getPendingTaskCount()
+  private Map<RowKey, Long> getTaskCountByMetricKey(final Collection<? extends 
TaskRunnerWorkItem> workItems)
   {
-    final Map<String, RowKey> taskDatasources = getCurrentTaskDatasources();
-    return taskRunner.getPendingTasks()
-                     .stream()
-                     .collect(Collectors.toMap(
-                         e -> taskDatasources.getOrDefault(e.getTaskId(), 
RowKey.empty()),
-                         e -> 1L,
-                         Long::sum
-                     ));
+    return 
workItems.stream().collect(Collectors.toMap(this::getWorkItemMetricKey, e -> 
1L, Long::sum));

Review Comment:
   ## CodeQL / Useless parameter
   
   The parameter 'e' is never used.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/12122)



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