xiangfu0 opened a new pull request, #16433:
URL: https://github.com/apache/pinot/pull/16433

   ## Summary
   
   This PR enhances the  REST API endpoint with powerful filtering 
capabilities, allowing operators to filter task counts by execution state and 
target table.
   
   ## Changes
   
   ### 🚀 New Features
   - **State Filtering**: Filter by single or multiple comma-separated task 
states
     - Example: `?state=running` or `?state=running,error,waiting`
     - Supported states: waiting, running, error, completed, dropped, timedOut, 
aborted, unknown, total
   - **Table Filtering**: Filter tasks that have subtasks for specific tables
     - Example: `?table=myTable_OFFLINE`
     - Database-aware table name translation support
   - **Combined Filtering**: Use both filters together
     - Example: `?state=running&table=myTable_OFFLINE`
   
   ### 📝 API Examples
   ```bash
   # Original behavior (no filters) - returns all tasks
   GET /tasks/SegmentGenerationAndPushTask/taskcounts
   
   # Filter by single state
   GET /tasks/SegmentGenerationAndPushTask/taskcounts?state=running
   
   # Filter by multiple states  
   GET 
/tasks/SegmentGenerationAndPushTask/taskcounts?state=running,error,waiting
   
   # Filter by table
   GET /tasks/SegmentGenerationAndPushTask/taskcounts?table=myTable_OFFLINE
   
   # Combined filtering
   GET 
/tasks/SegmentGenerationAndPushTask/taskcounts?state=running,error&table=myTable_OFFLINE
   ```
   
   ### 🏗️ Implementation Details
   
   #### REST API Layer (`PinotTaskRestletResource.java`)
   - Added optional `state` and `table` query parameters
   - Enhanced API documentation with examples
   - Database context support via `DatabaseUtils.translateTableName()`
   - **Fully backward compatible** - existing API usage unchanged
   
   #### Backend Logic (`PinotHelixTaskResourceManager.java`)
   - New overloaded `getTaskCounts(taskType, state, tableNameWithType)` method
   - `validateState()` helper for upfront state validation with clear error 
messages
   - `hasTasksForTable()` helper for table filtering logic
   - Efficient filtering with early validation and proper exception handling
   
   #### Test Coverage (`PinotHelixTaskResourceManagerTest.java`)
   - **6 new comprehensive test methods** covering all scenarios:
     - Single state filtering
     - Multiple state filtering
     - Invalid state validation
     - Table-only filtering  
     - Combined state + table filtering
     - Edge cases (null values, exceptions, no matches)
   
   ## Benefits
   
   - **🎯 Precision Monitoring**: Get exactly the tasks needed for specific 
monitoring scenarios
   - **⚡ Performance**: Reduce response payload size through server-side 
filtering
   - **🔧 Operational Efficiency**: Enable targeted troubleshooting and resource 
planning
   - **🔄 Backward Compatibility**: All existing API usage continues to work 
unchanged
   - **💪 Robust**: Comprehensive input validation and error handling
   
   ## Use Cases
   
   1. **Problem Debugging**: `?state=error&table=problematicTable_OFFLINE`
   2. **Resource Planning**: `?state=running,waiting&table=largeTable_OFFLINE`  
   3. **Table-Specific Monitoring**: `?table=criticalTable_REALTIME`
   4. **Multi-State Analysis**: 
`?state=running,error,waiting&table=dailyReport_OFFLINE`
   
   ## Testing
   
   - ✅ All existing tests pass
   - ✅ 6 new comprehensive test methods
   - ✅ Checkstyle compliance  
   - ✅ Full compilation success
   - ✅ Backward compatibility verified
   
   ## Validation
   
   The implementation has been thoroughly tested with:
   - Single and multiple state filtering
   - Table filtering with various table names
   - Combined state and table filtering
   - Error cases and invalid inputs
   - Edge cases with null values and exceptions


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