Skip to content

Conversation

@rmdmattingly
Copy link
Collaborator

I'll rebase this PR to master when HBASE-29071 has shipped. This is yet another bite of apache#6593

@rmdmattingly rmdmattingly requested a review from ndimiduk January 14, 2025 19:56
Comment on lines -163 to -164
assertFalse(loadBalancer.needsBalance(HConstants.ENSEMBLE_TABLE_NAME,
new BalancerClusterState(map, null, null, new ForTestRackManagerOne())));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was just naively swapped to assertFalse in HBASE-26327 when we began ignoring rack colocation. The intention was originally for this case to be true

Comment on lines 150 to 157
BalancerClusterState cluster = new BalancerClusterState(map, null, null, null);
loadBalancer.initCosts(cluster);
assertTrue(loadBalancer.needsBalance(HConstants.ENSEMBLE_TABLE_NAME, cluster));
}

@Test
public void testNeedsBalanceForColocatedReplicasOnRack() {
// check for the case where there are two hosts and with one rack, and where
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is really two distinct tests that were previously in one method, so I've split it up.

Comment on lines 175 to 197
@Test
public void testNoNeededBalanceForColocatedReplicasTooFewRacks() {
// Three hosts, two racks, and three replicas for a region. This cannot be balanced
List<RegionInfo> regions = randomRegions(1);
ServerName s1 = ServerName.valueOf("host1", 1000, 11111);
ServerName s2 = ServerName.valueOf("host11", 1000, 11111);
ServerName s3 = ServerName.valueOf("host2", 1000, 11111);
Map<ServerName, List<RegionInfo>> map = new HashMap<>();
List<RegionInfo> regionsOnS2 = new ArrayList<>(1);
regionsOnS2.add(RegionReplicaUtil.getRegionInfoForReplica(regions.get(0), 1));
map.put(s1, regions);
map.put(s2, regionsOnS2);
// there are 3 replicas for region 0, but only add a second rack
map.put(s3, ImmutableList.of(RegionReplicaUtil.getRegionInfoForReplica(regions.get(0), 2)));
BalancerClusterState cluster = new BalancerClusterState(map, null, null, null);
loadBalancer.initCosts(cluster);
// Should be false because there aren't enough racks
assertFalse(loadBalancer.needsBalance(HConstants.ENSEMBLE_TABLE_NAME, cluster));
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This new test validates our smarter way of deprioritizing rack balancing for topologies with too few racks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants