Search in sources :

Example 76 with StoreDefinitionsMapper

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

the class ServerTestUtils method createServerConfigWithDefs.

public static VoldemortConfig createServerConfigWithDefs(boolean useNio, int nodeId, String baseDir, Cluster cluster, List<StoreDefinition> stores, Properties properties) throws IOException {
    File clusterXml = new File(TestUtils.createTempDir(), "cluster.xml");
    File storesXml = new File(TestUtils.createTempDir(), "stores.xml");
    ClusterMapper clusterMapper = new ClusterMapper();
    StoreDefinitionsMapper storeDefMapper = new StoreDefinitionsMapper();
    FileWriter writer = new FileWriter(clusterXml);
    writer.write(clusterMapper.writeCluster(cluster));
    writer.close();
    writer = new FileWriter(storesXml);
    writer.write(storeDefMapper.writeStoreList(stores));
    writer.close();
    return createServerConfig(useNio, nodeId, baseDir, clusterXml.getAbsolutePath(), storesXml.getAbsolutePath(), properties);
}
Also used : FileWriter(java.io.FileWriter) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ClusterMapper(voldemort.xml.ClusterMapper) File(java.io.File)

Example 77 with StoreDefinitionsMapper

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

the class TestUtils method makeSingleNodeRoutingStrategy.

/**
     * Provides a routing strategy for local tests to work with
     * 
     * @return
     */
public static RoutingStrategy makeSingleNodeRoutingStrategy() {
    Cluster cluster = VoldemortTestConstants.getOneNodeCluster();
    StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
    List<StoreDefinition> storeDefs = mapper.readStoreList(new StringReader(VoldemortTestConstants.getSingleStoreDefinitionsXml()));
    return new RoutingStrategyFactory().updateRoutingStrategy(storeDefs.get(0), cluster);
}
Also used : RoutingStrategyFactory(voldemort.routing.RoutingStrategyFactory) StoreDefinition(voldemort.store.StoreDefinition) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) StringReader(java.io.StringReader) Cluster(voldemort.cluster.Cluster)

Example 78 with StoreDefinitionsMapper

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

the class AdminServiceBasicTest method testFetchSingleStoreFromAdminClient.

@Test
public void testFetchSingleStoreFromAdminClient() {
    String storeName = "test-replication-memory";
    StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
    for (int nodeId : this.cluster.getNodeIds()) {
        Versioned<String> storeDef = adminClient.metadataMgmtOps.getRemoteMetadata(nodeId, storeName);
        List<StoreDefinition> def = mapper.readStoreList(new StringReader(storeDef.getValue()));
        assertEquals(def.get(0).getName(), storeName);
    }
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 79 with StoreDefinitionsMapper

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

the class AdminServiceMultiJVMTest method setUp.

@Override
@Before
public void setUp() throws IOException {
    cluster = ServerTestUtils.getLocalCluster(2);
    voldemortHome = ServerJVMTestUtils.createAndInitializeVoldemortHome(useNio, 0, storesXmlfile, cluster);
    List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile));
    storeDef = StoreDefinitionUtils.getStoreDefinitionWithName(storeDefs, testStoreName);
    pid = ServerJVMTestUtils.startServerJVM(socketStoreFactory, cluster.getNodeById(0), voldemortHome);
    adminClient = ServerTestUtils.getAdminClient(cluster);
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) File(java.io.File) Before(org.junit.Before)

Example 80 with StoreDefinitionsMapper

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

the class AtomicSetMetadataPairTest method testClusterAndStoresAreSetAtomically.

/**
     * Bug fix: The old approach tried to test store metadata update by
     * replacing an existing stores.xml with a completely different stores.xml.
     * This has been fixed such that, the new stores.xml is the same as the
     * original, except for required replication factor = 2.
     * 
     */
@Test
public void testClusterAndStoresAreSetAtomically() {
    try {
        AdminClient adminClient = new AdminClient(bootStrapUrls[0]);
        StoreDefinitionsMapper storeDefsMapper = new StoreDefinitionsMapper();
        List<StoreDefinition> storeDefs = storeDefsMapper.readStoreList(new File(newStoresXmlfile));
        ClusterMapper clusterMapper = new ClusterMapper();
        for (Node node : oldCluster.getNodes()) {
            VoldemortAdminTool.executeSetMetadataPair(node.getId(), adminClient, CLUSTER_KEY, clusterMapper.writeCluster(newCluster), STORES_KEY, storeDefsMapper.writeStoreList(storeDefs));
        }
        String dirPath = TestUtils.createTempDir().getAbsolutePath();
        for (Node node : newCluster.getNodes()) {
            VoldemortAdminTool.executeGetMetadata(node.getId(), adminClient, CLUSTER_KEY, dirPath);
            // Make sure cluster metadata was updated
            Cluster newClusterFromMetadataRepo = clusterMapper.readCluster(new File(dirPath, CLUSTER_KEY + "_" + node.getId()));
            // All nodes should have this old list
            assertTrue(oldCluster.getNodeById(5).getPartitionIds().equals(oldPartitionIds));
            // As per the new metadata node 5 should have this list
            assertTrue(newClusterFromMetadataRepo.getNodeById(5).getPartitionIds().equals(newPartitionIds));
            // Make sure store metadata was updated
            VoldemortAdminTool.executeGetMetadata(node.getId(), adminClient, STORES_KEY, dirPath);
            List<StoreDefinition> newStoreDefsFromMetadatRepo = storeDefsMapper.readStoreList(new File(dirPath, STORES_KEY + "_" + node.getId()));
            // Check that the required replication factor has been updated
            assertTrue(newStoreDefsFromMetadatRepo.get(1).getRequiredReads() == 2);
            assertTrue(newStoreDefsFromMetadatRepo.get(1).getRequiredWrites() == 2);
        }
    } 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) Cluster(voldemort.cluster.Cluster) ClusterMapper(voldemort.xml.ClusterMapper) File(java.io.File) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

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