Package com.hazelcast.test

Examples of com.hazelcast.test.TestThread


    @Test(timeout = 15000)
    public void testAwait() throws InterruptedException {
        HazelcastInstance instance = createHazelcastInstance();
        final ICountDownLatch latch = instance.getCountDownLatch(randomString());
        latch.trySetCount(1);
        TestThread thread = new TestThread() {
            public void doRun() {
                latch.countDown();
            }
        };
        thread.start();
        assertOpenEventually(latch);
    }
View Full Code Here


        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

    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);
            }
        };
        awaitThread.start();

        // give the awaitthread some time to get in the waiting state
        sleepSeconds(5);
        instance.shutdown();
        awaitThread.assertFailsEventually(HazelcastInstanceNotActiveException.class);
    }
View Full Code Here

        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();
            }
        }.start();
View Full Code Here

        final ILock lock = instance.getLock(randomString());
        final ICondition condition = lock.newCondition(randomString());

        final CountDownLatch latch = new CountDownLatch(1);

        new TestThread(){
            @Override
            public void doRun() {
                lock.lock();
                latch.countDown();
            }
View Full Code Here

        finalLatch.await(2, TimeUnit.MINUTES);
        assertEquals(size, count.get());
    }

    private TestThread createThreadWaitsForCondition(final CountDownLatch latch, final ILock lock, final ICondition condition, final CountDownLatch syncLatch) {
        TestThread t = new TestThread() {
            public void doRun() throws Exception {
                try {
                    lock.lock();
                    syncLatch.countDown();
                    condition.await();
View Full Code Here

TOP

Related Classes of com.hazelcast.test.TestThread

Copyright © 2018 www.massapicom. 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.