use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class RunScriptOperation method run.
@Override
public void run() {
final ILogger logger = getNodeEngine().getLogger(getClass());
final ExecutionService executionService = getNodeEngine().getExecutionService();
Future<Object> future = executionService.submit(ExecutionService.MC_EXECUTOR, () -> {
ManagementCenterConfig managementCenterConfig = getNodeEngine().getConfig().getManagementCenterConfig();
if (!managementCenterConfig.isScriptingEnabled()) {
throw new AccessControlException("Using ScriptEngine is not allowed on this Hazelcast member.");
}
ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
ScriptEngine scriptEngine = scriptEngineManager.getEngineByName(engine);
if (scriptEngine == null) {
throw new IllegalArgumentException("Could not find ScriptEngine named '" + engine + "'." + " Please add the corresponding ScriptEngine to the classpath of this Hazelcast member");
}
scriptEngine.put("hazelcast", getNodeEngine().getHazelcastInstance());
try {
return scriptEngine.eval(script);
} catch (ScriptException e) {
// ScriptException's cause is not serializable - we don't need the cause
HazelcastException hazelcastException = new HazelcastException(e.getMessage());
hazelcastException.setStackTrace(e.getStackTrace());
throw hazelcastException;
}
});
executionService.asCompletableFuture(future).whenCompleteAsync(withTryCatch(logger, (result, error) -> sendResponse(error != null ? peel(error) : result)), CALLER_RUNS);
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class ChangeClusterStateOperation method run.
@Override
public void run() {
ILogger logger = getNodeEngine().getLogger(getClass());
ExecutionService executionService = getNodeEngine().getExecutionService();
Future<Void> future = executionService.submit(ExecutionService.ASYNC_EXECUTOR, () -> {
getNodeEngine().getClusterService().changeClusterState(newState);
return null;
});
executionService.asCompletableFuture(future).whenCompleteAsync(withTryCatch(logger, (empty, error) -> sendResponse(error != null ? peel(error) : null)), CALLER_RUNS);
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class ManagementCenterService method registerExecutor.
private void registerExecutor() {
final ExecutionService executionService = instance.node.nodeEngine.getExecutionService();
int threadCount = instance.node.getProperties().getInteger(ClusterProperty.MC_EXECUTOR_THREAD_COUNT);
logger.finest("Creating new executor for Management Center service tasks with threadCount=" + threadCount);
executionService.register(ExecutionService.MC_EXECUTOR, threadCount, threadCount * EXECUTOR_QUEUE_CAPACITY_PER_THREAD, ExecutorType.CACHED);
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class ChangeClusterVersionOperation method run.
@Override
public void run() throws Exception {
ILogger logger = getNodeEngine().getLogger(getClass());
ExecutionService executionService = getNodeEngine().getExecutionService();
Future<Void> future = executionService.submit(ExecutionService.ASYNC_EXECUTOR, () -> {
getNodeEngine().getClusterService().changeClusterVersion(version);
return null;
});
executionService.asCompletableFuture(future).whenCompleteAsync(withTryCatch(logger, (empty, error) -> sendResponse(error != null ? peel(error) : null)), CALLER_RUNS);
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class PostJoinProxyOperation method run.
@Override
public void run() throws Exception {
if (proxies == null || proxies.size() <= 0) {
return;
}
NodeEngine nodeEngine = getNodeEngine();
ProxyServiceImpl proxyService = getService();
ExecutionService executionService = nodeEngine.getExecutionService();
for (final ProxyInfo proxy : proxies) {
final ProxyRegistry registry = proxyService.getOrCreateRegistry(proxy.getServiceName());
try {
executionService.execute(ExecutionService.SYSTEM_EXECUTOR, new CreateProxyTask(registry, proxy));
} catch (Throwable t) {
logProxyCreationFailure(proxy, t);
}
}
}
Aggregations