use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.
the class ExecutorServiceTest method testManagedContextAndLocal.
@Test
public void testManagedContextAndLocal() throws Exception {
Config config = smallInstanceConfig();
config.addExecutorConfig(new ExecutorConfig("test", 1));
final AtomicBoolean initialized = new AtomicBoolean();
config.setManagedContext(obj -> {
if (obj instanceof RunnableWithManagedContext) {
initialized.set(true);
}
return obj;
});
HazelcastInstance instance = createHazelcastInstance(config);
IExecutorService executor = instance.getExecutorService("test");
RunnableWithManagedContext task = new RunnableWithManagedContext();
executor.submit(task).get();
assertTrue("The task should have been initialized by the ManagedContext", initialized.get());
}
use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.
the class DistributedExecutorServiceTest method testExecutorConfigCache_whenSecondTaskSubmitted_thenCachedConfigIsSame.
@Test
public void testExecutorConfigCache_whenSecondTaskSubmitted_thenCachedConfigIsSame() throws Exception {
IExecutorService executorService = hz.getExecutorService(EXECUTOR_NAME);
Future future = executorService.submit(new EmptyRunnable());
future.get();
ExecutorConfig cachedConfig = distributedExecutorService.executorConfigCache.get(EXECUTOR_NAME);
future = executorService.submit(new EmptyRunnable());
future.get();
assertEquals("Executor config cache should have cached one element", 1, distributedExecutorService.executorConfigCache.size());
assertSame("Executor config cache should have reused the same ExecutorConfig", cachedConfig, distributedExecutorService.executorConfigCache.get(EXECUTOR_NAME));
}
use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.
the class ExecutorServiceTestSupport method createSingleNodeExecutorService.
IExecutorService createSingleNodeExecutorService(String name, int poolSize, boolean statsEnabled) {
ExecutorConfig executorConfig = new ExecutorConfig(name, poolSize).setStatisticsEnabled(statsEnabled);
HazelcastInstance instance = createHazelcastInstance(smallInstanceConfig().addExecutorConfig(executorConfig));
return instance.getExecutorService(name);
}
use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.
the class AbstractDynamicConfigGeneratorTest method testExecutor.
// EXECUTOR
@Test
public void testExecutor() {
ExecutorConfig expectedConfig = new ExecutorConfig().setName("testExecutor").setStatisticsEnabled(true).setPoolSize(10).setQueueCapacity(100).setSplitBrainProtectionName("splitBrainProtection");
Config config = new Config().addExecutorConfig(expectedConfig);
Config decConfig = getNewConfigViaGenerator(config);
ExecutorConfig actualConfig = decConfig.getExecutorConfig(expectedConfig.getName());
assertEquals(expectedConfig, actualConfig);
}
use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.
the class DynamicConfigTest method testExecutorConfig.
@Test
public void testExecutorConfig() {
ExecutorConfig config = new ExecutorConfig(name, 7).setStatisticsEnabled(true).setQueueCapacity(13);
driver.getConfig().addExecutorConfig(config);
assertConfigurationsEqualOnAllMembers(config);
}
Aggregations