Package com.hazelcast.core

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


    public void testAwait_withManyThreads() {
        HazelcastInstance instance = createHazelcastInstance();
        final ICountDownLatch latch = instance.getCountDownLatch(randomString());
        final CountDownLatch completedLatch = new CountDownLatch(10);

        latch.trySetCount(1);
        for (int i = 0; i < 10; i++) {
            new TestThread() {
                public void doRun() throws Exception {
                    if (latch.await(1, TimeUnit.MINUTES)) {
                        completedLatch.countDown();
View Full Code Here


    @Test(timeout = 15000)
    public void testAwait_whenTimeOut() throws InterruptedException {
        HazelcastInstance instance = createHazelcastInstance();
        ICountDownLatch latch = instance.getCountDownLatch(randomString());

        latch.trySetCount(1);
        long time = System.currentTimeMillis();
        assertFalse(latch.await(100, TimeUnit.MILLISECONDS));
        long elapsed = System.currentTimeMillis() - time;
        assertTrue(elapsed >= 100);
        assertEquals(1, latch.getCount());
View Full Code Here

    @Test
    public void testAwait_whenInstanceShutdown_thenHazelcastInstanceNotActiveException() throws InterruptedException {
        HazelcastInstance instance = createHazelcastInstance();
        final ICountDownLatch latch = instance.getCountDownLatch(randomString());
        latch.trySetCount(10);

        final TestThread awaitThread = new TestThread() {
            @Override
            public void doRun() throws Exception {
                latch.await(1, TimeUnit.HOURS);
View Full Code Here

    public void testCountDownLatch() throws Exception {
        String partitionKey = "hazelcast";
        HazelcastInstance hz = getHazelcastInstance(partitionKey);

        ICountDownLatch countDownLatch = hz.getCountDownLatch("countdownlatch@" + partitionKey);
        countDownLatch.trySetCount(1);
        assertEquals("countdownlatch@" + partitionKey, countDownLatch.getName());
        assertEquals(partitionKey, countDownLatch.getPartitionKey());

        CountDownLatchService service = getNodeEngine(hz).getService(CountDownLatchService.SERVICE_NAME);
        assertTrue(service.containsLatch(countDownLatch.getName()));
View Full Code Here

    }

    @Test(expected = IllegalArgumentException.class)
    public void testTrySetCount_whenArgumentNegative() {
        ICountDownLatch latch = hz.getCountDownLatch(randomString());
        latch.trySetCount(-20);
    }

    @Test
    public void testTrySetCount_whenCountIsNotZero() {
        ICountDownLatch latch = hz.getCountDownLatch(randomString());
View Full Code Here

    }

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

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

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

    // Starting the countdown latch.
    ICountDownLatch countDownLatchForDeploy = context.getCoordinationStructures()
        .getCountDownLatchForDeploy(version);
    Set<String> dnodesInvolved = actionsPerDNode.keySet();
    countDownLatchForDeploy.trySetCount(dnodesInvolved.size());

    // Sending deploy signals to each DNode
    for(Map.Entry<String, List<DeployAction>> actionPerDNode : actionsPerDNode.entrySet()) {
      DNodeService.Client client = null;
      boolean renew = false;
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.