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());
}
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;
}
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());
}
Aggregations