use of voldemort.server.VoldemortConfig in project voldemort by voldemort.
the class ServerTestUtils method restartServer.
public static VoldemortServer restartServer(VoldemortServer oldServer, int nodeId, Cluster cluster, Properties serverProps) throws Exception {
ServerTestUtils.stopVoldemortServer(oldServer);
String baseDirPath = oldServer.getVoldemortConfig().getVoldemortHome();
String parentDirPath = Paths.get(baseDirPath).getParent().toString();
List<StoreDefinition> storeDefs = oldServer.getMetadataStore().getStoreDefList();
final boolean ENABLE_NIO = true;
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(ENABLE_NIO, nodeId, parentDirPath, cluster, storeDefs, serverProps);
SocketStoreFactory socketStoreFactory = getSocketStoreFactory();
try {
return startVoldemortServer(socketStoreFactory, config, cluster);
} finally {
socketStoreFactory.close();
}
}
use of voldemort.server.VoldemortConfig in project voldemort by voldemort.
the class ServerJVMTestUtils method createAndInitializeVoldemortHome.
public static String createAndInitializeVoldemortHome(boolean useNio, int node, String storesXmlfile, Cluster cluster) throws IOException {
VoldemortConfig config = ServerTestUtils.createServerConfig(useNio, node, TestUtils.createTempDir().getAbsolutePath(), null, storesXmlfile, new Properties());
// Initialize voldemort config dir with all required files.
// cluster.xml
File clusterXml = new File(config.getMetadataDirectory() + File.separator + "cluster.xml");
FileUtils.writeStringToFile(clusterXml, new ClusterMapper().writeCluster(cluster));
// stores.xml
File storesXml = new File(config.getMetadataDirectory() + File.separator + "stores.xml");
FileUtils.copyFile(new File(storesXmlfile), storesXml);
// server.properties
File serverProperties = new File(config.getMetadataDirectory() + File.separator + "server.properties");
FileUtils.writeLines(serverProperties, Arrays.asList("node.id=" + node, "bdb.cache.size=" + 1024 * 1024, "enable.metadata.checking=" + false, "enable.network.classloader=" + false));
return config.getVoldemortHome();
}
use of voldemort.server.VoldemortConfig in project voldemort by voldemort.
the class HintedHandoffTestEnvironment method startServer.
/**
* Start a server How it works:
*
* 1. create a server using test utilities
*
* 2.Inject prepared test store and storage engine
*
* 3. Inject prepared slop store and storage engine
*
* @param nodeId The node of server to start
* @throws IOException
*/
public void startServer(int nodeId) throws IOException {
if (logger.isInfoEnabled())
logger.info("Starting server of node [" + nodeId + "]");
SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
List<StoreDefinition> stores = new ArrayList<StoreDefinition>();
stores.add(storeDef);
// start a voldemort server
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties());
config.setNioAdminConnectorSelectors(1);
config.setNioConnectorSelectors(5);
config.setSlopFrequencyMs(DEFAULT_SLOP_PUSH_INTERVAL_S * 1000);
config.setSlopStoreType("memory");
config.setFailureDetectorAsyncRecoveryInterval(DEFAULT_ASYNC_RECOVERY_INTERVAL_S * 1000);
VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config);
socketStoreFactory.close();
voldemortServers.put(nodeId, vs);
VoldemortService vsrv = vs.getService(ServiceType.STORAGE);
StoreRepository sr = ((StorageService) vsrv).getStoreRepository();
// storage engine injection
sr.removeLocalStore(STORE_NAME);
sr.addLocalStore(sleepyStores.get(nodeId));
sr.removeStorageEngine(STORE_NAME);
sr.addStorageEngine((StorageEngine<ByteArray, byte[], byte[]>) realStores.get(nodeId));
// slop stores caching and injection
if (!slopStorageEngines.containsKey(nodeId)) {
SlopStorageEngine slopStorageEngine = sr.getSlopStore();
slopStorageEngines.put(nodeId, slopStorageEngine);
} else {
sr.removeStorageEngine("slop");
sr.removeLocalStore("slop");
sr.addStorageEngine(slopStorageEngines.get(nodeId));
sr.addLocalStore(slopStorageEngines.get(nodeId));
sr.setSlopStore(slopStorageEngines.get(nodeId));
}
}
Aggregations