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);
}
}
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);
}
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];
}
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");
}
}
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());
}
Aggregations