use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class RestServerAPITest method oneTimeSetUp.
@BeforeClass
public static void oneTimeSetUp() {
voldemortConfig = VoldemortConfig.loadFromVoldemortHome("config/single_node_rest_server/");
key = new ByteArray("key1".getBytes());
vectorClock = new VectorClock();
vectorClock.incrementVersion(voldemortConfig.getNodeId(), System.currentTimeMillis());
value = new Versioned<byte[]>("value1".getBytes(), vectorClock);
server = new VoldemortServer(voldemortConfig);
if (!server.isStarted())
server.start();
logger.info("********************Starting REST Server********************");
restClientConfig = new RESTClientConfig();
restClientConfig.setHttpBootstrapURL("http://localhost:8085").setTimeoutMs(1500, TimeUnit.MILLISECONDS).setMaxR2ConnectionPoolSize(100);
clientFactory = new HttpClientFactory();
Map<String, String> properties = new HashMap<String, String>();
properties.put(HttpClientFactory.HTTP_POOL_SIZE, Integer.toString(restClientConfig.getMaxR2ConnectionPoolSize()));
transportClient = clientFactory.getClient(properties);
r2store = new R2Store("test", restClientConfig.getHttpBootstrapURL(), "2", transportClient, restClientConfig, 0);
store = r2store;
deleteCreatedKeys(key);
}
use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class RestServiceR2StoreTest method tearDown.
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
for (VoldemortServer server : servers) {
ServerTestUtils.stopVoldemortServer(server);
}
store.close();
}
use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class RepairJobTest method setUp.
public void setUp() {
File temp = TestUtils.createTempDir();
VoldemortConfig config = new VoldemortConfig(0, temp.getAbsolutePath());
new File(config.getMetadataDirectory()).mkdir();
this.serverMap = new HashMap<Integer, VoldemortServer>();
this.scheduler = new SchedulerService(1, new MockTime());
this.cluster = VoldemortTestConstants.getNineNodeCluster();
StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
this.storeDefs = mapper.readStoreList(new StringReader((VoldemortTestConstants.getSingleStore322Xml())));
this.storeRepository = new StoreRepository();
this.metadataStore = ServerTestUtils.createMetadataStore(cluster, storeDefs);
storage = new StorageService(storeRepository, metadataStore, scheduler, config);
// Start the storage service
storage.start();
this.socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
String storeDefsString = mapper.writeStoreList(storeDefs);
File file = null;
try {
file = ServerTestUtils.createTempFile("single-store-", ".xml");
FileUtils.writeStringToFile(file, storeDefsString);
String storeDefFile = file.getAbsolutePath();
List<Integer> nodesToStart = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8);
// Start the servers
startServers(cluster, storeDefFile, nodesToStart, null);
} catch (Exception e) {
e.printStackTrace();
}
}
use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class RepairJobTest method startServers.
private Cluster startServers(Cluster cluster, String storeXmlFile, List<Integer> nodeToStart, Map<String, String> configProps) throws Exception {
for (int node : nodeToStart) {
Properties properties = new Properties();
if (null != configProps) {
for (Entry<String, String> property : configProps.entrySet()) {
properties.put(property.getKey(), property.getValue());
}
}
VoldemortConfig config = ServerTestUtils.createServerConfig(true, node, TestUtils.createTempDir().getAbsolutePath(), null, storeXmlFile, properties);
VoldemortServer server = ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster);
serverMap.put(node, server);
}
return cluster;
}
use of voldemort.server.VoldemortServer in project voldemort by voldemort.
the class VersionedPutPruneJobTest method testPruneJob.
@Test
public void testPruneJob() {
long now = System.currentTimeMillis();
// for all keys, do versioned puts based on old and new routing plans
int recordCount = 0;
String fetchedValue = "fetched";
String onlineValue = "online";
for (Map.Entry<String, String> entry : testEntries.entrySet()) {
ByteArray key = new ByteArray(entry.getKey().getBytes());
Versioned<Object> fetchedVersion = new Versioned<Object>(fetchedValue, makeVersionedPutClock(oldRoutingPlan, key.get(), now));
storeClient.put(entry.getKey(), fetchedVersion);
if (recordCount < 50) {
// let the first 50 keys be active ones that received some
// online writes before the prune job
Versioned<Object> onlineVersion = new Versioned<Object>(onlineValue, makeVersionedPutClock(currentRoutingPlan, key.get(), now + Time.MS_PER_SECOND));
storeClient.put(entry.getKey(), onlineVersion);
}
recordCount++;
}
// run the prune job
AdminClient admin = new AdminClient(cluster);
for (int nodeid = 0; nodeid < servers.length; nodeid++) {
admin.storeMntOps.pruneJob(nodeid, "test");
}
for (VoldemortServer server : servers) {
ServerTestUtils.waitForAsyncOperationOnServer(server, "Prune", 5000);
}
// do the checks
recordCount = 0;
for (Map.Entry<String, String> entry : testEntries.entrySet()) {
ByteArray key = new ByteArray(entry.getKey().getBytes());
List<Integer> replicas = currentRoutingPlan.getReplicationNodeList(key.get());
Versioned<Object> val = storeClient.get(entry.getKey());
// check vector clock does not contain non replicas
assertFalse("Clock must not contain any non replicas", clockContainsNonReplicas((VectorClock) val.getVersion(), replicas));
if (recordCount < 50) {
assertEquals("Must have online value", onlineValue, val.getValue());
} else {
assertEquals("Must have fetched value", fetchedValue, val.getValue());
}
recordCount++;
}
// do subsequent writes
String finalValue = "final";
for (Map.Entry<String, String> entry : testEntries.entrySet()) {
ByteArray key = new ByteArray(entry.getKey().getBytes());
List<Integer> replicas = currentRoutingPlan.getReplicationNodeList(key.get());
Versioned<Object> finalVersion = new Versioned<Object>(finalValue, makeVersionedPutClock(currentRoutingPlan, key.get(), now + 2 * Time.MS_PER_SECOND));
storeClient.put(entry.getKey(), finalVersion);
for (Integer replica : replicas) {
Store<ByteArray, byte[], byte[]> socketStore = socketStoreMap.get(replica);
List<Versioned<byte[]>> vals = socketStore.get(key, null);
assertEquals("No more conflicts expected", 1, vals.size());
assertEquals("Key should have the final value", finalValue, new String(vals.get(0).getValue()));
}
}
}
Aggregations