use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class SetMetadataTest method setup.
/**
* This test is to partially test the functionality of SetMetadata feature
* of the VoldemortAdminTool
*/
@Before
public void setup() throws IOException {
// setup cluster
cluster = ClusterTestUtils.getZZZCluster();
oldStores = ClusterTestUtils.getZZZStoreDefsInMemory();
bsURL = cluster.getNodes().iterator().next().getSocketUrl().toString();
for (Node node : cluster.getNodes()) {
SocketStoreFactory ssf = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), TestUtils.createTempDir().getAbsolutePath(), cluster, oldStores, new Properties());
VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
vservers.put(node.getId(), vs);
socketStoreFactories.put(node.getId(), ssf);
}
}
use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class SetMetadataTest method testSetMetadataStoreXmlVerifyVersionUpdate.
@Test
public void testSetMetadataStoreXmlVerifyVersionUpdate() throws Exception {
// setup new stores xml
final String newStoreXMLFilePrefix = "updated.stores";
final String newStoreXMLFileSuffix = "xml";
List<StoreDefinition> newStores = new ArrayList<StoreDefinition>();
for (StoreDefinition storeDef : ClusterTestUtils.getZZZStoreDefsInMemory()) {
StoreDefinitionBuilder sb = storeDefToBuilder(storeDef);
Map<Integer, Integer> zrf = sb.getZoneReplicationFactor();
Integer zone0RepFactor = zrf.get(0);
zrf.remove(0);
sb.setReplicationFactor(sb.getReplicationFactor() - zone0RepFactor);
newStores.add(sb.build());
}
File newStoresXMLFolder = TestUtils.createTempDir();
File newStoreXMLFile = File.createTempFile(newStoreXMLFilePrefix, newStoreXMLFileSuffix, newStoresXMLFolder);
FileWriter fwriter = new FileWriter(newStoreXMLFile);
fwriter.write(new StoreDefinitionsMapper().writeStoreList(newStores));
fwriter.close();
// check version
String sysStoreName = SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name();
ByteArray metadataKey = new ByteArray(ByteUtils.getBytes(SystemStoreConstants.VERSIONS_METADATA_KEY, "utf-8"));
for (VoldemortServer vs : vservers.values()) {
List<Versioned<byte[]>> result = vs.getStoreRepository().getLocalStore(sysStoreName).get(metadataKey, null);
String versionInfo = new String(result.get(0).getValue());
System.out.format("[INITIAL]Version values on node [%d] is: \n %s\n", vs.getIdentityNode().getId(), versionInfo);
Properties props = new Properties();
props.load(new ByteArrayInputStream(versionInfo.getBytes()));
for (StoreDefinition sd : oldStores) {
if (!props.getProperty(sd.getName()).equals("0")) {
Assert.fail("Initial version of key [" + sd.getName() + "] on node [" + vs.getIdentityNode().getId() + "] is expected to be 0 but not");
}
}
if (!props.getProperty("cluster.xml").equals("0")) {
Assert.fail("Final version of key [stores.xml] on node [" + vs.getIdentityNode().getId() + "] is expected to greater than 0 but not");
}
}
// update the stores xml
VoldemortAdminTool.main(new String[] { "--auto", "--set-metadata", MetadataStore.STORES_KEY, "--set-metadata-value", newStoreXMLFile.getAbsolutePath(), "--url", bsURL });
// properly
try {
Thread.sleep(10000);
} catch (Exception e) {
}
// check version
for (VoldemortServer vs : vservers.values()) {
List<Versioned<byte[]>> result = vs.getStoreRepository().getLocalStore(sysStoreName).get(metadataKey, null);
String versionInfo = new String(result.get(0).getValue());
System.out.format("[FINAL]Version values on node [%d] is: \n %s\n", vs.getIdentityNode().getId(), versionInfo);
Properties props = new Properties();
props.load(new ByteArrayInputStream(versionInfo.getBytes()));
for (StoreDefinition sd : oldStores) {
if (!(Long.parseLong(props.getProperty(sd.getName())) > 0)) {
Assert.fail("Final version of key [" + sd.getName() + "] on node [" + vs.getIdentityNode().getId() + "] is expected to greater than 0 but not");
}
}
if (!(Long.parseLong(props.getProperty("stores.xml")) > 0)) {
Assert.fail("Final version of key [stores.xml] on node [" + vs.getIdentityNode().getId() + "] is expected to greater than 0 but not");
}
}
}
use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class StoreOperationsTest method setup.
@Before
public void setup() throws IOException {
// setup cluster
cluster = ServerTestUtils.getLocalCluster(2);
stores = ServerTestUtils.getStoreDefs(2);
bsURL = cluster.getNodes().iterator().next().getSocketUrl().toString();
for (Node node : cluster.getNodes()) {
SocketStoreFactory ssf = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties());
VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
vservers.put(node.getId(), vs);
socketStoreFactories.put(node.getId(), ssf);
}
adminClient = new AdminClient(cluster);
}
use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class AsyncMetadataVersionManagerTest method setUp.
@Before
public void setUp() throws Exception {
servers = new VoldemortServer[cluster.getNodeIds().size()];
int i = 0;
for (Integer nodeId : cluster.getNodeIds()) {
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, storeDefs, new Properties());
VoldemortServer server = ServerTestUtils.startVoldemortServer(socketStoreFactory, config);
servers[i++] = server;
}
socketUrl = servers[0].getIdentityNode().getSocketUrl().toString();
bootStrapUrls = new String[1];
bootStrapUrls[0] = socketUrl;
ClientConfig clientConfig = new ClientConfig();
clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(clientZoneId);
SystemStoreClientFactory<String, String> systemStoreFactory = new SystemStoreClientFactory<String, String>(clientConfig);
sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
repository = new SystemStoreRepository(clientConfig);
repository.addSystemStore(sysVersionStore, SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
this.scheduler = new SchedulerService(2, SystemTime.INSTANCE, true);
}
use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class SystemStoreTest method setUp.
@Before
public void setUp() throws Exception {
servers = new VoldemortServer[cluster.getNodeIds().size()];
int i = 0;
for (Integer nodeId : cluster.getNodeIds()) {
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, storeDefs, new Properties());
VoldemortServer server = ServerTestUtils.startVoldemortServer(socketStoreFactory, config);
servers[i++] = server;
}
socketUrl = servers[0].getIdentityNode().getSocketUrl().toString();
ClientConfig clientConfig = new ClientConfig().setMaxTotalConnections(4).setMaxConnectionsPerNode(4).setBootstrapUrls(socketUrl);
SocketStoreClientFactory socketFactory = new SocketStoreClientFactory(clientConfig);
bootStrapUrls = new String[1];
bootStrapUrls[0] = socketUrl;
clusterXml = ((AbstractStoreClientFactory) socketFactory).bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY);
}
Aggregations