Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kvargha committed Feb 1, 2025
1 parent 74c9039 commit a8e9c6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ public void createVeniceControllerCluster() {
}
ClusterConfig clusterConfig = new ClusterConfig(controllerClusterName);
clusterConfig.getRecord().setBooleanField(ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN, true);
// Topology and fault zone type fields are used by CRUSH alg. Helix would apply the constrains on CRUSH alg to
// Topology and fault zone type fields are used by CRUSH alg. Helix would apply the constraints on CRUSH alg to
// choose proper instance to hold the replica.
clusterConfig.setTopologyAwareEnabled(false);
clusterConfig.setPersistBestPossibleAssignment(true);

if (!commonConfig.getHelixGlobalRebalancePreference().isEmpty()) {
if (commonConfig.getHelixGlobalRebalancePreference() != null) {
// We want to prioritize evenness over less movement when it comes to resource assignment, because the cost
// of rebalancing for the controller is cheap as it is stateless.
clusterConfig.setGlobalRebalancePreference(commonConfig.getHelixGlobalRebalancePreference());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,18 @@ public void testRebalancePreferenceAndCapacityKeys() throws NoSuchFieldException
}

@Test
public void testUndefinedRebalancePreferenceAndCapacityKeys() {
public void testUndefinedRebalancePreferenceAndCapacityKeys() throws NoSuchFieldException, IllegalAccessException {
when(zkHelixAdminClient.isVeniceControllerClusterCreated()).thenReturn(false);
when(mockHelixAdmin.addCluster(VENICE_CONTROLLER_CLUSTER, false)).thenReturn(true);

Properties clusterProperties = getBaseSingleRegionProperties(false);
VeniceControllerClusterConfig clusterConfig =
new VeniceControllerClusterConfig(new VeniceProperties(clusterProperties));

Field commonConfigsField = ZkHelixAdminClient.class.getDeclaredField("commonConfig");
commonConfigsField.setAccessible(true);
commonConfigsField.set(zkHelixAdminClient, clusterConfig);

doAnswer(invocation -> {
String controllerClusterName = invocation.getArgument(0);
ClusterConfig helixClusterConfig = invocation.getArgument(1);
Expand Down Expand Up @@ -358,7 +366,6 @@ public void testPartiallyDefinedRebalancePreference() throws NoSuchFieldExceptio

assertEquals(controllerClusterName, VENICE_CONTROLLER_CLUSTER);

// EVENNESS and LESS_MOVEMENT must be defined together. If not it will use Helix's default settings
Map<ClusterConfig.GlobalRebalancePreferenceKey, Integer> globalRebalancePreference =
helixClusterConfig.getGlobalRebalancePreference();
assertFalse(globalRebalancePreference.containsKey(ClusterConfig.GlobalRebalancePreferenceKey.EVENNESS));
Expand Down

0 comments on commit a8e9c6b

Please sign in to comment.