Search in sources :

Example 96 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class RepartitionerTest method testShuffleWithinZoneWithNonContiguousZoneAndNodeIds.

@Test
public void testShuffleWithinZoneWithNonContiguousZoneAndNodeIds() {
    // Two zone cluster
    Cluster currentCluster = ClusterTestUtils.getZ1Z3ImbalancedClusterWithNonContiguousNodeIds();
    List<StoreDefinition> storeDefs = ClusterTestUtils.getZ1Z3StoreDefsInMemory();
    List<Integer> swapZoneIds = new ArrayList<Integer>();
    // Only shuffle within zone 1
    swapZoneIds.add(1);
    verifyRandomSwapsWithinZoneOnlyShufflesPartitionsInThatZone(currentCluster, storeDefs, swapZoneIds);
    // Three zone cluster
    currentCluster = ClusterTestUtils.getZ1Z3Z5ImbalancedClusterWithNonContiguousNodeIds();
    storeDefs = ClusterTestUtils.getZ1Z3Z5StoreDefsInMemory();
    // Shuffle only within zone 3
    swapZoneIds.clear();
    swapZoneIds.add(3);
    verifyRandomSwapsWithinZoneOnlyShufflesPartitionsInThatZone(currentCluster, storeDefs, swapZoneIds);
    // Shuffle only within zone 1, 3
    swapZoneIds.clear();
    swapZoneIds.add(1);
    swapZoneIds.add(3);
    verifyRandomSwapsWithinZoneOnlyShufflesPartitionsInThatZone(currentCluster, storeDefs, swapZoneIds);
    // Shuffle only within zone 1, 3, 5 
    swapZoneIds.clear();
    swapZoneIds.add(1);
    swapZoneIds.add(3);
    swapZoneIds.add(5);
    verifyRandomSwapsWithinZoneOnlyShufflesPartitionsInThatZone(currentCluster, storeDefs, swapZoneIds);
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) ArrayList(java.util.ArrayList) Cluster(voldemort.cluster.Cluster) Test(org.junit.Test)

Example 97 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class RepartitionerTest method verifyBalanceNodesNotZones.

/**
     * Verify balancing of partitions among nodes without balancing partitions
     * among zones.
     * 
     * @param currentCluster
     * @param currentStores
     * @param interimCluster
     * @param finalStores
     */
public void verifyBalanceNodesNotZones(Cluster currentCluster, List<StoreDefinition> currentStores, Cluster interimCluster, List<StoreDefinition> finalStores) {
    // Confirm current cluster is imbalanced on all fronts:
    assertFalse(verifyNodesBalancedInEachZone(currentCluster));
    assertFalse(verifyZonesBalanced(currentCluster));
    // Repartition to balance partition IDs among zones and among nodes
    // within zone.
    boolean disableNodeBalancing = false;
    boolean disableZoneBalancing = true;
    Cluster repartitionedCluster = Repartitioner.repartition(currentCluster, currentStores, interimCluster, finalStores, null, 1, disableNodeBalancing, disableZoneBalancing, false, 0, 0, Collections.<Integer>emptyList(), false, 0, 0, 0, Collections.<Integer>emptyList(), 0);
    assertTrue(verifyNodesBalancedInEachZone(repartitionedCluster));
    assertFalse(verifyZonesBalanced(repartitionedCluster));
}
Also used : Cluster(voldemort.cluster.Cluster)

Example 98 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class ZoneCLipperTest method testDropZoneIdWorks.

