Search in sources :

Example 26 with VoldemortServer

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

the class VoldemortServletContextListener method contextInitialized.

public void contextInitialized(ServletContextEvent event) {
    try {
        logger.info("Creating application...");
        VoldemortServer server = new VoldemortServer(VoldemortConfig.loadFromEnvironmentVariable());
        event.getServletContext().setAttribute(SERVER_KEY, server);
        event.getServletContext().setAttribute(SERVER_CONFIG_KEY, server.getVoldemortConfig());
        event.getServletContext().setAttribute(VELOCITY_ENGINE_KEY, new VelocityEngine(VOLDEMORT_TEMPLATE_DIR));
        server.start();
        logger.info("Application created.");
    } catch (ConfigurationException e) {
        logger.info("Error loading voldemort server:", e);
        throw e;
    } catch (Exception e) {
        logger.error("Error loading voldemort server:", e);
        throw new ConfigurationException(e);
    }
}
Also used : VelocityEngine(voldemort.server.http.gui.VelocityEngine) ConfigurationException(voldemort.utils.ConfigurationException) VoldemortServer(voldemort.server.VoldemortServer) ConfigurationException(voldemort.utils.ConfigurationException)

Example 27 with VoldemortServer

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

the class ReadOnlyStoreManagementServlet method init.

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    VoldemortServer server = (VoldemortServer) config.getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY);
    initMetadataStore(server);
    initStores(server);
    initVelocity(config);
    setFetcherClass(server);
}
Also used : VoldemortServer(voldemort.server.VoldemortServer)

Example 28 with VoldemortServer

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

the class ServerTestUtils method startStandAloneVoldemortServer.

public static VoldemortServer startStandAloneVoldemortServer(Properties serverProperties, String storesXmlFile) throws IOException {
    VoldemortServer[] servers = new VoldemortServer[1];
    int[][] partitionMap = { { 0, 1, 2, 3 } };
    SocketStoreFactory socketStoreFactory = getSocketStoreFactory();
    try {
        Cluster cluster = ServerTestUtils.startVoldemortCluster(1, servers, partitionMap, socketStoreFactory, true, null, storesXmlFile, serverProperties);
    } finally {
        socketStoreFactory.close();
    }
    return servers[0];
}
Also used : Cluster(voldemort.cluster.Cluster) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) VoldemortServer(voldemort.server.VoldemortServer)

Example 29 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 30 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)

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