Search in sources :

Example 1 with ExecutionService

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;
}
Also used : CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) ManagementPermission(com.hazelcast.security.permission.ManagementPermission) Connection(com.hazelcast.internal.nio.Connection) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) MCTriggerHotRestartBackupCodec(com.hazelcast.client.impl.protocol.codec.MCTriggerHotRestartBackupCodec) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) Node(com.hazelcast.instance.impl.Node) Future(java.util.concurrent.Future) AbstractCallableMessageTask(com.hazelcast.client.impl.protocol.task.AbstractCallableMessageTask) ILogger(com.hazelcast.logging.ILogger) Permission(java.security.Permission) ExceptionUtil.withTryCatch(com.hazelcast.internal.util.ExceptionUtil.withTryCatch) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ILogger(com.hazelcast.logging.ILogger) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 2 with ExecutionService

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();
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 3 with ExecutionService

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);
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 4 with ExecutionService

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;
    }
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 5 with ExecutionService

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);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) AbstractLocalOperation(com.hazelcast.spi.impl.operationservice.AbstractLocalOperation) CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) HazelcastException(com.hazelcast.core.HazelcastException) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) ManagementCenterConfig(com.hazelcast.config.ManagementCenterConfig) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) Future(java.util.concurrent.Future) ILogger(com.hazelcast.logging.ILogger) StringUtil.isNullOrEmpty(com.hazelcast.internal.util.StringUtil.isNullOrEmpty) AccessControlException(java.security.AccessControlException) ExceptionUtil.withTryCatch(com.hazelcast.internal.util.ExceptionUtil.withTryCatch) HazelcastException(com.hazelcast.core.HazelcastException) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) AccessControlException(java.security.AccessControlException) ILogger(com.hazelcast.logging.ILogger) ManagementCenterConfig(com.hazelcast.config.ManagementCenterConfig) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Aggregations

ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)46 ILogger (com.hazelcast.logging.ILogger)10 ManagementCenterService (com.hazelcast.internal.management.ManagementCenterService)7 CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)7 ExceptionUtil.peel (com.hazelcast.internal.util.ExceptionUtil.peel)7 ExceptionUtil.withTryCatch (com.hazelcast.internal.util.ExceptionUtil.withTryCatch)7 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)7 Future (java.util.concurrent.Future)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 IExecutorService (com.hazelcast.core.IExecutorService)4 AbstractLocalOperation (com.hazelcast.spi.impl.operationservice.AbstractLocalOperation)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 Node (com.hazelcast.instance.impl.Node)3 NodeEngine (com.hazelcast.spi.impl.NodeEngine)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 ExecutorService (java.util.concurrent.ExecutorService)3 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)2