use of com.hazelcast.config.DurableExecutorConfig in project hazelcast by hazelcast.
the class DurableExecutorServiceTest method testManagedContextAndLocal.
/* ############ submit runnable ############ */
@Test
public void testManagedContextAndLocal() throws Exception {
Config config = new Config();
config.addDurableExecutorConfig(new DurableExecutorConfig("test").setPoolSize(1));
final AtomicBoolean initialized = new AtomicBoolean();
config.setManagedContext(new ManagedContext() {
@Override
public Object initialize(Object obj) {
if (obj instanceof RunnableWithManagedContext) {
initialized.set(true);
}
return obj;
}
});
HazelcastInstance instance = createHazelcastInstance(config);
DurableExecutorService executor = instance.getDurableExecutorService("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.DurableExecutorConfig in project hazelcast by hazelcast.
the class DurableExecutorPartitionContainer method createExecutorContainer.
private DurableExecutorContainer createExecutorContainer(String name) {
DurableExecutorConfig durableExecutorConfig = nodeEngine.getConfig().findDurableExecutorConfig(name);
int durability = durableExecutorConfig.getDurability();
int ringBufferCapacity = durableExecutorConfig.getCapacity();
TaskRingBuffer ringBuffer = new TaskRingBuffer(ringBufferCapacity);
return new DurableExecutorContainer(nodeEngine, name, partitionId, durability, ringBuffer);
}
use of com.hazelcast.config.DurableExecutorConfig in project hazelcast by hazelcast.
the class DurableExecutorPartitionContainer method createExecutorContainer.
public void createExecutorContainer(String name, TaskRingBuffer ringBuffer) {
DurableExecutorConfig durableExecutorConfig = nodeEngine.getConfig().findDurableExecutorConfig(name);
int durability = durableExecutorConfig.getDurability();
executorContainerMap.put(name, new DurableExecutorContainer(nodeEngine, name, partitionId, durability, ringBuffer));
}
use of com.hazelcast.config.DurableExecutorConfig in project hazelcast by hazelcast.
the class ExecutorServiceTestSupport method createSingleNodeDurableExecutorService.
protected DurableExecutorService createSingleNodeDurableExecutorService(String name, int poolSize) {
DurableExecutorConfig executorConfig = new DurableExecutorConfig(name).setPoolSize(poolSize);
HazelcastInstance instance = createHazelcastInstance(new Config().addDurableExecutorConfig(executorConfig));
return instance.getDurableExecutorService(name);
}
Aggregations