Package org.menagerie

Examples of org.menagerie.BaseZkSessionManager


        System.out.printf("Count Down occurred. Time: %s%n",System.currentTimeMillis());
    }

    @Test(timeout = 5000l)
    public void testCountDownWorksWithTwoClients() throws Exception{
         countDownLatch = LatchBuilder.newCountDownLatch(2, baseBarrierPath, new BaseZkSessionManager(zk));
        final ZooKeeper myOtherZooKeeper = newZooKeeper();
        final DistributedCountDownLatch joinedCountDownLatch = LatchBuilder.newCountDownLatch(2,baseBarrierPath,new BaseZkSessionManager(myOtherZooKeeper));

        executor.submit(new Runnable() {
            @Override
            public void run() {
                System.out.printf("#1 Counting down at :%s%n",System.currentTimeMillis());
View Full Code Here


        }
    }

    @Test(timeout = 5000l)
    public void testCountDownSucceedsWithOneClientFailedAfterCountingDown() throws Exception{
        countDownLatch = LatchBuilder.newCountDownLatch(2, baseBarrierPath, new BaseZkSessionManager(zk));
        final ZooKeeper myOtherZooKeeper = newZooKeeper();
        final DistributedCountDownLatch joinedCountDownLatch = LatchBuilder.newCountDownLatch(2,baseBarrierPath,new BaseZkSessionManager(myOtherZooKeeper));
        System.out.printf("#1 Counting down at :%s%n",System.currentTimeMillis());
        joinedCountDownLatch.countDown();
        try {
            System.out.printf("Closing my zk client%n");
            myOtherZooKeeper.close();
View Full Code Here

        System.out.printf("Count Down occurred. Time: %s%n",System.currentTimeMillis());
    }

    @Test(timeout = 5000l)
    public void testMultipleCountDownsWork() throws Exception{
        countDownLatch = LatchBuilder.newCountDownLatch(1, baseBarrierPath, new BaseZkSessionManager(zk));
        assertEquals("The Initial count down latch does not have a count of zero!",0,countDownLatch.getCount());
        countDownLatch.countDown();
        assertEquals("The Initial count down latch does not have a count of one!",1,countDownLatch.getCount());
        countDownLatch.await();
        countDownLatch.closeLatch();

        countDownLatch = LatchBuilder.newCountDownLatch(1, baseBarrierPath, new BaseZkSessionManager(zk));
        assertEquals("The Initial count down latch does not have a count of zero!",0,countDownLatch.getCount());
        countDownLatch.countDown();
        assertEquals("The Initial count down latch does not have a count of one!",1,countDownLatch.getCount());
        countDownLatch.await();
    }
View Full Code Here

        countDownLatch.await();
    }

    @Test
    public void testLatchTimesOutCorrectly() throws Exception {
        countDownLatch = LatchBuilder.newCountDownLatch(1, baseBarrierPath, new BaseZkSessionManager(zk));

        boolean alerted = countDownLatch.await(500, TimeUnit.MILLISECONDS);
        assertTrue("The Count down latch returned an incorrect state!",!alerted);
    }
View Full Code Here

        //be sure that the lock-place is created
        ZkUtils.safeDelete(zk,basePath,-1);
        zk.create(basePath,new byte[]{}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

        zkSessionManager = new BaseZkSessionManager(zk);
    }
View Full Code Here

            @Override
            public Void call() throws Exception {
                ZooKeeper zk = newZooKeeper();
                try {

                    DistributedSemaphore semaphore2 = new ZkSemaphore(2, basePath, new BaseZkSessionManager(zk));
                    semaphore2.acquire();
                    latch.countDown();
                } finally {
                    zk.close();
                }
View Full Code Here

        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                ZooKeeper zk = newZooKeeper();
                try {
                    DistributedSemaphore semaphore2 = new ZkSemaphore(1, basePath, new BaseZkSessionManager(zk));
                    semaphore2.acquire();
                    latch.countDown();
                } finally {
                    zk.close();
                }
View Full Code Here

        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                ZooKeeper zk = newZooKeeper();
                try {
                    DistributedSemaphore semaphore2 = new ZkSemaphore(2, basePath, new BaseZkSessionManager(zk));
                    semaphore2.acquire(2);
                    latch.countDown();
                } finally {
                    zk.close();
                }
View Full Code Here

        //be sure that the lock-place is created

        zk.create(baseLockPath,new byte[]{}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

        zkSessionManager = new BaseZkSessionManager(zk);
    }
View Full Code Here

                    } catch (BrokenBarrierException e) {
                        fail(String.format("%d - %s",Thread.currentThread().getId(),e.getMessage()));
                    }
                    ZooKeeper zk = newZooKeeper();
                    try{
                        ZkSessionManager zksm = new BaseZkSessionManager(zk);
                        Lock guard = new ReentrantZkLock2(baseLockPath,zksm);
                        long totalStart = System.currentTimeMillis();
                        for(int i=0;i<MAX_LOCK_ATTEMPTS;i++){
                            timer.addTiming(guardedWork(guard,operator));
                        }
View Full Code Here

TOP

Related Classes of org.menagerie.BaseZkSessionManager

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.