use of com.hazelcast.config.DurableExecutorConfig in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceTest method setup.
@Before
public void setup() {
Config config = new Config();
DurableExecutorConfig durableExecutorConfig = config.getDurableExecutorConfig(SINGLE_TASK + "*");
durableExecutorConfig.setCapacity(1);
hazelcastFactory.newHazelcastInstance(config);
hazelcastFactory.newHazelcastInstance(config);
hazelcastFactory.newHazelcastInstance(config);
hazelcastFactory.newHazelcastInstance(config);
client = hazelcastFactory.newHazelcastClient();
}
use of com.hazelcast.config.DurableExecutorConfig in project hazelcast by hazelcast.
the class TestFullApplicationContext method testDurableExecutorConfig.
@Test
public void testDurableExecutorConfig() {
DurableExecutorConfig testExecConfig = config.getDurableExecutorConfig("durableExec");
assertNotNull(testExecConfig);
assertEquals("durableExec", testExecConfig.getName());
assertEquals(10, testExecConfig.getPoolSize());
assertEquals(5, testExecConfig.getDurability());
assertEquals(200, testExecConfig.getCapacity());
}
use of com.hazelcast.config.DurableExecutorConfig in project hazelcast by hazelcast.
the class DurableExecutorServiceTest method hazelcastInstanceAwareAndLocal.
@Test
public void hazelcastInstanceAwareAndLocal() throws Exception {
Config config = new Config();
config.addDurableExecutorConfig(new DurableExecutorConfig("test").setPoolSize(1));
HazelcastInstance instance = createHazelcastInstance(config);
DurableExecutorService executor = instance.getDurableExecutorService("test");
HazelcastInstanceAwareRunnable task = new HazelcastInstanceAwareRunnable();
// if setHazelcastInstance() not called we expect a RuntimeException
executor.submit(task).get();
}
use of com.hazelcast.config.DurableExecutorConfig in project hazelcast by hazelcast.
the class DurableSpecificSetupTest method managedContext_mustInitializeRunnable.
@Test
public void managedContext_mustInitializeRunnable() throws Exception {
final AtomicBoolean initialized = new AtomicBoolean();
Config config = new Config().addDurableExecutorConfig(new DurableExecutorConfig("test").setPoolSize(1)).setManagedContext(new ManagedContext() {
@Override
public Object initialize(Object obj) {
if (obj instanceof RunnableWithManagedContext) {
initialized.set(true);
}
return obj;
}
});
DurableExecutorService executor = createHazelcastInstance(config).getDurableExecutorService("test");
executor.submit(new RunnableWithManagedContext()).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 DurableExecutorServiceTest method testStatsIssue2039.
@Test
public // @Repeat(100)
void testStatsIssue2039() throws Exception {
Config config = new Config();
String name = "testStatsIssue2039";
config.addDurableExecutorConfig(new DurableExecutorConfig(name).setPoolSize(1).setCapacity(1));
HazelcastInstance instance = createHazelcastInstance(config);
DurableExecutorService executorService = instance.getDurableExecutorService(name);
executorService.execute(new SleepLatchRunnable());
assertOpenEventually(SleepLatchRunnable.startLatch, 30);
Future rejected = executorService.submit(new EmptyRunnable());
try {
rejected.get(1, TimeUnit.MINUTES);
} catch (Exception e) {
boolean isRejected = e.getCause() instanceof RejectedExecutionException;
if (!isRejected) {
fail(e.toString());
}
} finally {
SleepLatchRunnable.sleepLatch.countDown();
}
// FIXME as soon as executorService.getLocalExecutorStats() is implemented
//LocalExecutorStats stats = executorService.getLocalExecutorStats();
//assertEquals(2, stats.getStartedTaskCount());
//assertEquals(0, stats.getPendingTaskCount());
}
Aggregations