Package com.hazelcast.core

Examples of com.hazelcast.core.IdGenerator.newId()


        ServiceReference reference = context.getServiceReference("com.hazelcast.core.HazelcastInstance");
        HazelcastInstance instance = (HazelcastInstance) context.getService(reference);
        context.ungetService(reference);
        try {
            IdGenerator idGenerator = instance.getIdGenerator("cellar-smaple-generator");
            Long id = idGenerator.newId();
            topic = instance.getTopic("cellar-sample-topic");
            topic.addMessageListener(messageListener);
            topic.publish(new Message("id="+id));
        } catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here


        IdGenerator idGenerator = createIdGenerator();

        boolean initialized = idGenerator.init(initialValue);
        assertEquals(expected, initialized);

        long newId = idGenerator.newId();
        assertEquals(expectedValue, newId);
    }

    private IdGenerator createIdGenerator() {
        return hz.getIdGenerator("id-" + UUID.randomUUID().toString());
View Full Code Here

    }

    @Test
    public void testInitWhenAlreadyInitialized() {
        IdGenerator idGenerator = createIdGenerator();
        long first = idGenerator.newId();

        boolean initialized = idGenerator.init(10);
        assertFalse(initialized);

        long actual = idGenerator.newId();
View Full Code Here

        long first = idGenerator.newId();

        boolean initialized = idGenerator.init(10);
        assertFalse(initialized);

        long actual = idGenerator.newId();
        assertEquals(first + 1, actual);
    }

    @Test
    public void testNewId_withExplicitInit() {
View Full Code Here

    @Test
    public void testNewId_withExplicitInit() {
        IdGenerator idGenerator =createIdGenerator();
        assertTrue(idGenerator.init(10));

        long result = idGenerator.newId();
        assertEquals(11, result);
    }

    @Test
    public void testNewId_withoutExplictInit() {
View Full Code Here

    }

    @Test
    public void testNewId_withoutExplictInit() {
        IdGenerator idGenerator = createIdGenerator();
        long result = idGenerator.newId();
        assertEquals(0, result);
    }

    @Test
    public void testGeneratingMultipleBlocks() {
View Full Code Here

    public void testGeneratingMultipleBlocks() {
        IdGenerator idGenerator = createIdGenerator();

        long expected = 0;
        for (int k = 0; k < 3 * IdGeneratorProxy.BLOCK_SIZE; k++) {
            assertEquals(expected, idGenerator.newId());
            expected++;
        }
    }

    @Test
View Full Code Here

    @Test
    public void testDestroy() {
        IdGenerator idGenerator = createIdGenerator();
        String id = idGenerator.getName();
        idGenerator.newId();
        idGenerator.newId();

        idGenerator.destroy();

        IdGenerator newIdGenerator = hz.getIdGenerator(id);
View Full Code Here

    @Test
    public void testDestroy() {
        IdGenerator idGenerator = createIdGenerator();
        String id = idGenerator.getName();
        idGenerator.newId();
        idGenerator.newId();

        idGenerator.destroy();

        IdGenerator newIdGenerator = hz.getIdGenerator(id);
        long actual = newIdGenerator.newId();
View Full Code Here

        idGenerator.newId();

        idGenerator.destroy();

        IdGenerator newIdGenerator = hz.getIdGenerator(id);
        long actual = newIdGenerator.newId();
        assertEquals(0, actual);
    }
}
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.