use of voldemort.cluster.Cluster in project voldemort by voldemort.
the class RepartitionerTest method testClusterExpansion.
@Test
public void testClusterExpansion() {
// Two zone cluster
Cluster currentCluster = ClusterTestUtils.getZZCluster();
Cluster interimCluster = ClusterTestUtils.getZZClusterWithNN();
List<StoreDefinition> storeDefs = ClusterTestUtils.getZZStoreDefsInMemory();
verifyBalanceZoneAndNode(currentCluster, storeDefs, interimCluster, storeDefs);
verifyBalanceNodesNotZones(currentCluster, storeDefs, interimCluster, storeDefs);
verifyRepartitionNoop(currentCluster, storeDefs, interimCluster, storeDefs);
// Three zone cluster
currentCluster = ClusterTestUtils.getZZZCluster();
interimCluster = ClusterTestUtils.getZZZClusterWithNNN();
storeDefs = ClusterTestUtils.getZZZStoreDefsInMemory();
verifyBalanceZoneAndNode(currentCluster, storeDefs, interimCluster, storeDefs);
verifyBalanceNodesNotZones(currentCluster, storeDefs, interimCluster, storeDefs);
verifyRepartitionNoop(currentCluster, storeDefs, interimCluster, storeDefs);
}
use of voldemort.cluster.Cluster in project voldemort by voldemort.
the class RepartitionerTest method verifyGreedySwapsImproveBalance.
/**
* Verify that greedy swaps improve balance.
*
* @param currentCluster
* @param currentStores
*/
public void verifyGreedySwapsImproveBalance(Cluster currentCluster, List<StoreDefinition> currentStores) {
// Confirm current cluster is imbalanced on all fronts:
assertFalse(verifyNodesBalancedInEachZone(currentCluster));
assertFalse(verifyZonesBalanced(currentCluster));
PartitionBalance currentPb = new PartitionBalance(currentCluster, currentStores);
// Greedy test 1: Do greedy for each zone in cluster
// Disable basic balancing among zones & nodes
boolean disableNodeBalancing = true;
boolean disableZoneBalancing = true;
// Do some greedy swaps!
boolean enableGreedySwaps = true;
// For each zone
List<Integer> greedyZones = new ArrayList<Integer>(currentCluster.getZoneIds());
int swapAttempts = 1;
int swapsPerNode = 100;
int swapsPerZone = 100;
Cluster repartitionedCluster = Repartitioner.repartition(currentCluster, currentStores, currentCluster, currentStores, null, 1, disableNodeBalancing, disableZoneBalancing, false, 0, 0, null, enableGreedySwaps, swapAttempts, swapsPerNode, swapsPerZone, greedyZones, 0);
// Confirm repartitioned cluster is still imbalanced on all fronts
assertFalse(verifyNodesBalancedInEachZone(repartitionedCluster));
assertFalse(verifyZonesBalanced(repartitionedCluster));
// Confirm overall balance has been improved
PartitionBalance repartitionedPb = new PartitionBalance(repartitionedCluster, currentStores);
assertTrue(repartitionedPb.getUtility() < currentPb.getUtility());
// Greedy test 2: Only do greedy for a single zone.
greedyZones = new ArrayList<Integer>();
greedyZones.add(currentCluster.getZoneIds().iterator().next());
repartitionedCluster = Repartitioner.repartition(currentCluster, currentStores, currentCluster, currentStores, null, 1, disableNodeBalancing, disableZoneBalancing, false, 0, 0, null, enableGreedySwaps, swapAttempts, swapsPerNode, swapsPerZone, greedyZones, 0);
// Confirm repartitioned cluster is still imbalanced on all fronts
assertFalse(verifyNodesBalancedInEachZone(repartitionedCluster));
assertFalse(verifyZonesBalanced(repartitionedCluster));
// Confirm overall balance has been improved
repartitionedPb = new PartitionBalance(repartitionedCluster, currentStores);
assertTrue(repartitionedPb.getUtility() < currentPb.getUtility());
// Greedy test 3: Greedy overall nodes in cluster (rather than
// zone-by-zone)
greedyZones = Collections.<Integer>emptyList();
repartitionedCluster = Repartitioner.repartition(currentCluster, currentStores, currentCluster, currentStores, null, 1, disableNodeBalancing, disableZoneBalancing, false, 0, 0, null, enableGreedySwaps, swapAttempts, swapsPerNode, swapsPerZone, greedyZones, 0);
// Confirm repartitioned cluster is still imbalanced on all fronts
assertFalse(verifyNodesBalancedInEachZone(repartitionedCluster));
assertFalse(verifyZonesBalanced(repartitionedCluster));
// Confirm overall balance has been improved
repartitionedPb = new PartitionBalance(repartitionedCluster, currentStores);
assertTrue(repartitionedPb.getUtility() < currentPb.getUtility());
}
use of voldemort.cluster.Cluster in project voldemort by voldemort.
the class RepartitionerTest method verifyRandomSwapsWithinZoneOnlyShufflesPartitionsInThatZone.
/**
* Verify that random swaps within improve balance
*
* @param currentCluster
* @param currentStores
* @param swapZoneIds
*/
public void verifyRandomSwapsWithinZoneOnlyShufflesPartitionsInThatZone(Cluster currentCluster, List<StoreDefinition> currentStores, List<Integer> swapZoneIds) {
PartitionBalance currentPb = new PartitionBalance(currentCluster, currentStores);
// Disable basic balancing among zones & nodes
boolean disableNodeBalancing = true;
boolean disableZoneBalancing = true;
// Do some random swaps within zone
boolean enableRandomSwaps = true;
int swapAttempts = 100;
int swapSuccesses = 10;
Cluster repartitionedCluster = Repartitioner.repartition(currentCluster, currentStores, currentCluster, currentStores, null, 1, disableNodeBalancing, disableZoneBalancing, enableRandomSwaps, swapAttempts, swapSuccesses, swapZoneIds, false, 0, 0, 0, Collections.<Integer>emptyList(), 0);
PartitionBalance repartitionedPb = new PartitionBalance(repartitionedCluster, currentStores);
Set<Integer> allNodeIds = repartitionedCluster.getNodeIds();
Set<Integer> swapNodeIds = null;
for (Integer swapZoneId : swapZoneIds) {
swapNodeIds = repartitionedCluster.getNodeIdsInZone(swapZoneId);
}
// Remove nodes that we don't want to verify the partition count on
allNodeIds.removeAll(swapNodeIds);
for (Integer remainingNodeId : allNodeIds) {
Set<Integer> beforeRepartition = new HashSet<Integer>(currentCluster.getNodeById(remainingNodeId).getPartitionIds());
Set<Integer> afterRepartition = new HashSet<Integer>(currentCluster.getNodeById(remainingNodeId).getPartitionIds());
assertTrue(beforeRepartition.equals(afterRepartition));
assertTrue(repartitionedPb.getUtility() <= currentPb.getUtility());
}
}
use of voldemort.cluster.Cluster in project voldemort by voldemort.
the class RepartitionerTest method testZoneExpansionAsRepartitionerCLI.
@Test
public void testZoneExpansionAsRepartitionerCLI() {
Cluster currentCluster = ClusterTestUtils.getZZCluster();
List<StoreDefinition> currentStoreDefs = ClusterTestUtils.getZZStoreDefsInMemory();
Cluster interimCluster = ClusterTestUtils.getZZZClusterWithNNN();
List<StoreDefinition> finalStoreDefs = ClusterTestUtils.getZZZStoreDefsInMemory();
verifyBalanceZoneAndNode(currentCluster, currentStoreDefs, interimCluster, finalStoreDefs);
// verifyBalanceNodesNotZones does not make sense for zone expansion.
verifyRepartitionNoop(currentCluster, currentStoreDefs, interimCluster, finalStoreDefs);
}
use of voldemort.cluster.Cluster in project voldemort by voldemort.
the class RepartitionerTest method testZoneExpansionAsRebalanceControllerCLI.
@Test
public void testZoneExpansionAsRebalanceControllerCLI() {
Cluster currentCluster = ClusterTestUtils.getZZECluster();
List<StoreDefinition> currentStoreDefs = ClusterTestUtils.getZZZStoreDefsInMemory();
Cluster interimCluster = ClusterTestUtils.getZZZClusterWithNNN();
List<StoreDefinition> finalStoreDefs = ClusterTestUtils.getZZZStoreDefsInMemory();
verifyBalanceZoneAndNode(currentCluster, currentStoreDefs, interimCluster, finalStoreDefs);
// verifyBalanceNodesNotZones does not make sense for zone expansion.
verifyRepartitionNoop(currentCluster, currentStoreDefs, interimCluster, finalStoreDefs);
}
Aggregations