Search in sources :

Example 26 with StoreDefinitionsMapper

use of voldemort.xml.StoreDefinitionsMapper 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 27 with StoreDefinitionsMapper

use of voldemort.xml.StoreDefinitionsMapper 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 28 with StoreDefinitionsMapper

use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.

the class AdminRebalanceTest method startFourNodeRO.

public void startFourNodeRO() throws IOException {
    storeDef1 = new StoreDefinitionBuilder().setName("test").setType(ReadOnlyStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
    storeDef2 = new StoreDefinitionBuilder().setName("test2").setType(ReadOnlyStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(3).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
    File tempStoreXml = new File(TestUtils.createTempDir(), "stores.xml");
    FileUtils.writeStringToFile(tempStoreXml, new StoreDefinitionsMapper().writeStoreList(Lists.newArrayList(storeDef1, storeDef2)));
    int numServers = 4;
    servers = new VoldemortServer[numServers];
    int[][] partitionMap = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, {} };
    currentCluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, useNio, null, tempStoreXml.getAbsolutePath(), new Properties());
    finalCluster = UpdateClusterUtils.createUpdatedCluster(currentCluster, 3, Lists.newArrayList(0));
    RebalanceBatchPlan plan = new RebalanceBatchPlan(currentCluster, finalCluster, Lists.newArrayList(storeDef1, storeDef2));
    plans = Lists.newArrayList(plan.getBatchPlan());
    adminClient = ServerTestUtils.getAdminClient(currentCluster);
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Properties(java.util.Properties) File(java.io.File) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Example 29 with StoreDefinitionsMapper

use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.

the class AdminRebalanceTest method startFourNodeRORW.

public void startFourNodeRORW() throws IOException {
    storeDef1 = new StoreDefinitionBuilder().setName("test").setType(ReadOnlyStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
    storeDef2 = new StoreDefinitionBuilder().setName("test2").setType(ReadOnlyStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(3).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
    storeDef3 = ServerTestUtils.getStoreDef("test3", 2, 1, 1, 1, 1, RoutingStrategyType.CONSISTENT_STRATEGY);
    storeDef4 = ServerTestUtils.getStoreDef("test4", 3, 1, 1, 1, 1, RoutingStrategyType.CONSISTENT_STRATEGY);
    File tempStoreXml = new File(TestUtils.createTempDir(), "stores.xml");
    FileUtils.writeStringToFile(tempStoreXml, new StoreDefinitionsMapper().writeStoreList(Lists.newArrayList(storeDef1, storeDef2, storeDef3, storeDef4)));
    int numServers = 4;
    servers = new VoldemortServer[numServers];
    int[][] partitionMap = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, {} };
    currentCluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, useNio, null, tempStoreXml.getAbsolutePath(), new Properties());
    finalCluster = UpdateClusterUtils.createUpdatedCluster(currentCluster, 3, Lists.newArrayList(0));
    // Make plan only with RO stores
    RebalanceBatchPlan plan = new RebalanceBatchPlan(currentCluster, finalCluster, Lists.newArrayList(storeDef1, storeDef2));
    plans = plan.getBatchPlan();
    adminClient = ServerTestUtils.getAdminClient(currentCluster);
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Properties(java.util.Properties) File(java.io.File) SerializerDefinition(voldemort.serialization.SerializerDefinition)

Example 30 with StoreDefinitionsMapper

use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.

the class RebalanceMetadataConsistencyTest method setUp.

@Before
public void setUp() {
    currentCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0 }, { 1, 3 }, { 2 } });
    finalCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0 }, { 1 }, { 2 }, { 3 } });
    rwStoreDefWithReplication = new StoreDefinitionBuilder().setName(testStoreNameRW).setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
    Store<String, String, String> innerStore = new InMemoryStorageEngine<String, String, String>("inner-store");
    innerStore.put(MetadataStore.CLUSTER_KEY, new Versioned<String>(new ClusterMapper().writeCluster(currentCluster)), null);
    innerStore.put(MetadataStore.STORES_KEY, new Versioned<String>(new StoreDefinitionsMapper().writeStoreList(Lists.newArrayList(rwStoreDefWithReplication))), null);
    rwStoreDefWithReplication2 = new StoreDefinitionBuilder().setName(testStoreNameRW2).setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
    metadataStore = MetadataStore.createInMemoryMetadataStore(innerStore, 0);
    rebalancer = new Rebalancer(null, metadataStore, null, null);
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) Rebalancer(voldemort.server.rebalance.Rebalancer) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ClusterMapper(voldemort.xml.ClusterMapper) SerializerDefinition(voldemort.serialization.SerializerDefinition) Before(org.junit.Before)

Aggregations

StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)82 StoreDefinition (voldemort.store.StoreDefinition)50 File (java.io.File)44 StringReader (java.io.StringReader)29 ClusterMapper (voldemort.xml.ClusterMapper)26 Before (org.junit.Before)19 Cluster (voldemort.cluster.Cluster)18 Properties (java.util.Properties)16 VoldemortException (voldemort.VoldemortException)15 Test (org.junit.Test)14 Node (voldemort.cluster.Node)14 AdminClient (voldemort.client.protocol.admin.AdminClient)13 ArrayList (java.util.ArrayList)12 StoreDefinitionBuilder (voldemort.store.StoreDefinitionBuilder)12 IOException (java.io.IOException)10 OptionSet (joptsimple.OptionSet)9 VoldemortServer (voldemort.server.VoldemortServer)9 ByteArray (voldemort.utils.ByteArray)9 HashMap (java.util.HashMap)8 SerializerDefinition (voldemort.serialization.SerializerDefinition)8