Package org.menagerie.locks

Examples of org.menagerie.locks.ReentrantZkLock$LockHolder


        segmentShift = 32 - sshift;
        segmentMask = ssize - 1;
        this.segments = ZkSegment.newArray(ssize);

        //need to build the map in a single, synchronized activity across all members
        Lock mapLock = new ReentrantZkLock(mapNode,zkSessionManager,privileges);
        mapLock.lock();
        try{
            //need to read the data out of zookeeper
            ZooKeeper zk = zkSessionManager.getZooKeeper();
            for(int i=0;i< segments.length;i++){
                try {
                    //attach the first segments to any segments which are already created
                    List<String> zkBuckets = ZkUtils.filterByPrefix(zk.getChildren(mapNode,false),"bucket");
                    ZkUtils.sortBySequence(zkBuckets,'-');
                    int numBucketsBuilt = 0;
                    for(int bucketIndex=0;bucketIndex<zkBuckets.size()&&bucketIndex< segments.length;bucketIndex++){
                        numBucketsBuilt++;
                        segments[bucketIndex] = new ZkSegment<K,V>(mapNode+"/"+zkBuckets.get(bucketIndex),
                                serializer,zkSessionManager,privileges);
                    }

                    //create any additional segments as needed
                    while(numBucketsBuilt< segments.length){
                        String bucketNode = ZkUtils.safeCreate(zk, mapNode + "/bucket-",
                                new byte[]{}, privileges, CreateMode.PERSISTENT_SEQUENTIAL);
                        segments[numBucketsBuilt] = new ZkSegment<K,V>(bucketNode,
                                serializer,zkSessionManager,privileges);
                        numBucketsBuilt++;
                    }
                } catch (KeeperException e) {
                    throw new RuntimeException(e);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }finally{
            mapLock.unlock();
        }
    }
View Full Code Here

TOP

Related Classes of org.menagerie.locks.ReentrantZkLock$LockHolder

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.