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);
}
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);
}
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);
}
}
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);
}
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);
}
}
Aggregations