Search in sources :

Example 1 with AtomicLongService

use of com.hazelcast.concurrent.atomiclong.AtomicLongService in project hazelcast by hazelcast.

the class PartitionControlledIdTest method testIdGenerator.

@Test
public void testIdGenerator() throws Exception {
    String partitionKey = "hazelcast";
    HazelcastInstance hz = getHazelcastInstance(partitionKey);
    IdGenerator idGenerator = hz.getIdGenerator("idgenerator@" + partitionKey);
    idGenerator.newId();
    assertEquals("idgenerator@" + partitionKey, idGenerator.getName());
    assertEquals(partitionKey, idGenerator.getPartitionKey());
    AtomicLongService service = getNodeEngine(hz).getService(AtomicLongService.SERVICE_NAME);
    assertTrue(service.containsAtomicLong("hz:atomic:idGenerator:" + idGenerator.getName()));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AtomicLongService(com.hazelcast.concurrent.atomiclong.AtomicLongService) IdGenerator(com.hazelcast.core.IdGenerator) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with AtomicLongService

use of com.hazelcast.concurrent.atomiclong.AtomicLongService 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()));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AtomicLongService(com.hazelcast.concurrent.atomiclong.AtomicLongService) IAtomicLong(com.hazelcast.core.IAtomicLong) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with AtomicLongService

use of com.hazelcast.concurrent.atomiclong.AtomicLongService in project hazelcast by hazelcast.

the class AtomicLongReplicationOperation method run.

@Override
public void run() throws Exception {
    AtomicLongService atomicLongService = getService();
    for (Map.Entry<String, Long> longEntry : migrationData.entrySet()) {
        String name = longEntry.getKey();
        AtomicLongContainer atomicLongContainer = atomicLongService.getLongContainer(name);
        Long value = longEntry.getValue();
        atomicLongContainer.set(value);
    }
}
Also used : AtomicLongService(com.hazelcast.concurrent.atomiclong.AtomicLongService) Map(java.util.Map) HashMap(java.util.HashMap) AtomicLongContainer(com.hazelcast.concurrent.atomiclong.AtomicLongContainer)

Aggregations

AtomicLongService (com.hazelcast.concurrent.atomiclong.AtomicLongService)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 AtomicLongContainer (com.hazelcast.concurrent.atomiclong.AtomicLongContainer)1 IAtomicLong (com.hazelcast.core.IAtomicLong)1 IdGenerator (com.hazelcast.core.IdGenerator)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1