use of voldemort.server.protocol.admin.AsyncOperationService in project voldemort by voldemort.
the class ServerTestUtils method waitForAsyncOperationOnServer.
/***
*
*
* NOTE: This relies on the current behavior of the AsyncOperationService to
* remove an operation if an explicit isComplete() is invoked. If/When that
* is changed, this method will always block upto timeoutMs & return
*
* @param server
* @param asyncOperationPattern substring to match with the operation
* description
* @param timeoutMs
* @return
*/
public static boolean waitForAsyncOperationOnServer(VoldemortServer server, String asyncOperationPattern, long timeoutMs) {
long endTimeMs = System.currentTimeMillis() + timeoutMs;
AsyncOperationService service = server.getAsyncRunner();
List<Integer> matchingOperationIds = null;
// wait till the atleast one matching operation shows up
while (System.currentTimeMillis() < endTimeMs) {
matchingOperationIds = service.getMatchingAsyncOperationList(asyncOperationPattern, true);
if (matchingOperationIds.size() > 0) {
break;
}
}
// now wait for those operations to complete
while (System.currentTimeMillis() < endTimeMs) {
List<Integer> completedOps = new ArrayList<Integer>(matchingOperationIds.size());
for (Integer op : matchingOperationIds) {
if (service.isComplete(op)) {
completedOps.add(op);
}
}
matchingOperationIds.removeAll(completedOps);
if (matchingOperationIds.size() == 0) {
return false;
}
}
return false;
}
use of voldemort.server.protocol.admin.AsyncOperationService 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