use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class PartitionControlledIdTest method testAtomicLong.
@Test
public void testAtomicLong() throws Exception {
String partitionKey = "hazelcast";
HazelcastInstance hz = getHazelcastInstance(partitionKey);
IAtomicLong atomicLong = hz.getAtomicLong("atomiclong@" + partitionKey);
atomicLong.incrementAndGet();
assertEquals("atomiclong@" + partitionKey, atomicLong.getName());
assertEquals(partitionKey, atomicLong.getPartitionKey());
AtomicLongService service = getNodeEngine(hz).getService(AtomicLongService.SERVICE_NAME);
assertTrue(service.containsAtomicLong(atomicLong.getName()));
}
use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class HazelcastOSGiInstanceTest method getAtomicLongCalledSuccessfullyOverOSGiInstance.
@Test
public void getAtomicLongCalledSuccessfullyOverOSGiInstance() {
IAtomicLong mockAtomicLong = mock(IAtomicLong.class);
HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
HazelcastOSGiInstance hazelcastOSGiInstance = HazelcastOSGiTestUtil.createHazelcastOSGiInstance(mockHazelcastInstance);
when(mockHazelcastInstance.getAtomicLong("my-atomiclong")).thenReturn(mockAtomicLong);
assertEquals(mockAtomicLong, hazelcastOSGiInstance.getAtomicLong("my-atomiclong"));
verify(mockHazelcastInstance).getAtomicLong("my-atomiclong");
}
use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class MBeanTest method testAtomicLong.
@Test
public void testAtomicLong() throws Exception {
IAtomicLong atomicLong = holder.getHz().getAtomicLong("atomiclong");
atomicLong.incrementAndGet();
holder.assertMBeanExistEventually("IAtomicLong", atomicLong.getName());
}
use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class MBeanDestroyTest method testAtomicLong.
@Test
public void testAtomicLong() throws Exception {
IAtomicLong atomicLong = holder.getHz().getAtomicLong("atomiclong");
atomicLong.incrementAndGet();
holder.assertMBeanExistEventually("IAtomicLong", atomicLong.getName());
destroyObjectAndAssert(atomicLong, "IAtomicLong");
}
use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class ScheduledExecutorServiceSlowTest method schedule_withStatefulRunnable_durable.
@Test
public void schedule_withStatefulRunnable_durable() throws ExecutionException, InterruptedException {
HazelcastInstance[] instances = createClusterWithCount(4);
IScheduledExecutorService executorService = getScheduledExecutor(instances, "s");
int waitStateSyncPeriodToAvoidPassiveState = 2000;
String key = generateKeyOwnedBy(instances[1]);
ICountDownLatch latch = instances[0].getCountDownLatch("latch");
IAtomicLong runC = instances[0].getAtomicLong("runC");
IAtomicLong loadC = instances[0].getAtomicLong("loadC");
latch.trySetCount(1);
IScheduledFuture future = executorService.scheduleOnKeyOwnerAtFixedRate(new StatefulRunnableTask("latch", "runC", "loadC"), key, 10, 10, SECONDS);
// Wait for task to get scheduled and start
latch.await(11, SECONDS);
Thread.sleep(waitStateSyncPeriodToAvoidPassiveState);
instances[1].getLifecycleService().shutdown();
// Reset latch - task should be running on a replica now
latch.trySetCount(7);
latch.await(70, SECONDS);
future.cancel(false);
assertEquals(getPartitionService(instances[0]).getPartitionId(key), future.getHandler().getPartitionId());
assertEquals(8, runC.get(), 1);
assertEquals(1, loadC.get());
}
Aggregations