Search in sources :

Example 26 with ExecutionService

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

the class MigrationManagerTest method setupMocks.

private void setupMocks() {
    node = mock(Node.class);
    NodeEngineImpl nodeEngine = mock(NodeEngineImpl.class);
    HazelcastInstance instance = mock(HazelcastInstance.class);
    MetricsRegistry metricsRegistry = mock(MetricsRegistry.class);
    ExecutionService executionService = mock(ExecutionService.class);
    ManagedExecutorService asyncExecutor = mock(ManagedExecutorService.class);
    clusterService = mock(ClusterServiceImpl.class);
    when(node.getProperties()).thenReturn(new HazelcastProperties(new Config()));
    when(node.getNodeEngine()).thenReturn(nodeEngine);
    when(node.getClusterService()).thenReturn(clusterService);
    when(instance.getName()).thenReturn("dev");
    when(nodeEngine.getHazelcastInstance()).thenReturn(instance);
    when(nodeEngine.getMetricsRegistry()).thenReturn(metricsRegistry);
    when(executionService.getExecutor(any(String.class))).thenReturn(asyncExecutor);
    when(nodeEngine.getExecutionService()).thenReturn(executionService);
    when(clusterService.getClusterVersion()).thenReturn(Versions.CURRENT_CLUSTER_VERSION);
    partitionStateManager = mock(PartitionStateManager.class);
    partitionService = mock(InternalPartitionServiceImpl.class);
    when(partitionService.getPartitionStateManager()).thenReturn(partitionStateManager);
    when(node.getConfig()).thenReturn(new Config());
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) Node(com.hazelcast.instance.impl.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 27 with ExecutionService

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

the class ClientEngineImpl method newBlockingExecutor.

private Executor newBlockingExecutor() {
    final ExecutionService executionService = nodeEngine.getExecutionService();
    int coreSize = Runtime.getRuntime().availableProcessors();
    int threadCount = node.getProperties().getInteger(ClusterProperty.CLIENT_ENGINE_BLOCKING_THREAD_COUNT);
    if (threadCount <= 0) {
        threadCount = coreSize * BLOCKING_THREADS_PER_CORE;
    }
    logger.finest("Creating new client executor for blocking tasks with threadCount=" + threadCount);
    return executionService.register(ExecutionService.CLIENT_BLOCKING_EXECUTOR, threadCount, coreSize * EXECUTOR_QUEUE_CAPACITY_PER_CORE, ExecutorType.CONCRETE);
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 28 with ExecutionService

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

the class ClientEngineImpl method newClientQueryExecutor.

private Executor newClientQueryExecutor() {
    final ExecutionService executionService = nodeEngine.getExecutionService();
    int coreSize = RuntimeAvailableProcessors.get();
    int threadCount = node.getProperties().getInteger(ClusterProperty.CLIENT_ENGINE_QUERY_THREAD_COUNT);
    if (threadCount <= 0) {
        threadCount = coreSize * QUERY_THREADS_PER_CORE;
    }
    logger.finest("Creating new client query executor with threadCount=" + threadCount);
    return executionService.register(ExecutionService.CLIENT_QUERY_EXECUTOR, threadCount, coreSize * EXECUTOR_QUEUE_CAPACITY_PER_CORE, ExecutorType.CONCRETE);
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 29 with ExecutionService

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

the class ClusterViewListenerService method schedulePeriodicPush.

private void schedulePeriodicPush() {
    ExecutionService executor = nodeEngine.getExecutionService();
    executor.scheduleWithRepetition(this::pushView, PUSH_PERIOD_IN_SECONDS, PUSH_PERIOD_IN_SECONDS, TimeUnit.SECONDS);
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 30 with ExecutionService

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

the class JobCoordinationService method startScanningForJobs.

public void startScanningForJobs() {
    ExecutionService executionService = nodeEngine.getExecutionService();
    HazelcastProperties properties = nodeEngine.getProperties();
    maxJobScanPeriodInMillis = properties.getMillis(JOB_SCAN_PERIOD);
    try {
        executionService.schedule(COORDINATOR_EXECUTOR_NAME, this::scanJobs, 0, MILLISECONDS);
        logger.info("Jet started scanning for jobs");
    } catch (RejectedExecutionException ex) {
        logger.info("Scan jobs task is rejected on the execution service since the executor service" + " has shutdown", ex);
    }
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

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