Search in sources :

Example 61 with VoldemortServer

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);
}
Also used : RESTClientConfig(voldemort.restclient.RESTClientConfig) HashMap(java.util.HashMap) VectorClock(voldemort.versioning.VectorClock) R2Store(voldemort.restclient.R2Store) ByteArray(voldemort.utils.ByteArray) VoldemortServer(voldemort.server.VoldemortServer) HttpClientFactory(com.linkedin.r2.transport.http.client.HttpClientFactory) BeforeClass(org.junit.BeforeClass)

Example 62 with VoldemortServer

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();
}
Also used : VoldemortServer(voldemort.server.VoldemortServer) After(org.junit.After)

Example 63 with VoldemortServer

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();
    }
}
Also used : SchedulerService(voldemort.common.service.SchedulerService) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) StoreRepository(voldemort.server.StoreRepository) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) StringReader(java.io.StringReader) File(java.io.File) MockTime(voldemort.MockTime)

Example 64 with VoldemortServer

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;
}
Also used : Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig)

Example 65 with VoldemortServer

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()));
        }
    }
}
Also used : Versioned(voldemort.versioning.Versioned) VectorClock(voldemort.versioning.VectorClock) VoldemortServer(voldemort.server.VoldemortServer) ByteArray(voldemort.utils.ByteArray) HashMap(java.util.HashMap) Map(java.util.Map) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Aggregations

VoldemortServer (voldemort.server.VoldemortServer)86 Properties (java.util.Properties)36 VoldemortConfig (voldemort.server.VoldemortConfig)24 Test (org.junit.Test)23 Node (voldemort.cluster.Node)23 Before (org.junit.Before)21 SocketStoreFactory (voldemort.store.socket.SocketStoreFactory)20 ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)18 ClientConfig (voldemort.client.ClientConfig)17 ByteArray (voldemort.utils.ByteArray)17 ArrayList (java.util.ArrayList)16 After (org.junit.After)15 StoreDefinition (voldemort.store.StoreDefinition)15 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)14 Cluster (voldemort.cluster.Cluster)14 IOException (java.io.IOException)11 HashMap (java.util.HashMap)11 AdminClient (voldemort.client.protocol.admin.AdminClient)11 VectorClock (voldemort.versioning.VectorClock)10 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)9