use of com.hazelcast.spi.impl.executionservice.ExecutionService 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.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class ClusterServiceImpl method init.
@Override
public void init(NodeEngine nodeEngine, Properties properties) {
long mergeFirstRunDelayMs = node.getProperties().getPositiveMillisOrDefault(ClusterProperty.MERGE_FIRST_RUN_DELAY_SECONDS, DEFAULT_MERGE_RUN_DELAY_MILLIS);
long mergeNextRunDelayMs = node.getProperties().getPositiveMillisOrDefault(ClusterProperty.MERGE_NEXT_RUN_DELAY_SECONDS, DEFAULT_MERGE_RUN_DELAY_MILLIS);
ExecutionService executionService = nodeEngine.getExecutionService();
executionService.scheduleWithRepetition(SPLIT_BRAIN_HANDLER_EXECUTOR_NAME, new SplitBrainHandler(node), mergeFirstRunDelayMs, mergeNextRunDelayMs, TimeUnit.MILLISECONDS);
membershipManager.init();
clusterHeartbeatManager.init();
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class MembershipManager method init.
/**
* Initializes the {@link MembershipManager}.
* It will schedule the member list publication to the {@link ClusterProperty#MEMBER_LIST_PUBLISH_INTERVAL_SECONDS} interval.
*/
void init() {
ExecutionService executionService = nodeEngine.getExecutionService();
HazelcastProperties hazelcastProperties = node.getProperties();
executionService.register(MASTERSHIP_CLAIM_EXECUTOR_NAME, 1, Integer.MAX_VALUE, ExecutorType.CACHED);
long memberListPublishInterval = hazelcastProperties.getSeconds(ClusterProperty.MEMBER_LIST_PUBLISH_INTERVAL_SECONDS);
memberListPublishInterval = (memberListPublishInterval > 0 ? memberListPublishInterval : 1);
executionService.scheduleWithRepetition(CLUSTER_EXECUTOR_NAME, this::publishMemberList, memberListPublishInterval, memberListPublishInterval, SECONDS);
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class MetricsService method scheduleMetricsCollectorIfNeeded.
private void scheduleMetricsCollectorIfNeeded() {
if (!collectorScheduled && !publishers.isEmpty()) {
logger.fine("Configuring metrics collection, collection interval=" + config.getCollectionFrequencySeconds() + " seconds, retention=" + config.getManagementCenterConfig().getRetentionSeconds() + " seconds, publishers=" + publishers.stream().map(MetricsPublisher::name).collect(joining(", ", "[", "]")));
ExecutionService executionService = nodeEngine.getExecutionService();
scheduledFuture = executionService.scheduleWithRepetition("MetricsPublisher", this::collectMetrics, 1, config.getCollectionFrequencySeconds(), TimeUnit.SECONDS);
collectorScheduled = true;
}
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService 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);
}
Aggregations