Skip to content

Commit

Permalink
Minor tweak to dealing with contiguous runs of partitions.
Browse files Browse the repository at this point in the history
- Hard code 10 repeated attempts to get rid of contiguous partitions.
- Added a TODO to do something perfect at some unspecified time in the future...
  • Loading branch information
jayjwylie committed Mar 20, 2013
1 parent 10d57ac commit 796aa5d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/java/voldemort/utils/RebalanceClusterUtils.java
Expand Up @@ -554,26 +554,29 @@ public static Cluster balancePrimaryPartitionsPerNode(final Cluster targetCluste
* Loops over cluster and repeatedly tries to break up contiguous runs of
* partitions. After each phase of breaking up contiguous partitions, random
* partitions are selected to move between zones to balance the number of
* partitions in each zone. This process loops until no partitions move
* across zones.
* partitions in each zone. The second phase may re-introduce contiguous
* partition runs in another zone. Therefore, this overall process is
* repeated multiple times.
*
* @param nextCluster
* @param maxContiguousPartitionsPerZone See RebalanceCLI.
* @return
*/
public static Cluster repeatedlyBalanceContiguousPartitionsPerZone(final Cluster targetCluster,
final int maxContiguousPartitionsPerZone) {
int contigPartitionsMoved = 0;
// TODO: Make this loop definitive. I.e., ensure that
// maxContiguousPartitionsPerZone is truly met.
System.out.println("Looping to evenly balance partitions across zones while limiting contiguous partitions");
int repeatContigBalance = 10;
Cluster nextCluster = targetCluster;
do {
for(int i = 0; i < repeatContigBalance; i++) {
nextCluster = balanceContiguousPartitionsPerZone(nextCluster,
maxContiguousPartitionsPerZone);

nextCluster = balanceNumPartitionsPerZone(nextCluster);

System.out.println("Looping to evenly balance partitions across zones while limiting contiguous partitions: "
+ contigPartitionsMoved);
} while(contigPartitionsMoved > 0);
System.out.println("Completed round of balancing contiguous partitions: round "
+ (i + 1) + " of " + repeatContigBalance);
}

return nextCluster;
}
Expand Down

0 comments on commit 796aa5d

Please sign in to comment.