use of com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS in project hazelcast by hazelcast.
the class HotRestartTriggerBackupMessageTask method call.
@Override
protected Object call() throws Exception {
ILogger logger = nodeEngine.getLogger(getClass());
ExecutionService executionService = nodeEngine.getExecutionService();
Future<Void> future = executionService.submit(ExecutionService.ASYNC_EXECUTOR, () -> {
node.getNodeExtension().getHotRestartService().backup();
return null;
});
executionService.asCompletableFuture(future).whenCompleteAsync(withTryCatch(logger, (empty, error) -> sendResponse(error != null ? peel(error) : null)), CALLER_RUNS);
return null;
}
use of com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS in project hazelcast by hazelcast.
the class RunConsoleCommandOperation method run.
@Override
public void run() throws Exception {
final ManagementCenterService mcs = ((NodeEngineImpl) getNodeEngine()).getManagementCenterService();
if (mcs == null) {
sendResponse(new HazelcastException("ManagementCenterService is not initialized yet"));
return;
}
final ILogger logger = getNodeEngine().getLogger(getClass());
final ExecutionService executionService = getNodeEngine().getExecutionService();
Future<String> future = executionService.submit(ExecutionService.MC_EXECUTOR, () -> {
ManagementCenterConfig mcConfig = getNodeEngine().getConfig().getManagementCenterConfig();
if (!mcConfig.isConsoleEnabled()) {
throw new AccessControlException("Using Console is not allowed on this Hazelcast member.");
}
try {
final String ns = namespace;
String cmd = command;
if (!isNullOrEmpty(ns)) {
// set namespace as a part of the command
cmd = ns + "__" + cmd;
}
return mcs.runConsoleCommand(cmd);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw e;
}
});
executionService.asCompletableFuture(future).whenCompleteAsync(withTryCatch(logger, (output, error) -> sendResponse(error != null ? peel(error) : output)), CALLER_RUNS);
}
use of com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS 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.internal.util.ConcurrencyUtil.CALLER_RUNS 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.internal.util.ConcurrencyUtil.CALLER_RUNS 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);
}
Aggregations