Search in sources :

Example 6 with DurableExecutorConfig

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());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) ManagedContext(com.hazelcast.core.ManagedContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with DurableExecutorConfig

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);
}
Also used : DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig)

Example 8 with DurableExecutorConfig

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));
}
Also used : DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig)

Example 9 with DurableExecutorConfig

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig)

Aggregations

DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)9 Config (com.hazelcast.config.Config)6 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 ManagedContext (com.hazelcast.core.ManagedContext)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ExecutorConfig (com.hazelcast.config.ExecutorConfig)1 ICompletableFuture (com.hazelcast.core.ICompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 Before (org.junit.Before)1