Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix partition assignment npe #2903

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,10 @@ public Map<String, StateModelDefinition> getStateModelDefMap() {
return _stateModelDefinitionCache.getPropertyMap();
}

public void setStateModelDefMap(Map<String, StateModelDefinition> stateModelDefMap) {
_stateModelDefinitionCache.setPropertyMap(stateModelDefMap);
}

/**
* Provides the idealstate for a given resource
* @param resourceName
Expand Down
9 changes: 6 additions & 3 deletions helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,16 @@ public static Map<String, Map<String, String>> getIdealAssignmentForFullAuto(
allNodes.add(instanceConfig.getInstanceName());
instanceConfigMap.put(instanceConfig.getInstanceName(), instanceConfig);
}
ResourceControllerDataProvider cache = new ResourceControllerDataProvider();
cache.setClusterConfig(clusterConfig);
cache.setInstanceConfigMap(instanceConfigMap);

// TODO: Consider full cache refresh to prevent needing to manually set necessary fields
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess core does not impact, right? Only rest?

Copy link
Contributor

Choose a reason for hiding this comment

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

Merge this change now for the 1.4.1 release. Please think of impact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method getIdealAssignmentForFullAuto is only called by ResourceAssignmentOptimizerAccessor in helix-rest module (the partitionAssignment API). It seems the only impact was partitionAssignment API calls for FULL_AUTO resources that are not on WAGED. Core should not be affected from what I've seen.

The equivalent ideal state calculation method used by partitionAssignment API for WAGED resources getAssignmentForWagedFullAutoImpl creates and fully refreshes the ResourceControllerDataProvider.

StateModelDefinition stateModelDefinition =
BuiltInStateModelDefinitions.valueOf(idealState.getStateModelDefRef())
.getStateModelDefinition();
ResourceControllerDataProvider cache = new ResourceControllerDataProvider(clusterConfig.getClusterName());
cache.setClusterConfig(clusterConfig);
cache.setInstanceConfigMap(instanceConfigMap);
cache.setIdealStates(Collections.singletonList(idealState));
cache.setStateModelDefMap(Collections.singletonMap(stateModelDefinition.getId(), stateModelDefinition));

RebalanceStrategy strategy =
RebalanceStrategy.class.cast(loadClass(HelixUtil.class, strategyClassName).newInstance());
Expand Down
Loading