Package org.menagerie

Examples of org.menagerie.BaseZkSessionManager


                    If the read lock never acquires, then this method will block until the timeout
                    kills everything
                    */
                    ZooKeeper newSession = TestUtils.newLocalZooKeeper(timeout);
                    try{
                        ReadWriteLock rwLock = new ReentrantZkReadWriteLock2(baseLockPath,new BaseZkSessionManager(newSession));
                        final Lock readLock = rwLock.readLock();
                        readLock.lock();
                        try{
                            return null;
                        }finally{
View Full Code Here


                    If the read lock never acquires, then this method will block until the timeout
                    kills everything
                    */
                    ZooKeeper newSession = TestUtils.newLocalZooKeeper(timeout);
                    try{
                        ReadWriteLock rwLock2 = new ReentrantZkReadWriteLock2(baseLockPath,new BaseZkSessionManager(newSession));
                        Lock readLock = rwLock2.readLock();
                        readLock.lock();
                        try{
                            return null;
                        }finally{
View Full Code Here

            future = testService.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    ZooKeeper zk = TestUtils.newZooKeeper(hostString,timeout);
                    try{
                        ReadWriteLock rwLock = new ReentrantZkReadWriteLock2(baseLockPath,new BaseZkSessionManager(zk));
                        Lock writeLock = rwLock.writeLock();
                        writeLock.lock();
                        try{
                            return null;
                        }finally{
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

        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                ZooKeeper newZk = TestUtils.newZooKeeper(hostString, timeout);
                try {
                    final Lock sameLock = new ReentrantZkLock2(baseLockPath, new BaseZkSessionManager(newZk));
                    sameLock.lock();
                    try {
                        latch.countDown();
                    } finally {
                        sameLock.unlock();
View Full Code Here

            @Override
            public Void call() throws Exception{
                final Lock otherClientLock;
                ZooKeeper newZk = newZooKeeper(hostString,timeout);
                try {
                    otherClientLock = new ReentrantZkLock2(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

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

                    //create the lock that we're going to use
                    ZooKeeper zk = newZooKeeper(hostString,timeout);
                    try{
                        Lock testLock = new ReentrantZkLock2(baseLockPath,new BaseZkSessionManager(zk));
                        for(int j=0;j<numIterations;j++){
                            testLock.lock();
                            try{
                                operator.increment();
                            }finally{
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

        barrierPath = baseBarrierPath+System.currentTimeMillis();
        zk = newZooKeeper();

        //be sure that the lock-place is created
        try{
            ZkCommandExecutor zkCommandExecutor = new ZkCommandExecutor(new BaseZkSessionManager(zk));
            zkCommandExecutor.execute(new ZkCommand<Void>() {
                @Override
                public Void execute(ZooKeeper zk) throws KeeperException, InterruptedException {
                    zk.create(barrierPath,new byte[]{}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                    return null;
View Full Code Here

        }
    }

    @Test(timeout = 5000l)
    public void testBarrierWorks()throws Exception{
        cyclicBarrier = new ZkCyclicBarrier(1, new BaseZkSessionManager(zk), barrierPath);
        cyclicBarrier.await();
        //this method would timeout if await doesn't move forward
    }
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.