Jackie-Jiang commented on code in PR #16433:
URL: https://github.com/apache/pinot/pull/16433#discussion_r2237844068
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java:
##########
@@ -267,8 +270,21 @@ public SuccessResponse deleteTaskMetadataByTable(
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Fetch count of sub-tasks for each of the tasks for the given
task type")
public Map<String, PinotHelixTaskResourceManager.TaskCount> getTaskCounts(
- @ApiParam(value = "Task type", required = true) @PathParam("taskType")
String taskType) {
- return _pinotHelixTaskResourceManager.getTaskCounts(taskType);
+ @ApiParam(value = "Task type", required = true) @PathParam("taskType")
String taskType,
+ @ApiParam(value = "Task state(s) to filter by. Can be single state or
comma-separated multiple states "
+ + "(NOT_STARTED, IN_PROGRESS, STOPPED, STOPPING, FAILED, COMPLETED,
ABORTED, TIMED_OUT, TIMING_OUT, "
+ + "FAILING). Example: 'IN_PROGRESS' or
'IN_PROGRESS,FAILED,STOPPING'")
+ @QueryParam("state") @Nullable String state,
+ @ApiParam(value = "Table name with type (e.g., 'myTable_OFFLINE') to
filter tasks by table. "
+ + "Only tasks that have subtasks for this table will be returned.")
+ @QueryParam("table") @Nullable String table, @Context HttpHeaders
headers) {
+ String tableNameWithType = table != null ?
DatabaseUtils.translateTableName(table, headers) : null;
+
+ if (state != null || tableNameWithType != null) {
Review Comment:
Consider using `StringUtils.isNotEmpty()`
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotHelixTaskResourceManager.java:
##########
@@ -776,6 +776,120 @@ public synchronized Map<String, TaskCount>
getTaskCounts(String taskType) {
return taskCounts;
}
+ /**
+ * Fetch count of sub-tasks for each of the tasks for the given taskType,
filtered by state.
+ *
+ * @param taskType Pinot taskType / Helix JobQueue
+ * @param state State(s) to filter by. Can be single state or
comma-separated multiple states
+ * (waiting, running, error, completed, dropped,
timedOut, aborted, unknown, total)
+ * @return Map of Pinot Task Name to TaskCount containing only tasks that
have > 0 count for any of the
+ * specified states
+ */
+ public synchronized Map<String, TaskCount> getTaskCounts(String taskType,
String state) {
+ return getTaskCounts(taskType, state, null);
+ }
+
+ /**
+ * Fetch count of sub-tasks for each of the tasks for the given taskType,
filtered by state and/or table.
+ *
+ * @param taskType Pinot taskType / Helix JobQueue
+ * @param state State(s) to filter by. Can be single state or
comma-separated multiple states
+ * (NOT_STARTED, IN_PROGRESS, STOPPED, STOPPING,
FAILED, COMPLETED, ABORTED, TIMED_OUT,
+ * TIMING_OUT, FAILING). Can be null to skip state
filtering.
+ * @param tableNameWithType Table name with type to filter by. Only tasks
that have subtasks for this table
+ * will be returned. Can be null to skip table
filtering.
+ * @return Map of Pinot Task Name to TaskCount containing only tasks that
match the specified filters
+ */
+ public synchronized Map<String, TaskCount> getTaskCounts(String taskType,
String state, String tableNameWithType) {
Review Comment:
Add `@Nullable` to `state` and `tableNameWithType`
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotHelixTaskResourceManager.java:
##########
@@ -776,6 +776,120 @@ public synchronized Map<String, TaskCount>
getTaskCounts(String taskType) {
return taskCounts;
}
+ /**
+ * Fetch count of sub-tasks for each of the tasks for the given taskType,
filtered by state.
+ *
+ * @param taskType Pinot taskType / Helix JobQueue
+ * @param state State(s) to filter by. Can be single state or
comma-separated multiple states
+ * (waiting, running, error, completed, dropped,
timedOut, aborted, unknown, total)
+ * @return Map of Pinot Task Name to TaskCount containing only tasks that
have > 0 count for any of the
+ * specified states
+ */
+ public synchronized Map<String, TaskCount> getTaskCounts(String taskType,
String state) {
+ return getTaskCounts(taskType, state, null);
+ }
+
+ /**
+ * Fetch count of sub-tasks for each of the tasks for the given taskType,
filtered by state and/or table.
+ *
+ * @param taskType Pinot taskType / Helix JobQueue
+ * @param state State(s) to filter by. Can be single state or
comma-separated multiple states
+ * (NOT_STARTED, IN_PROGRESS, STOPPED, STOPPING,
FAILED, COMPLETED, ABORTED, TIMED_OUT,
+ * TIMING_OUT, FAILING). Can be null to skip state
filtering.
+ * @param tableNameWithType Table name with type to filter by. Only tasks
that have subtasks for this table
+ * will be returned. Can be null to skip table
filtering.
+ * @return Map of Pinot Task Name to TaskCount containing only tasks that
match the specified filters
+ */
+ public synchronized Map<String, TaskCount> getTaskCounts(String taskType,
String state, String tableNameWithType) {
+ Set<String> tasks = getTasks(taskType);
+ if (tasks == null) {
+ return Collections.emptyMap();
+ }
+
+ // Parse and validate comma-separated states if provided
+ Set<TaskState> requestedStates = null;
+ if (state != null) {
Review Comment:
Use `StringUtils.isNotEmpty()`
--
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]