Examples of trySetCount()


Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

    public void testSimpleUsage() throws InterruptedException {
        final int k = 5;
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(k);
        final HazelcastInstance[] instances = factory.newInstances();
        ICountDownLatch latch = instances[0].getCountDownLatch("test");
        latch.trySetCount(k - 1);
        assertEquals(k - 1, latch.getCount());

        new Thread() {
            public void run() {
                for (int i = 1; i < k; i++) {
View Full Code Here

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

    public void testLatchDestroyed() throws Exception {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        HazelcastInstance hz1 = factory.newHazelcastInstance();
        HazelcastInstance hz2 = factory.newHazelcastInstance();
        final ICountDownLatch latch = hz1.getCountDownLatch("test");
        latch.trySetCount(2);

        new TestThread() {
            public void doRun() throws Exception {
                sleep(1000);
                latch.destroy();
View Full Code Here

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

        HazelcastInstance hz1 = factory.newHazelcastInstance();
        HazelcastInstance hz2 = factory.newHazelcastInstance();
        warmUpPartitions(hz2, hz1);

        ICountDownLatch latch1 = hz1.getCountDownLatch("test");
        latch1.trySetCount(10);
        Thread.sleep(500);

        ICountDownLatch latch2 = hz2.getCountDownLatch("test");
        assertEquals(10, latch2.getCount());
        latch2.countDown();
View Full Code Here

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

    }

    @Test
    public void testCountDown() throws IOException {
        ICountDownLatch countDownLatch = getCountDownLatch();
        countDownLatch.trySetCount(1);
        final SimpleClient client = getClient();
        client.send(new CountDownRequest(name));
        client.receive();

        assertEquals(0, countDownLatch.getCount());
View Full Code Here

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

        HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
        HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
        HazelcastInstance h3 = Hazelcast.newHazelcastInstance(config);
        final String name = generateKeyOwnedBy(h3);
        ICountDownLatch countDownLatch = h3.getCountDownLatch(name);
        countDownLatch.trySetCount(5);

        TestMemberShipListener memberShipListener = new TestMemberShipListener(2);
        h3.getCluster().addMembershipListener(memberShipListener);
        TestLifeCycleListener lifeCycleListener = new TestLifeCycleListener(1);
        h3.getLifecycleService().addLifecycleListener(lifeCycleListener);
View Full Code Here

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

    @Test(expected = IllegalArgumentException.class)
    public void testTrySetCount_whenArgumentNegative() {
        HazelcastInstance instance = createHazelcastInstance();
        ICountDownLatch latch = instance.getCountDownLatch("latch");
        latch.trySetCount(-20);
    }

    @Test
    public void testTrySetCount_whenCountIsZero() {
        HazelcastInstance instance = createHazelcastInstance();
View Full Code Here

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

    @Test
    public void testTrySetCount_whenCountIsZero() {
        HazelcastInstance instance = createHazelcastInstance();
        ICountDownLatch latch = instance.getCountDownLatch(randomString());

        assertTrue(latch.trySetCount(40));
        assertEquals(40, latch.getCount());
    }

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

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

    @Test
    public void testTrySetCount_whenCountIsNotZero() {
        HazelcastInstance instance = createHazelcastInstance();
        ICountDownLatch latch = instance.getCountDownLatch(randomString());
        latch.trySetCount(10);
        assertFalse(latch.trySetCount(20));
        assertFalse(latch.trySetCount(0));
        assertEquals(10, latch.getCount());
    }
View Full Code Here

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

    @Test
    public void testTrySetCount_whenCountIsNotZero() {
        HazelcastInstance instance = createHazelcastInstance();
        ICountDownLatch latch = instance.getCountDownLatch(randomString());
        latch.trySetCount(10);
        assertFalse(latch.trySetCount(20));
        assertFalse(latch.trySetCount(0));
        assertEquals(10, latch.getCount());
    }

    @Test
View Full Code Here

Examples of com.hazelcast.core.ICountDownLatch.trySetCount()

    public void testTrySetCount_whenCountIsNotZero() {
        HazelcastInstance instance = createHazelcastInstance();
        ICountDownLatch latch = instance.getCountDownLatch(randomString());
        latch.trySetCount(10);
        assertFalse(latch.trySetCount(20));
        assertFalse(latch.trySetCount(0));
        assertEquals(10, latch.getCount());
    }

    @Test
    public void testTrySetCount_whenPositive() {
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.