Search in sources :

Example 6 with ManagedExecutorService

use of com.hazelcast.internal.util.executor.ManagedExecutorService 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 7 with ManagedExecutorService

use of com.hazelcast.internal.util.executor.ManagedExecutorService in project hazelcast by hazelcast.

the class ExecutionServiceImpl method register.

private ManagedExecutorService register(String name, int defaultPoolSize, int defaultQueueCapacity, ExecutorType type, ThreadFactory threadFactory) {
    ExecutorConfig config = nodeEngine.getConfig().getExecutorConfigs().get(name);
    int poolSize = defaultPoolSize;
    int queueCapacity = defaultQueueCapacity;
    if (config != null) {
        poolSize = config.getPoolSize();
        if (config.getQueueCapacity() <= 0) {
            queueCapacity = Integer.MAX_VALUE;
        } else {
            queueCapacity = config.getQueueCapacity();
        }
    }
    ManagedExecutorService executor = createExecutor(name, poolSize, queueCapacity, type, threadFactory);
    if (executors.putIfAbsent(name, executor) != null) {
        throw new IllegalArgumentException("ExecutorService['" + name + "'] already exists!");
    }
    return executor;
}
Also used : ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) ExecutorConfig(com.hazelcast.config.ExecutorConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig)

Example 8 with ManagedExecutorService

use of com.hazelcast.internal.util.executor.ManagedExecutorService in project hazelcast by hazelcast.

the class ScheduledExecutorServiceBasicTest method config.

@Test
public void config() {
    String schedulerName = ANY_EXECUTOR_NAME;
    ScheduledExecutorConfig sec = new ScheduledExecutorConfig().setName(schedulerName).setDurability(5).setPoolSize(24);
    Config config = new Config().addScheduledExecutorConfig(sec);
    HazelcastInstance[] instances = createClusterWithCount(1, config);
    IScheduledFuture future = instances[0].getScheduledExecutorService(schedulerName).schedule(new PlainCallableTask(), 0, SECONDS);
    NodeEngineImpl nodeEngine = getNodeEngineImpl(instances[0]);
    ManagedExecutorService mes = (ManagedExecutorService) nodeEngine.getExecutionService().getScheduledDurable(sec.getName());
    DistributedScheduledExecutorService dses = nodeEngine.getService(DistributedScheduledExecutorService.SERVICE_NAME);
    assertNotNull(mes);
    assertEquals(24, mes.getMaximumPoolSize());
    assertEquals(5, dses.getPartition(future.getHandler().getPartitionId()).getOrCreateContainer(schedulerName).getDurability());
    assertEquals(1, dses.getPartition(future.getHandler().getPartitionId()).getOrCreateContainer("other").getDurability());
}
Also used : IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) Config(com.hazelcast.config.Config) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ManagedExecutorService (com.hazelcast.internal.util.executor.ManagedExecutorService)8 Config (com.hazelcast.config.Config)2 ScheduledExecutorConfig (com.hazelcast.config.ScheduledExecutorConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)2 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)1 ExecutorConfig (com.hazelcast.config.ExecutorConfig)1 CloseSessionOp (com.hazelcast.cp.internal.session.operation.CloseSessionOp)1 Node (com.hazelcast.instance.impl.Node)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 MetricsRegistry (com.hazelcast.internal.metrics.MetricsRegistry)1 AccumulationExecutor (com.hazelcast.map.impl.query.AccumulationExecutor)1 AggregationResultProcessor (com.hazelcast.map.impl.query.AggregationResultProcessor)1 CallerRunsAccumulationExecutor (com.hazelcast.map.impl.query.CallerRunsAccumulationExecutor)1 CallerRunsPartitionScanExecutor (com.hazelcast.map.impl.query.CallerRunsPartitionScanExecutor)1 ParallelAccumulationExecutor (com.hazelcast.map.impl.query.ParallelAccumulationExecutor)1 ParallelPartitionScanExecutor (com.hazelcast.map.impl.query.ParallelPartitionScanExecutor)1 PartitionScanExecutor (com.hazelcast.map.impl.query.PartitionScanExecutor)1 QueryRunner (com.hazelcast.map.impl.query.QueryRunner)1