@Test
public void testDropZoneIdWorks() {
    // Create a list of current partition ids. We will use this set to
    // compare partitions ids with the interim cluster
    Set<Integer> originalPartitions = new HashSet<Integer>();
    for (Integer zoneId : initialCluster.getZoneIds()) {
        originalPartitions.addAll(initialCluster.getPartitionIdsInZone(zoneId));
    }
    // Get an intermediate cluster where partitions that belong to the zone
    // that is being dropped have been moved to the existing zones
    Cluster interimCluster = RebalanceUtils.vacateZone(initialCluster, dropZoneId);
    // Make sure that the intermediate cluster should have same number of
    // partitions
    RebalanceUtils.validateClusterPartitionCounts(initialCluster, interimCluster);
    // Make sure that the intermediate cluster should have same number of
    // nodes
    RebalanceUtils.validateClusterNodeCounts(initialCluster, interimCluster);
    // Make sure that the intermediate cluster doesn't have any partitions in
    // the dropped zone
    assertTrue("Zone being dropped has partitions. ZoneClipper didn't work properly", interimCluster.getPartitionIdsInZone(dropZoneId).isEmpty());
    // Make sure that the nodes being dropped don't host any partitions
    for (Integer nodeId : interimCluster.getNodeIdsInZone(dropZoneId)) {
        assertTrue("Nodes in the zone being dropped don't have empty partitions list", interimCluster.getNodeById(nodeId).getPartitionIds().isEmpty());
    }
    Set<Integer> finalPartitions = new HashSet<Integer>();
    for (Integer zoneId : interimCluster.getZoneIds()) {
        finalPartitions.addAll(interimCluster.getPartitionIdsInZone(zoneId));
    }
    // Compare to original partition ids list
    assertTrue("Original and interm partition ids don't match", originalPartitions.equals(finalPartitions));
    // Make sure that there is no data movement
    RebalancePlan rebalancePlan = ClusterTestUtils.makePlan(initialCluster, storeDefs, interimCluster, storeDefs);
    // Make sure we have a plan
    assertEquals(rebalancePlan.getPlan().size(), 1);
    // Make sure there is no cross zones between zones in the plan
    assertEquals(rebalancePlan.getPartitionStoresMovedXZone(), 0);
    // Make sure there is no data movement between nodes
    assertEquals(rebalancePlan.getPartitionStoresMoved(), 0);
    for (Integer nodeId : interimCluster.getNodeIds()) {
        Set<Integer> remainingNodes = Sets.symmetricDifference(interimCluster.getNodeIds(), Sets.newHashSet(nodeId));
        for (Integer otherNodeId : remainingNodes) {
            assertTrue("Something went wrong as there is data movement between nodes", rebalancePlan.getNodeMoveMap().get(nodeId, otherNodeId) == 0);
        }
    }
    // Also get the adjusted store definitions, with the zone dropped
    Cluster finalCluster = RebalanceUtils.dropZone(interimCluster, dropZoneId);
    List<StoreDefinition> clippedStoreDefs = RebalanceUtils.dropZone(storeDefs, dropZoneId);
    for (StoreDefinition storeDef : clippedStoreDefs) {
        StoreDefinition orgStoreDef = StoreDefinitionUtils.getStoreDefinitionWithName(storeDefs, storeDef.getName());
        assertFalse("Clipped storedef has replication for dropped zone", storeDef.getZoneReplicationFactor().containsKey(dropZoneId));
        assertEquals("Clipped storedef has incorrect number of zones", initialCluster.getZones().size() - 1, storeDef.getZoneReplicationFactor().size());
        assertEquals("Clipped storedef has incorrect total repfactor", orgStoreDef.getReplicationFactor() - orgStoreDef.getZoneReplicationFactor().get(dropZoneId), storeDef.getReplicationFactor());
    }
    // Confirm that we would not route to any of the dropped nodes for any
    // store.
    Set<Integer> dropNodes = interimCluster.getNodeIdsInZone(dropZoneId);
    for (StoreDefinition storeDef : clippedStoreDefs) {
        StoreRoutingPlan routingPlan = new StoreRoutingPlan(finalCluster, storeDef);
        Node[] partitionToNode = finalCluster.getPartitionIdToNodeArray();
        for (int p = 0; p < partitionToNode.length; p++) {
            List<Integer> replicaNodes = routingPlan.getReplicationNodeList(p);
            assertFalse("Should not be routing to any dropped nodes", replicaNodes.removeAll(dropNodes));
        }
    }
}
Also used : RebalancePlan(voldemort.client.rebalance.RebalancePlan) StoreRoutingPlan(voldemort.routing.StoreRoutingPlan) StoreDefinition(voldemort.store.StoreDefinition) Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 99 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class ChainedInconsistencyResolverTest method setUp.

@Before
public void setUp() throws IOException {
    boolean useNio = false;
    int numServers = 2;
    VoldemortServer[] servers = new VoldemortServer[numServers];
    Cluster cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, null, socketStoreFactory, useNio, null, STORES_XML, new Properties());
    // Initialize versioned puts for basic test
    v1 = getVersioned(0, 1, 1, 1, 1, 1);
    v2 = getVersioned(0, 0, 1, 1, 1, 1);
    // Initialize versioned puts for > 1 conflicts
    conflict1 = getVersioned(0, 1, 1, 1, 1, 1, 1, 1, 1, 1);
    conflict2 = getVersioned(0, 0, 1, 1, 1, 1, 1, 1, 1, 1);
    conflict3 = getVersioned(0, 0, 0, 1, 1, 1, 1, 1, 1, 1);
    conflict4 = getVersioned(0, 0, 0, 0, 1, 1, 1, 1, 1, 1);
    conflict5 = getVersioned(0, 0, 0, 0, 0, 1, 1, 1, 1, 1);
    conflict6 = getVersioned(0, 0, 0, 0, 0, 0, 1, 1, 1, 1);
    Node node = cluster.getNodes().iterator().next();
    String bootstrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
    StoreClientFactory storeClientFactory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));
    defaultStoreClient = storeClientFactory.getStoreClient("test");
    socketStore = ServerTestUtils.getSocketStore(socketStoreFactory, "test", node.getSocketPort(), RequestFormatType.VOLDEMORT_V1);
}
Also used : SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) VoldemortServer(voldemort.server.VoldemortServer) Properties(java.util.Properties) ClientConfig(voldemort.client.ClientConfig) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) StoreClientFactory(voldemort.client.StoreClientFactory) Before(org.junit.Before)

Example 100 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class HandoffToAnyStrategyTest method testRouteHint.

@Test
public void testRouteHint() {
    Cluster cluster = VoldemortTestConstants.getNineNodeCluster();
    HintedHandoffStrategy handoffStrategy = new HandoffToAnyStrategy(cluster, false, 0);
    for (Node origin : cluster.getNodes()) {
        List<Node> nodes = handoffStrategy.routeHint(origin);
        assertTrue("hint preflist is correctly sized", nodes.size() == cluster.getNumberOfNodes() - 1);
        assertFalse("hint preflist doesn't include self", nodes.contains(origin));
    }
}
Also used : Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) HandoffToAnyStrategy(voldemort.store.slop.strategy.HandoffToAnyStrategy) HintedHandoffStrategy(voldemort.store.slop.strategy.HintedHandoffStrategy) 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