Search in sources :

Example 31 with AdminClient

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

the class EndToEndRebootstrapTest method testEndToEndRebootstrap.

/*
     * Test to validate that the client bootstraps on metadata change. 
     * 1. Do some operations to validate that the client is correctly initialized.
     * 2. Update the cluster.xml using the Admin Tool (which should update the
     *    metadata version as well). 
     * 3. Verify that the client bootstraps after this update.
     * 4. Whether the client has automatically bootstrapped is verified by checking
     * the new bootstrap time in the client registry.
     */
@Test
public void testEndToEndRebootstrap() {
    try {
        sanityTestClientOps();
        // Get bootstraptime at start
        String bootstrapTime = getPropertyFromClientInfo("bootstrapTime");
        // Update cluster.xml metadata
        ClientConfig clientConfig = new ClientConfig().setBootstrapUrls(bootStrapUrls).setClientZoneId(CLIENT_ZONE_ID);
        AdminClient adminClient = new AdminClient(clientConfig);
        for (Node node : cluster.getNodes()) {
            VoldemortAdminTool.executeSetMetadata(node.getId(), adminClient, CLUSTER_KEY, new ClusterMapper().writeCluster(cluster));
        }
        // Wait for about 15 seconds to be sure
        try {
            Thread.sleep(15000);
        } catch (Exception e) {
            fail("Interrupted .");
        }
        // Get bootstraptime again
        String newBootstrapTime = getPropertyFromClientInfo("bootstrapTime");
        assertFalse(bootstrapTime.equals(newBootstrapTime));
        long origTime = Long.parseLong(bootstrapTime);
        long newTime = Long.parseLong(newBootstrapTime);
        assertTrue(newTime > origTime);
    } catch (Exception e) {
        fail("Error in validating end to end client rebootstrap : " + e);
    }
}
Also used : Node(voldemort.cluster.Node) ClusterMapper(voldemort.xml.ClusterMapper) VoldemortException(voldemort.VoldemortException) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 32 with AdminClient

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

the class EndToEndRebootstrapTest method testEndToEndRebootstrapWithSetMetadataPair.

/*
     * Test to validate that the client bootstraps on metadata change. 
     * 1. Do some operations to validate that the client is correctly initialized.
     * 2. Update the <cluster.xml, stores.xml> pair using the Admin Tool. 
     * 3. Verify that the client bootstraps after this update.
     * 4. Whether the client has automatically bootstrapped is verified by checking
     *    the new bootstrap time in the client registry.
     */
@Test
public void testEndToEndRebootstrapWithSetMetadataPair() {
    try {
        sanityTestClientOps();
        // Get bootstraptime at start
        String bootstrapTime = getPropertyFromClientInfo("bootstrapTime");
        // Update cluster.xml metadata
        ClientConfig clientConfig = new ClientConfig().setBootstrapUrls(bootStrapUrls).setClientZoneId(CLIENT_ZONE_ID);
        AdminClient adminClient = new AdminClient(clientConfig);
        StoreDefinitionsMapper storeDefsMapper = new StoreDefinitionsMapper();
        List<StoreDefinition> storeDefs = storeDefsMapper.readStoreList(new File(storesXmlfile));
        for (Node node : cluster.getNodes()) {
            VoldemortAdminTool.executeSetMetadataPair(node.getId(), adminClient, CLUSTER_KEY, new ClusterMapper().writeCluster(cluster), STORES_KEY, storeDefsMapper.writeStoreList(storeDefs));
        }
        // Wait for about 15 seconds to be sure
        try {
            Thread.sleep(15000);
        } catch (Exception e) {
            fail("Interrupted .");
        }
        // Get bootstraptime again
        String newBootstrapTime = getPropertyFromClientInfo("bootstrapTime");
        assertFalse(bootstrapTime.equals(newBootstrapTime));
        long origTime = Long.parseLong(bootstrapTime);
        long newTime = Long.parseLong(newBootstrapTime);
        assertTrue(newTime > origTime);
    } catch (Exception e) {
        fail("Error in validating end to end client rebootstrap : " + e);
    }
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) Node(voldemort.cluster.Node) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ClusterMapper(voldemort.xml.ClusterMapper) File(java.io.File) VoldemortException(voldemort.VoldemortException) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 33 with AdminClient

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

the class OfflineStateTest method testStateTransitions.

@Test
public void testStateTransitions() throws Exception {
    AdminClient client = getAdminClient();
    assertTrue(testOnlineTraffic());
    assertTrue(testSlopStreaming());
    toOfflineState(client);
    assertFalse(testOnlineTraffic());
    assertFalse(testSlopStreaming());
    toNormalState(client);
    assertTrue(testOnlineTraffic());
    assertTrue(testSlopStreaming());
    toOfflineState(client);
    assertFalse(testOnlineTraffic());
    assertFalse(testSlopStreaming());
    toNormalState(client);
    assertTrue(testOnlineTraffic());
    assertTrue(testSlopStreaming());
    toOfflineState(client);
    assertFalse(testOnlineTraffic());
    assertFalse(testSlopStreaming());
    toNormalState(client);
    assertTrue(testOnlineTraffic());
    assertTrue(testSlopStreaming());
}
Also used : AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 34 with AdminClient

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

the class QuotaResetterTest method setUp.

@Before
public void setUp() throws IOException {
    int numServers = 2;
    servers = new VoldemortServer[numServers];
    int[][] partitionMap = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } };
    Properties serverProperties = new Properties();
    serverProperties.setProperty("client.max.connections.per.node", "20");
    serverProperties.setProperty("enforce.retention.policy.on.read", Boolean.toString(false));
    cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, true, null, storesXmlfile, serverProperties);
    List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile));
    this.storeNames = Sets.newHashSet();
    for (StoreDefinition storeDef : storeDefs) {
        storeNames.add(storeDef.getName());
    }
    Properties adminProperties = new Properties();
    adminProperties.setProperty("max_connections", "20");
    adminClient = new AdminClient(cluster, new AdminClientConfig(adminProperties));
}
Also used : AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) StoreDefinition(voldemort.store.StoreDefinition) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Properties(java.util.Properties) File(java.io.File) AdminClient(voldemort.client.protocol.admin.AdminClient) Before(org.junit.Before)

Example 35 with AdminClient

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

the class AdminServiceBasicTest method testUpdateClusterMetadata.

@Test
public void testUpdateClusterMetadata() {
    Cluster updatedCluster = ServerTestUtils.getLocalCluster(4);
    AdminClient client = getAdminClient();
    for (int i = 0; i < NUM_RUNS; i++) {
        VectorClock existingClock = ((VectorClock) client.metadataMgmtOps.getRemoteCluster(0).getVersion());
        VectorClock clock = existingClock.incremented(0, System.currentTimeMillis());
        client.metadataMgmtOps.updateRemoteCluster(0, updatedCluster, clock);
        assertEquals("Cluster should match", updatedCluster, getVoldemortServer(0).getMetadataStore().getCluster());
        assertEquals("AdminClient.getMetdata() should match", client.metadataMgmtOps.getRemoteCluster(0).getValue(), updatedCluster);
        // version should match
        assertEquals("versions should match as well.", clock, client.metadataMgmtOps.getRemoteCluster(0).getVersion());
    }
}
Also used : VectorClock(voldemort.versioning.VectorClock) Cluster(voldemort.cluster.Cluster) 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