use of voldemort.common.service.VoldemortService in project voldemort by voldemort.
the class HintedHandoffSendHintTest method setUp.
@Before
public void setUp() throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Test Started: replication[" + REPLICATION_FACTOR + "], preferredW[" + P_WRITES + "], requiredW[" + R_WRITES + "]");
}
cluster = getNineNodeCluster();
storeDef = getStoreDef();
// create voldemort servers
for (Integer nodeId = 0; nodeId < NUM_NODES_TOTAL; nodeId++) {
SocketStoreFactory socketStoreFactory;
socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
List<StoreDefinition> stores = new ArrayList<StoreDefinition>();
stores.add(storeDef);
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties());
config.setNioAdminConnectorSelectors(1);
config.setNioConnectorSelectors(2);
VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config);
VoldemortService vsrv = vs.getService(ServiceType.STORAGE);
StorageService ss = (StorageService) vsrv;
voldemortServers.put(nodeId, vs);
slopStorageEngines.put(nodeId, ss.getStoreRepository().getSlopStore());
slopStores.put(nodeId, SerializingStore.wrap(ss.getStoreRepository().getSlopStore(), new ByteArraySerializer(), new SlopSerializer(), new IdentitySerializer()));
// wrap original store with force fail store
Store<ByteArray, byte[], byte[]> store = ss.getStoreRepository().removeLocalStore(STORE_NAME);
UnreachableStoreException exception = new UnreachableStoreException("Force failed");
ForceFailStore<ByteArray, byte[], byte[]> forceFailStore = new ForceFailStore<ByteArray, byte[], byte[]>(store, exception);
forceFailStores.put(nodeId, forceFailStore);
ss.getStoreRepository().addLocalStore(forceFailStore);
}
strategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDef, cluster);
// create client socket stores and slop stores
SocketStoreClientFactoryForTest clientSocketStoreFactory = new SocketStoreClientFactoryForTest(STORE_NAME, SLOP_STORE_NAME);
Serializer<ByteArray> slopKeySerializer = new ByteArraySerializer();
Serializer<Slop> slopValueSerializer = new SlopSerializer();
Map<Integer, Store<ByteArray, byte[], byte[]>> testStores = subStores;
Map<Integer, Store<ByteArray, Slop, byte[]>> slopStores = new HashMap<Integer, Store<ByteArray, Slop, byte[]>>();
for (Node node : cluster.getNodes()) {
// test store
SocketStore socketTestStore = clientSocketStoreFactory.getSocketTestStoreByNode(node);
socketTestStores.put(node.getId(), socketTestStore);
testStores.put(node.getId(), socketTestStore);
// slop store
SocketStore socketSlopStore = clientSocketStoreFactory.getSocketSlopStoreByNode(node);
Store<ByteArray, Slop, byte[]> slopStore = SerializingStore.wrap(socketSlopStore, slopKeySerializer, slopValueSerializer, new IdentitySerializer());
socketSlopStores.put(node.getId(), socketSlopStore);
slopStores.put(node.getId(), slopStore);
}
// set failure detector
if (failureDetector != null)
failureDetector.destroy();
FailureDetectorConfig failureDetectorConfig = new FailureDetectorConfig();
failureDetectorConfig.setImplementationClassName(failureDetectorCls.getName());
failureDetectorConfig.setThreshold(50);
failureDetectorConfig.setCluster(cluster);
failureDetectorConfig.setConnectionVerifier(MutableStoreConnectionVerifier.create(subStores));
failureDetector = FailureDetectorUtils.create(failureDetectorConfig, false);
// make routedStore
RoutedStoreFactory factory = new RoutedStoreFactory();
routedStore = factory.create(cluster, storeDef, testStores, socketTestStores, slopStores, socketSlopStores, failureDetector, new RoutedStoreConfig().setTimeoutConfig(new TimeoutConfig(1500L, false)));
// generate the keys
for (int i = 0; i < 5; i++) {
Set<Integer> nodesCovered = Sets.newHashSet();
while (nodesCovered.size() < NUM_NODES_TOTAL) {
ByteArray randomKey = new ByteArray(TestUtils.randomBytes(KEY_LENGTH));
byte[] randomValue = TestUtils.randomBytes(VALUE_LENGTH);
if (randomKey.length() > 0 && randomValue.length > 0) {
if (!keyList.contains(randomKey)) {
for (Node node : strategy.routeRequest(randomKey.get())) {
keysToNodes.put(randomKey, node.getId());
nodesCovered.add(node.getId());
}
logger.info("Inserting key [" + randomKey + "] to key list as id:" + keyList.size());
keyList.add(randomKey);
keyValues.put(randomKey, new ByteArray(randomValue));
}
}
}
}
}
use of voldemort.common.service.VoldemortService 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));
}
}
use of voldemort.common.service.VoldemortService in project voldemort by voldemort.
the class CoordinatorServer method startInner.
@Override
protected void startInner() throws VoldemortException {
logger.info("Starting " + services.size() + " services.");
long start = System.currentTimeMillis();
for (VoldemortService service : services) {
service.start();
}
long end = System.currentTimeMillis();
logger.info("Coordinator startup completed in " + (end - start) + " ms.");
}
use of voldemort.common.service.VoldemortService in project voldemort by voldemort.
the class CoordinatorServer method createServices.
private List<VoldemortService> createServices() {
List<VoldemortService> services = new ArrayList<VoldemortService>();
services.add(new CoordinatorProxyService(config, storeClientConfigs));
if (config.isAdminServiceEnabled()) {
services.add(new CoordinatorAdminService(config, storeClientConfigs));
}
return ImmutableList.copyOf(services);
}
use of voldemort.common.service.VoldemortService in project voldemort by voldemort.
the class VoldemortServer method createBasicServices.
private List<VoldemortService> createBasicServices() {
/* Services are given in the order they must be started */
List<VoldemortService> services = new ArrayList<VoldemortService>();
SchedulerService scheduler = new SchedulerService(voldemortConfig.getSchedulerThreads(), SystemTime.INSTANCE, voldemortConfig.canInterruptService());
storageService = new StorageService(storeRepository, metadata, scheduler, voldemortConfig);
asyncService = new AsyncOperationService(scheduler, ASYNC_REQUEST_CACHE_SIZE);
jmxService = null;
services.add(storageService);
services.add(scheduler);
services.add(asyncService);
if (voldemortConfig.isAdminServerEnabled()) {
Rebalancer rebalancer = null;
if (voldemortConfig.isEnableRebalanceService()) {
RebalancerService rebalancerService = new RebalancerService(storeRepository, metadata, voldemortConfig, asyncService, scheduler);
services.add(rebalancerService);
rebalancer = rebalancerService.getRebalancer();
}
SocketRequestHandlerFactory adminRequestHandlerFactory = new SocketRequestHandlerFactory(storageService, this.storeRepository, this.metadata, this.voldemortConfig, this.asyncService, scheduler, rebalancer, this);
if (voldemortConfig.getUseNioConnector()) {
logger.info("Using NIO Connector for Admin Service.");
services.add(new NioSocketService(adminRequestHandlerFactory, identityNode.getAdminPort(), voldemortConfig.getAdminSocketBufferSize(), voldemortConfig.isNioAdminConnectorKeepAlive(), voldemortConfig.getNioAdminConnectorSelectors(), "admin-server", voldemortConfig.isJmxEnabled(), voldemortConfig.getNioAcceptorBacklog(), voldemortConfig.getNioSelectorMaxHeartBeatTimeMs()));
} else {
logger.info("Using BIO Connector for Admin Service.");
services.add(new SocketService(adminRequestHandlerFactory, identityNode.getAdminPort(), voldemortConfig.getAdminCoreThreads(), voldemortConfig.getAdminMaxThreads(), voldemortConfig.getAdminSocketBufferSize(), "admin-server", voldemortConfig.isJmxEnabled()));
}
}
if (voldemortConfig.isGossipEnabled()) {
services.add(new GossipService(this.metadata, scheduler, voldemortConfig));
}
if (voldemortConfig.isJmxEnabled()) {
jmxService = new JmxService(this, this.metadata.getCluster(), storeRepository, services);
services.add(jmxService);
}
return ImmutableList.copyOf(services);
}
Aggregations