Package org.menagerie

Examples of org.menagerie.BaseZkSessionManager


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

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


    @Test(timeout = 1000l)
    public void testMultipleClientsCannotAccessSameLock()throws Exception{
        final CountDownLatch latch = new CountDownLatch(1);
        final Lock firstLock = new ReentrantZkLock(baseLockPath, zkSessionManager);
        final Lock sameLock = new ReentrantZkLock(baseLockPath, new BaseZkSessionManager(newZooKeeper()));

        firstLock.lock();
        testService.submit(new Runnable() {
            @Override
            public void run() {
View Full Code Here

                    startBarrier.await(); //make sure all threads are in the same place before starting

                    //create the lock that we're going to use
                    ZooKeeper newZk = newZooKeeper();
                    try{
                        Lock testLock = new ReentrantZkLock(baseLockPath,new BaseZkSessionManager(newZk));
                        for(int j=0;j<numIterations;j++){
                            testLock.lock();
                            try{
                                operator.increment();
                            }finally{
View Full Code Here

            @Override
            public Void call() throws Exception {
                final Lock otherClientLock;
                ZooKeeper newZk = newZooKeeper();
                try {
                    otherClientLock = new ReentrantZkLock(baseLockPath, new BaseZkSessionManager(newZk));
                    final Condition otherClientCondition = otherClientLock.newCondition();
                    otherClientLock.lock();
                    System.out.println("Lock acquired on second thread");
                    try {
                        otherClientCondition.signal();
View Full Code Here

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

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

            @Override
            public String call() throws Exception {
                ZooKeeper newZk = newZooKeeper();
                try{
                    @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
                    ZkHashMap<String, String> myMap = new ZkHashMap<String, String>(testPath, new BaseZkSessionManager(newZk), serializer);
                    waiter.await(); //wait until all threads are ready to test

                    String myTestValue=null;
                    while(myTestValue==null){
                        System.out.println("Calling get!");
View Full Code Here

            @Override
            public Boolean call() throws Exception {
                ZooKeeper newZk = newZooKeeper();
                try{
                    @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
                    ZkHashMap<String, String> myMap = new ZkHashMap<String, String>(testPath, new BaseZkSessionManager(newZk), serializer);
                    waiter.await(); //wait until all threads are ready to test

                    //call put-if-absent and see if I won!
                    String myReturnedTestValue = myMap.putIfAbsent(testKey, testValue1);
                    return myReturnedTestValue.equals(testValue1);
View Full Code Here

            countDownLatch.closeLatch();
    }
   
    @Test(timeout = 5000l)
    public void testCountDownWorksWhenAwaitHappensAfterCountDown() throws Exception {
        countDownLatch = LatchBuilder.newCountDownLatch(1, baseBarrierPath, new BaseZkSessionManager(zk));
        System.out.println(countDownLatch.getCount());
        countDownLatch.countDown();
        countDownLatch.await();
    }
View Full Code Here

        countDownLatch.await();
    }

    @Test(timeout = 5000l)
    public void testCountDownWorksWhenCountHappensOnAnotherThread() throws Exception{
        countDownLatch = LatchBuilder.newCountDownLatch(1, baseBarrierPath, new BaseZkSessionManager(zk));
        executor.submit(new Runnable() {
            @Override
            public void run() {
                System.out.printf("Counting down at :%s%n",System.currentTimeMillis());
                countDownLatch.countDown();
View Full Code Here

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

    @Test(timeout = 5000l)
    public void testCountDownWorksWithTwoCountsOnOtherThreads() throws Exception{
        countDownLatch = LatchBuilder.newCountDownLatch(2, baseBarrierPath, new BaseZkSessionManager(zk));
        executor.submit(new Runnable() {
            @Override
            public void run() {
                System.out.printf("#1 Counting down at :%s%n",System.currentTimeMillis());
                countDownLatch.countDown();
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.