Examples of IAtomicLong


Examples of com.hazelcast.core.IAtomicLong

            }
        });
        register(IdGeneratorService.SERVICE_NAME, new ClientProxyFactory() {
            public ClientProxy create(String id) {
                String name = String.valueOf(id);
                IAtomicLong atomicLong = client.getAtomicLong(IdGeneratorService.ATOMIC_LONG_NAME + name);
                return new ClientIdGeneratorProxy(instanceName, IdGeneratorService.SERVICE_NAME, name, atomicLong);
            }
        });
        register(CountDownLatchService.SERVICE_NAME, new ClientProxyFactory() {
            public ClientProxy create(String id) {
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

        return hazelcastInstance.getAtomicLong(ATOMIC_LONG_NAME + name);
    }

    @Override
    public DistributedObject createDistributedObject(String name) {
        IAtomicLong blockGenerator = getBlockGenerator(name);
        return new IdGeneratorProxy(blockGenerator, name, nodeEngine, this);
    }
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

        register(ReplicatedMapService.SERVICE_NAME, ClientReplicatedMapProxy.class);

        register(IdGeneratorService.SERVICE_NAME, new ClientProxyFactory() {
            public ClientProxy create(String id) {
                String instanceName = client.getName();
                IAtomicLong atomicLong = client.getAtomicLong(IdGeneratorService.ATOMIC_LONG_NAME + id);
                return new ClientIdGeneratorProxy(instanceName, IdGeneratorService.SERVICE_NAME, id, atomicLong);
            }
        });

        for (ProxyFactoryConfig proxyFactoryConfig : config.getProxyFactoryConfigs()) {
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

    }

    private static IdGenerator createIdGenerator() {
        String name = "id-" + UUID.randomUUID().toString();

        IAtomicLong blockGenerator = mockIAtomicLong();

        return new IdGeneratorProxy(blockGenerator, name, null, null);
    }
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

public class IAtomicLongMocks {

    /** Creates mocks IAtomicLong which wraps an AtomicLong **/
    public static IAtomicLong mockIAtomicLong() {
        final AtomicLong atomicLong = new AtomicLong(); // keeps actual value
        IAtomicLong iAtomicLong = mock(IAtomicLong.class);

        when( iAtomicLong.getAndIncrement() ).then( delegateTo(atomicLong) );
        when( iAtomicLong.compareAndSet(anyLong(), anyLong()) ).then( delegateTo(atomicLong) );

        return iAtomicLong;
    }
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

    @Test
    @ClientCompatibleTest
    public void getAndAlter() {
        HazelcastInstance hazelcastInstance = createHazelcastInstance();
        IAtomicLong ref = hazelcastInstance.getAtomicLong("getAndAlter");

        ref.set(10);
        assertEquals(10, ref.getAndAlter(new AddOneFunction()));
        assertEquals(11, ref.get());
    }
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

        assertEquals(7, result);
    }

    @Test
    public void testCompareAndSet() throws Exception {
        IAtomicLong atomicLong = getAtomicLong();
        atomicLong.set(11);

        final SimpleClient client = getClient();
        client.send(new CompareAndSetRequest(name, 9, 5));
        boolean result = (Boolean) client.receive();
        assertFalse(result);
        assertEquals(11, atomicLong.get());

        client.send(new CompareAndSetRequest(name, 11, 5));
        result = (Boolean) client.receive();
        assertTrue(result);
        assertEquals(5, atomicLong.get());
    }
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

        assertEquals(5, atomicLong.get());
    }

    @Test
    public void testGetAndAdd() throws IOException {
        IAtomicLong atomicLong = getAtomicLong();
        atomicLong.set(11);

        final SimpleClient client = getClient();
        client.send(new GetAndAddRequest(name, 4));
        long result = (Long) client.receive();
        assertEquals(11, result);
        assertEquals(15, atomicLong.get());
    }
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

        assertEquals(15, atomicLong.get());
    }

    @Test
    public void testGetAndSet() throws IOException {
        IAtomicLong atomicLong = getAtomicLong();
        atomicLong.set(11);

        final SimpleClient client = getClient();
        client.send(new GetAndSetRequest(name, 9));
        long result = (Long) client.receive();
        assertEquals(11, result);
        assertEquals(9, atomicLong.get());
    }
View Full Code Here

Examples of com.hazelcast.core.IAtomicLong

        assertEquals(9, atomicLong.get());
    }

    @Test
    public void testSet() throws IOException {
        IAtomicLong atomicLong = getAtomicLong();
        atomicLong.set(11);

        final SimpleClient client = getClient();
        client.send(new SetRequest(name, 7));
        client.receive();
        assertEquals(7, atomicLong.get());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.