Search in sources :

Example 91 with Cluster

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);
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) Cluster(voldemort.cluster.Cluster) Test(org.junit.Test)

Example 92 with Cluster

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());
}
Also used : ArrayList(java.util.ArrayList) Cluster(voldemort.cluster.Cluster)

Example 93 with Cluster

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());
    }
}
Also used : Cluster(voldemort.cluster.Cluster) HashSet(java.util.HashSet)

Example 94 with Cluster

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);
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) Cluster(voldemort.cluster.Cluster) Test(org.junit.Test)

Example 95 with Cluster

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);
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) Cluster(voldemort.cluster.Cluster) Test(org.junit.Test)

Aggregations

Cluster (voldemort.cluster.Cluster)197 Test (org.junit.Test)74 StoreDefinition (voldemort.store.StoreDefinition)74 Node (voldemort.cluster.Node)72 ArrayList (java.util.ArrayList)51 HashMap (java.util.HashMap)47 ByteArray (voldemort.utils.ByteArray)33 AdminClient (voldemort.client.protocol.admin.AdminClient)26 ClusterTestUtils (voldemort.ClusterTestUtils)25 VoldemortException (voldemort.VoldemortException)24 List (java.util.List)23 ClusterMapper (voldemort.xml.ClusterMapper)23 File (java.io.File)20 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)18 Zone (voldemort.cluster.Zone)17 Versioned (voldemort.versioning.Versioned)17 Properties (java.util.Properties)16 IOException (java.io.IOException)15 VoldemortServer (voldemort.server.VoldemortServer)15 RoutingStrategyFactory (voldemort.routing.RoutingStrategyFactory)14