Search in sources :

Example 31 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class ServerTestUtils method waitForSlopDrain.

public static void waitForSlopDrain(Map<Integer, VoldemortServer> vservers, Long slopDrainTimoutMs) throws InterruptedException {
    long timeStart = System.currentTimeMillis();
    boolean allSlopsEmpty = false;
    while (System.currentTimeMillis() < timeStart + slopDrainTimoutMs) {
        allSlopsEmpty = true;
        for (Integer nodeId : vservers.keySet()) {
            VoldemortServer vs = vservers.get(nodeId);
            SlopStorageEngine sse = vs.getStoreRepository().getSlopStore();
            ClosableIterator<ByteArray> keys = sse.keys();
            long count = 0;
            while (keys.hasNext()) {
                keys.next();
                count++;
            }
            keys.close();
            if (count > 0) {
                allSlopsEmpty = false;
                logger.info(String.format("Slop engine for node %d is not yet empty with %d slops\n", nodeId, count));
            }
        }
        if (allSlopsEmpty) {
            break;
        }
        Thread.sleep(1000);
    }
    if (!allSlopsEmpty) {
        throw new RuntimeException("Timeout while waiting for all slops to drain");
    }
}
Also used : ByteArray(voldemort.utils.ByteArray) SlopStorageEngine(voldemort.store.slop.SlopStorageEngine) VoldemortServer(voldemort.server.VoldemortServer)

Example 32 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class RebootstrappingStoreTest method setUp.

@Before
public void setUp() throws Exception {
    SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
    int numServers = 2;
    VoldemortServer[] voldemortServers = new VoldemortServer[numServers];
    int[][] partitionMap = { { 0, 1 }, {} };
    cluster = ServerTestUtils.startVoldemortCluster(numServers, voldemortServers, partitionMap, socketStoreFactory, false, null, STORES_XML, new Properties());
    servers = Lists.newArrayList();
    for (int i = 0; i < numServers; ++i) {
        servers.add(voldemortServers[i]);
    }
    String bootstrapUrl = cluster.getNodeById(0).getSocketUrl().toString();
    storeClient = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl)).getStoreClient(STORE_NAME);
    Map<String, String> entries = Maps.newHashMap();
    entries.put("a", "1");
    entries.put("b", "2");
    for (Map.Entry<String, String> entry : entries.entrySet()) storeClient.put(entry.getKey(), entry.getValue());
}
Also used : SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) VoldemortServer(voldemort.server.VoldemortServer) Properties(java.util.Properties) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) ClientConfig(voldemort.client.ClientConfig) Map(java.util.Map) Before(org.junit.Before)

Example 33 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class RedirectingStoreTest method startServer.

private VoldemortServer startServer(int node, String storesXmlfile, Cluster cluster) throws IOException {
    VoldemortConfig config = ServerTestUtils.createServerConfig(useNio, node, TestUtils.createTempDir().getAbsolutePath(), null, storesXmlfile, new Properties());
    // enable metadata checking for this test.
    config.setEnableMetadataChecking(true);
    config.setEnableRebalanceService(false);
    VoldemortServer server = new VoldemortServer(config, cluster);
    server.start();
    return server;
}
Also used : Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig)

Example 34 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class VersionedPutPruneJobTest method setup.

@Before
public void setup() throws Exception {
    socketStoreMap = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
    socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
    final int numServers = 4;
    servers = new VoldemortServer[numServers];
    int[][] currentPartitionMap = { { 0, 4 }, { 2, 6 }, { 1, 5 }, { 3, 7 } };
    cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, currentPartitionMap, socketStoreFactory, true, null, "test/common/voldemort/config/single-store-322.xml", new Properties());
    StringReader reader = new StringReader(VoldemortTestConstants.getSingleStore322Xml());
    StoreDefinition storeDef = new StoreDefinitionsMapper().readStoreList(reader).get(0);
    currentRoutingPlan = new BaseStoreRoutingPlan(cluster, storeDef);
    String bootStrapUrl = "";
    for (VoldemortServer server : servers) {
        Node node = server.getIdentityNode();
        socketStoreMap.put(node.getId(), ServerTestUtils.getSocketStore(socketStoreFactory, "test", node.getHost(), node.getSocketPort(), RequestFormatType.PROTOCOL_BUFFERS, false, true));
        bootStrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
    }
    testEntries = ServerTestUtils.createRandomKeyValueString(100);
    int[][] oldPartitionMap = { { 3, 6 }, { 1, 4 }, { 7, 2 }, { 5, 0 } };
    oldRoutingPlan = new BaseStoreRoutingPlan(ServerTestUtils.getLocalCluster(numServers, oldPartitionMap), storeDef);
    SocketStoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootStrapUrl));
    storeClient = factory.getStoreClient("test");
}
Also used : Node(voldemort.cluster.Node) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Store(voldemort.store.Store) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) StoreDefinition(voldemort.store.StoreDefinition) StringReader(java.io.StringReader) BaseStoreRoutingPlan(voldemort.routing.BaseStoreRoutingPlan) ClientConfig(voldemort.client.ClientConfig) Before(org.junit.Before)

Example 35 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class ServerSideRoutingTest method startServer.

private VoldemortServer startServer(boolean useNio, int node, String storesXmlfile, Cluster cluster, boolean metadataChecking) throws IOException {
    VoldemortConfig config = ServerTestUtils.createServerConfig(useNio, node, TestUtils.createTempDir().getAbsolutePath(), null, storesXmlfile, new Properties());
    if (metadataChecking)
        config.setEnableMetadataChecking(true);
    else
        config.setEnableMetadataChecking(false);
    // set server side routing true.
    config.setEnableServerRouting(true);
    VoldemortServer server = new VoldemortServer(config, cluster);
    server.start();
    return server;
}
Also used : Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig)

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