Search in sources :

Example 6 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class BatchInvalidator method checkBackgroundTaskIsRunning.

private void checkBackgroundTaskIsRunning() {
    if (runningBackgroundTask.get()) {
        // return if already started
        return;
    }
    if (runningBackgroundTask.compareAndSet(false, true)) {
        ExecutionService executionService = nodeEngine.getExecutionService();
        executionService.scheduleWithRepetition(invalidationExecutorName, new BatchInvalidationEventSender(), batchFrequencySeconds, batchFrequencySeconds, SECONDS);
    }
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 7 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class BatchInvalidator method shutdown.

@Override
public void shutdown() {
    ExecutionService executionService = nodeEngine.getExecutionService();
    executionService.shutdownExecutor(invalidationExecutorName);
    HazelcastInstance node = nodeEngine.getHazelcastInstance();
    LifecycleService lifecycleService = node.getLifecycleService();
    lifecycleService.removeLifecycleListener(nodeShutdownListenerId);
    invalidationQueues.clear();
    super.shutdown();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) LifecycleService(com.hazelcast.core.LifecycleService) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 8 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class JobCoordinationService method scanJobs.

// runs periodically to restart jobs on coordinator failure and perform GC
private void scanJobs() {
    long scanStart = System.currentTimeMillis();
    long nextScanDelay = maxJobScanPeriodInMillis;
    try {
        // it will be checked again in shouldStartJobs()
        if (isMaster()) {
            if (shouldStartJobs()) {
                doScanJobs();
            } else {
                // use a smaller delay when cluster is not in ready state
                nextScanDelay = MIN_JOB_SCAN_PERIOD_MILLIS;
            }
        }
    } catch (HazelcastInstanceNotActiveException ignored) {
    // ignore this exception
    } catch (Throwable e) {
        logger.severe("Scanning jobs failed", e);
    }
    // Adjust the delay by the time taken by the scan to avoid accumulating more and more job results with each scan
    long scanTime = System.currentTimeMillis() - scanStart;
    nextScanDelay = Math.max(0, nextScanDelay - scanTime);
    ExecutionService executionService = nodeEngine.getExecutionService();
    executionService.schedule(this::scanJobs, nextScanDelay, MILLISECONDS);
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) WrappedThrowable(com.hazelcast.jet.impl.observer.WrappedThrowable) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 9 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class JobCoordinationService method scheduleSnapshot.

void scheduleSnapshot(MasterContext mc, long executionId) {
    long snapshotInterval = mc.jobConfig().getSnapshotIntervalMillis();
    ExecutionService executionService = nodeEngine.getExecutionService();
    if (logger.isFineEnabled()) {
        logger.fine(mc.jobIdString() + " snapshot is scheduled in " + snapshotInterval + "ms");
    }
    executionService.schedule(COORDINATOR_EXECUTOR_NAME, () -> mc.snapshotContext().startScheduledSnapshot(executionId), snapshotInterval, MILLISECONDS);
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 10 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class MapNearCacheManager method createRepairingInvalidationTask.

private RepairingTask createRepairingInvalidationTask() {
    ExecutionService executionService = nodeEngine.getExecutionService();
    ClusterService clusterService = nodeEngine.getClusterService();
    OperationService operationService = nodeEngine.getOperationService();
    HazelcastProperties properties = nodeEngine.getProperties();
    ILogger metadataFetcherLogger = nodeEngine.getLogger(MemberMapInvalidationMetaDataFetcher.class);
    InvalidationMetaDataFetcher invalidationMetaDataFetcher = new MemberMapInvalidationMetaDataFetcher(clusterService, operationService, metadataFetcherLogger);
    ILogger repairingTaskLogger = nodeEngine.getLogger(RepairingTask.class);
    UUID localUuid = nodeEngine.getLocalMember().getUuid();
    return new RepairingTask(properties, invalidationMetaDataFetcher, executionService.getGlobalTaskScheduler(), serializationService, partitionService, localUuid, repairingTaskLogger);
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) ClusterService(com.hazelcast.internal.cluster.ClusterService) RepairingTask(com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) MemberMapInvalidationMetaDataFetcher(com.hazelcast.map.impl.nearcache.invalidation.MemberMapInvalidationMetaDataFetcher) UUID(java.util.UUID) MemberMapInvalidationMetaDataFetcher(com.hazelcast.map.impl.nearcache.invalidation.MemberMapInvalidationMetaDataFetcher) InvalidationMetaDataFetcher(com.hazelcast.internal.nearcache.impl.invalidation.InvalidationMetaDataFetcher)

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