Skip to content

Reduce PinotHelixResourceManager public APIs#17827

Open
krishan1390 wants to merge 2 commits intoapache:masterfrom
krishan1390:reduce_helix_resource_manager_apis
Open

Reduce PinotHelixResourceManager public APIs#17827
krishan1390 wants to merge 2 commits intoapache:masterfrom
krishan1390:reduce_helix_resource_manager_apis

Conversation

@krishan1390
Copy link
Contributor

There are currently 2 Public APIs of updateTableConfig and 3 APIs of setExistingTableConfig.

This makes overriding brittle and also makes clients harder to understand which API to call, so simplifying by keeping just one API for each method.

* @throws IOException
* @throws TableConfigBackwardIncompatibleException if config changes are backward incompatible
*/
public void updateTableConfig(TableConfig tableConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this method is more concise. Alternatively we can make it final to prevent wrong override. Directly removing it is backward incompatible

* @throws IOException
* @throws TableConfigBackwardIncompatibleException if config changes are backward incompatible and force is false
*/
public void updateTableConfig(TableConfig tableConfig, boolean force)
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems it won't throw IOException as well. Let's clean it up

@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.26%. Comparing base (3ca14f9) to head (2331828).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
...iodictask/RealtimeOffsetAutoResetKafkaHandler.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17827      +/-   ##
============================================
+ Coverage     63.20%   63.26%   +0.05%     
  Complexity     1456     1456              
============================================
  Files          3188     3189       +1     
  Lines        191736   191760      +24     
  Branches      29347    29354       +7     
============================================
+ Hits         121178   121308     +130     
+ Misses        61067    60971      -96     
+ Partials       9491     9481      -10     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-11 63.21% <50.00%> (+0.03%) ⬆️
java-21 63.22% <50.00%> (+0.05%) ⬆️
temurin 63.26% <50.00%> (+0.05%) ⬆️
unittests 63.25% <50.00%> (+0.05%) ⬆️
unittests1 55.60% <ø> (+0.04%) ⬆️
unittests2 34.22% <50.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies PinotHelixResourceManager’s public surface area by removing redundant overloads for updateTableConfig and setExistingTableConfig, updating controller code and tests to use the remaining canonical method signatures.

Changes:

  • Removed PinotHelixResourceManager.updateTableConfig(TableConfig) overload (keep updateTableConfig(TableConfig, boolean force)).
  • Removed PinotHelixResourceManager.setExistingTableConfig overloads (keep setExistingTableConfig(TableConfig, int expectedVersion, boolean force)).
  • Updated controller logic and test call sites to pass the new required parameters.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java Removes redundant public overloads, leaving one canonical API per operation.
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/periodictask/RealtimeOffsetAutoResetKafkaHandler.java Updates call to setExistingTableConfig with explicit args; removes now-unneeded IOException handling.
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java Updates table cleanup flow to call updateTableConfig(tableConfig, false).
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancerClusterStatelessTest.java Updates test call sites to use updateTableConfig(tableConfig, false).
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManagerStatelessTest.java Updates test call site to use updateTableConfig(tableConfig, false).
pinot-controller/src/test/java/org/apache/pinot/controller/helix/TableCacheTest.java Updates test call site to use updateTableConfig(tableConfig, false).
pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotInstanceAssignmentRestletResourceStatelessTest.java Updates test call sites to use setExistingTableConfig(tableConfig, -1, false).

realtimeTableConfig.setInstanceAssignmentConfigMap(
Collections.singletonMap(InstancePartitionsType.CONSUMING.toString(), consumingInstanceAssignmentConfig));
_helixResourceManager.setExistingTableConfig(realtimeTableConfig);
_helixResourceManager.setExistingTableConfig(realtimeTableConfig, -1, false);
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

This call hard-codes expectedVersion = -1 (ignore version check) and force = false. With the convenience overload removed, using named constants (or local variables) would make the test intent clearer and reduce repetition.

Copilot uses AI. Check for mistakes.
instanceAssignmentConfigMap.put(TIER_NAME, tierInstanceAssignmentConfig);
offlineTableConfig.setInstanceAssignmentConfigMap(instanceAssignmentConfigMap);
_helixResourceManager.setExistingTableConfig(offlineTableConfig);
_helixResourceManager.setExistingTableConfig(offlineTableConfig, -1, false);
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

Another use of magic -1 for expectedVersion (ignore version check). Suggest factoring out a constant in this test class to avoid repeating the sentinel value in multiple assertions/setup steps.

Copilot uses AI. Check for mistakes.
put(InstancePartitionsType.COMPLETED.toString(), offlineInstanceAssignmentConfig);
}});
_helixResourceManager.setExistingTableConfig(realtimeTableConfig);
_helixResourceManager.setExistingTableConfig(realtimeTableConfig, -1, false);
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

Another repeated setExistingTableConfig(..., -1, false) call. Consider replacing -1/false with named constants to make it obvious you're intentionally skipping the version check and not forcing backward-incompatible changes.

Copilot uses AI. Check for mistakes.
TableConfig currentTableConfig = _pinotHelixResourceManager.getTableConfig(tableNameWithType);
if (getOrAddBackfillTopic(newTopicStreamConfig, currentTableConfig)) {
_pinotHelixResourceManager.setExistingTableConfig(currentTableConfig);
_pinotHelixResourceManager.setExistingTableConfig(currentTableConfig, -1, false);
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

This call now hard-codes expectedVersion = -1 (ignore version check) and force = false. Since the overload that hid these defaults was removed, consider introducing named constants (e.g., IGNORE_VERSION_CHECK = -1, FORCE_UPDATE = false) to avoid magic values and clarify intent at the call site.

Copilot uses AI. Check for mistakes.
offlineTableConfig.setInstanceAssignmentConfigMap(
Collections.singletonMap(InstancePartitionsType.OFFLINE.toString(), offlineInstanceAssignmentConfig));
_helixResourceManager.setExistingTableConfig(offlineTableConfig);
_helixResourceManager.setExistingTableConfig(offlineTableConfig, -1, false);
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

This call now passes -1 for expectedVersion (ignore version check). Consider using a named constant in the test (e.g., IGNORE_VERSION_CHECK = -1) so the intent is clear and the value isn't duplicated across multiple calls.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants