Search in sources :

Example 51 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class AbstractZonedRebalanceTest method testRebalanceCleanPrimarySecondary.

@Test(timeout = 600000)
public void testRebalanceCleanPrimarySecondary() throws Exception {
    logger.info("Starting testRebalanceCleanPrimary");
    try {
        Cluster currentCluster = ServerTestUtils.getLocalZonedCluster(6, 2, new int[] { 0, 0, 0, 1, 1, 1 }, new int[][] { { 0 }, { 1, 6 }, { 2 }, { 3 }, { 4, 7 }, { 5 } });
        Cluster finalCluster = UpdateClusterUtils.createUpdatedCluster(currentCluster, 2, Lists.newArrayList(7));
        finalCluster = UpdateClusterUtils.createUpdatedCluster(finalCluster, 5, Lists.newArrayList(6));
        /**
         * original server partition ownership
         *
         * [s0 : p0,p3,p4,p5,p6,p7] [s1 : p1-p7] [s2 : p1,p2] [s3 :
         * p0,p1,p2,p3,p6,p7] [s4 : p1-p7] [s5 : p4,p5]
         *
         * final server partition ownership
         *
         * [s0 : p0,p2,p3,p4,p5,p6,p7] [s1 : p0,p1] [s2 : p1-p7] [s3 :
         * p0.p1,p2,p3,p5,p6,p7] [s4 : p0,p1,p2,p3,p4,p7] [s5 : p4,p5,p6]
         */
        // start servers
        List<Integer> serverList = Arrays.asList(0, 1, 2, 3, 4, 5);
        Map<String, String> configProps = new HashMap<String, String>();
        configProps.put("enable.repair", "true");
        currentCluster = startServers(currentCluster, rwStoreDefFileWithReplication, serverList, configProps);
        String bootstrapUrl = getBootstrapUrl(currentCluster, 0);
        ClusterTestUtils.RebalanceKit rebalanceKit = ClusterTestUtils.getRebalanceKit(bootstrapUrl, finalCluster);
        try {
            populateData(currentCluster, rwStoreDefWithReplication);
            AdminClient admin = rebalanceKit.controller.getAdminClient();
            List<ByteArray> p6KeySamples = sampleKeysFromPartition(admin, 1, rwStoreDefWithReplication.getName(), Arrays.asList(6), 20);
            List<ByteArray> p1KeySamples = sampleKeysFromPartition(admin, 1, rwStoreDefWithReplication.getName(), Arrays.asList(1), 20);
            List<ByteArray> p3KeySamples = sampleKeysFromPartition(admin, 0, rwStoreDefWithReplication.getName(), Arrays.asList(3), 20);
            List<ByteArray> p2KeySamples = sampleKeysFromPartition(admin, 1, rwStoreDefWithReplication.getName(), Arrays.asList(2), 20);
            List<ByteArray> p7KeySamples = sampleKeysFromPartition(admin, 4, rwStoreDefWithReplication.getName(), Arrays.asList(7), 20);
            rebalanceAndCheck(rebalanceKit.plan, rebalanceKit.controller, Arrays.asList(0, 1, 2, 3));
            checkConsistentMetadata(finalCluster, serverList);
            // Do the cleanup operation
            for (int i = 0; i < 6; i++) {
                admin.storeMntOps.repairJob(i);
            }
            // wait for the repairs to complete
            for (int i = 0; i < 6; i++) {
                ServerTestUtils.waitForAsyncOperationOnServer(serverMap.get(i), "Repair", 5000);
            }
            // confirm a primary movement in zone 0 : P6 : s1 -> S2. The
            // zone 0
            // primary changes when p6 moves cross zone
            // check for existence of p6 in server 2,
            checkForKeyExistence(admin, 2, rwStoreDefWithReplication.getName(), p6KeySamples);
            // confirm a secondary movement in zone 0.. p2 : s1 -> s0
            // check for its existence in server 0
            checkForKeyExistence(admin, 0, rwStoreDefWithReplication.getName(), p2KeySamples);
            // check for its absernce in server 1
            // also check that p1 is stable in server 1 [primary stability]
            checkForKeyExistence(admin, 1, rwStoreDefWithReplication.getName(), p1KeySamples);
            // check that p3 is stable in server 0 [Secondary stability]
            checkForKeyExistence(admin, 0, rwStoreDefWithReplication.getName(), p3KeySamples);
            // finally, test for server 4 which now became the secondary for
            // p7
            // from being a primary before
            checkForKeyExistence(admin, 4, rwStoreDefWithReplication.getName(), p7KeySamples);
        } finally {
            // stop servers
            stopServer(serverList);
        }
    } catch (AssertionError ae) {
        logger.error("Assertion broken in testRebalanceCleanPrimarySecondary ", ae);
        throw ae;
    }
}
Also used : HashMap(java.util.HashMap) Cluster(voldemort.cluster.Cluster) ClusterTestUtils(voldemort.ClusterTestUtils) ByteArray(voldemort.utils.ByteArray) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 52 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class AdminServiceBasicTest method testQuotaOpsForNode.

public void testQuotaOpsForNode(QuotaType quotaType) throws InterruptedException {
    AdminClient client = getAdminClient();
    String storeName = storeDefs.get(0).getName();
    Integer nodeId = 0;
    Long quota = 1000L;
    // test set quota
    client.quotaMgmtOps.setQuotaForNode(storeName, quotaType, nodeId, quota);
    Long getQuota = Long.parseLong(client.quotaMgmtOps.getQuotaForNode(storeName, quotaType, nodeId).getValue());
    assertEquals(quota, getQuota);
    // Sometimes the former set and the newer set are execute in same
    // millisecond which causes the later set to fail with
    // ObsoleteVersionException. Add 5ms sleep.
    Thread.sleep(5);
    // test reset quota
    quota = 10L;
    client.quotaMgmtOps.setQuotaForNode(storeName, quotaType, nodeId, quota);
    getQuota = Long.parseLong(client.quotaMgmtOps.getQuotaForNode(storeName, quotaType, nodeId).getValue());
    assertEquals(quota, getQuota);
    Thread.sleep(5);
    // test delete quota
    assertTrue(client.quotaMgmtOps.deleteQuotaForNode(storeName, quotaType, nodeId));
    Versioned<String> quotaVal = client.quotaMgmtOps.getQuotaForNode(storeName, quotaType, nodeId);
    assertEquals(null, quotaVal);
    Thread.sleep(5);
}
Also used : AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 53 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class AdminServiceBasicTest method testUpdateSingleStore.

@Test
public void testUpdateSingleStore() {
    doClientOperation();
    AdminClient client = getAdminClient();
    List<StoreDefinition> originalStoreDefinitions = client.metadataMgmtOps.getRemoteStoreDefList(0).getValue();
    StoreDefinition oldStore = getStoreDefinitionFromList(originalStoreDefinitions, "test-replication-memory");
    // Create a store definition for an existing store with different owners
    List<StoreDefinition> storesToBeUpdatedList = new ArrayList<StoreDefinition>();
    String storeName = "test-replication-memory";
    StoreDefinition definitionNew = new StoreDefinitionBuilder().setName(storeName).setType(InMemoryStorageConfiguration.TYPE_NAME).setKeySerializer(oldStore.getKeySerializer()).setValueSerializer(oldStore.getValueSerializer()).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(1).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).setOwners(Collections.singletonList("alice")).build();
    storesToBeUpdatedList.add(definitionNew);
    updateAndResetStoreDefinitions(storesToBeUpdatedList);
    doClientOperation();
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) StoreDefinition(voldemort.store.StoreDefinition) ArrayList(java.util.ArrayList) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 54 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class AdminServiceBasicTest method validateQuota.

private void validateQuota(String storeName) {
    AdminClient adminClient = getAdminClient();
    Versioned<String> value = adminClient.quotaMgmtOps.getQuota(storeName, QuotaType.STORAGE_SPACE);
    assertEquals("Default storage quota does not match", Long.toString(defaultStoreQuota), value.getValue());
}
Also used : AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 55 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class AdminServiceBasicTest method testFetchAndUpdateRW.

/**
 * Tests the basic RW fetch and update
 */
@Test
public void testFetchAndUpdateRW() {
    HashMap<ByteArray, byte[]> entrySet = ServerTestUtils.createRandomKeyValuePairs(TEST_STREAM_KEYS_SIZE);
    List<Integer> primaryMoved = Arrays.asList(0, 2);
    List<Integer> secondaryMoved = Arrays.asList(1, 4);
    List<Integer> combinedLists = Arrays.asList(0, 1, 2, 4);
    Cluster targetCluster = UpdateClusterUtils.createUpdatedCluster(cluster, 1, primaryMoved);
    HashMap<ByteArray, byte[]> keysMovedWith0AsSecondary = Maps.newHashMap();
    // insert it into server-0 store
    RoutingStrategy strategy = new RoutingStrategyFactory().updateRoutingStrategy(StoreDefinitionUtils.getStoreDefinitionWithName(storeDefs, "test-recovery-data"), cluster);
    Store<ByteArray, byte[], byte[]> store0 = getStore(0, "test-recovery-data");
    Store<ByteArray, byte[], byte[]> store1 = getStore(1, "test-recovery-data");
    for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) {
        store0.put(entry.getKey(), new Versioned<byte[]>(entry.getValue()), null);
        List<Integer> partitions = strategy.getPartitionList(entry.getKey().get());
        if (primaryMoved.contains(partitions.get(0)) || (secondaryMoved.contains(partitions.get(0)) && cluster.getNodeById(0).getPartitionIds().contains(partitions.get(1)))) {
            keysMovedWith0AsSecondary.put(entry.getKey(), entry.getValue());
        }
    }
    // Assert that server1 is empty.
    for (Entry<ByteArray, byte[]> entry : entrySet.entrySet()) assertEquals("server1 should be empty at start.", 0, store1.get(entry.getKey(), null).size());
    // Set some other metadata, so as to pick the right up later
    getServer(0).getMetadataStore().put(MetadataStore.CLUSTER_KEY, targetCluster);
    // Migrate the partition
    AdminClient client = getAdminClient();
    int id = client.storeMntOps.migratePartitions(0, 1, "test-recovery-data", combinedLists, null, cluster);
    client.rpcOps.waitForCompletion(1, id, 120, TimeUnit.SECONDS);
    // Check the values
    for (Entry<ByteArray, byte[]> entry : keysMovedWith0AsSecondary.entrySet()) {
        assertEquals("server1 store should contain fetchAndupdated partitions.", 1, store1.get(entry.getKey(), null).size());
        assertEquals("entry value should match", new String(entry.getValue()), new String(store1.get(entry.getKey(), null).get(0).getValue()));
    }
}
Also used : RoutingStrategyFactory(voldemort.routing.RoutingStrategyFactory) Cluster(voldemort.cluster.Cluster) RoutingStrategy(voldemort.routing.RoutingStrategy) ByteArray(voldemort.utils.ByteArray) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Aggregations

AdminClient (voldemort.client.protocol.admin.AdminClient)80 Test (org.junit.Test)35 Cluster (voldemort.cluster.Cluster)26 Node (voldemort.cluster.Node)26 Properties (java.util.Properties)19 StoreDefinition (voldemort.store.StoreDefinition)19 ArrayList (java.util.ArrayList)18 AdminClientConfig (voldemort.client.protocol.admin.AdminClientConfig)18 VoldemortException (voldemort.VoldemortException)17 IOException (java.io.IOException)14 Before (org.junit.Before)14 ByteArray (voldemort.utils.ByteArray)14 HashMap (java.util.HashMap)13 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)13 File (java.io.File)11 VoldemortServer (voldemort.server.VoldemortServer)11 ClientConfig (voldemort.client.ClientConfig)10 VectorClock (voldemort.versioning.VectorClock)10 Versioned (voldemort.versioning.Versioned)9 ClusterMapper (voldemort.xml.ClusterMapper)9