Examples of ReadWriteLock


Examples of java.util.concurrent.locks.ReadWriteLock

        super(capacity);
        locks = new Lock[capacity];
        for(int j = 0; j < locks.length; j++) {
            locks[j] = new ReentrantLock();
        }
        ReadWriteLock rwLock = new ReentrantReadWriteLock();
        readLock = rwLock.readLock();
        writeLock = rwLock.writeLock();
    }
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

        final Map<GridNode, List<String>> assignMap = new HashMap<GridNode, List<String>>(_relativePaths.size());
        final List<Pair<String, Lock>> localExecResources = new ArrayList<Pair<String, Lock>>(_relativePaths.size());

        int totalLocked = 0;
        for(String path : _relativePaths) {
            ReadWriteLock lock = lockManager.obtainLock(path);
            final Lock rlock = lock.readLock();
            if(rlock.tryLock()) {
                localExecResources.add(new Pair<String, Lock>(path, rlock));
            } else {
                totalLocked++;
                final byte[] k = StringUtils.getBytes(path);
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

        final Map<GridNode, List<String>> assignMap = new HashMap<GridNode, List<String>>(relativePaths.size());
        final List<Pair<String, Lock>> localExecResources = new ArrayList<Pair<String, Lock>>(relativePaths.size());

        int totalLocked = 0;
        for(String path : relativePaths) {
            ReadWriteLock lock = lockManager.obtainLock(path);
            final Lock rlock = lock.readLock();
            if(rlock.tryLock()) {
                localExecResources.add(new Pair<String, Lock>(path, rlock));
            } else {
                totalLocked++;
                final List<GridNode> replicatedNodes;
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

                + pageSize);

        final FixedSegments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];

        final ReadWriteLock rwlock = new FairReadWriteLock();//new ReentrantReadWriteLock();

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
        for(int i = 0; i < threads; i++) {
            final int threadId = i;
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

                + ", scanPercentage: " + percent + ", scanLength: " + scanLength + ", pageSize: "
                + pageSize);

        final Segments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];
        final ReadWriteLock rwlock = new ReentrantReadWriteLock();

        final boolean isGCLOCK = (algo == ReplacementAlgorithm.GClock);

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

                + pageSize);

        final FixedSegments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];

        final ReadWriteLock rwlock = new FairReadWriteLock();//new ReentrantReadWriteLock();

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
        for(int i = 0; i < threads; i++) {
            final int threadId = i;
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

                + ", scanPercentage: " + percent + ", scanLength: " + scanLength + ", pageSize: "
                + pageSize);

        final Segments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];
        final ReadWriteLock rwlock = new ReentrantReadWriteLock();

        final boolean isGCLOCK = (algo == ReplacementAlgorithm.GClock);

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

        }

        preFileAppend(file, append);
        final FileOutputStream dst = new FileOutputStream(file, append);
        final String fp = file.getAbsolutePath();
        final ReadWriteLock filelock = accquireLock(fp, locks);
        final FileChannel fileCh = dst.getChannel();
        final long startPos = file.length();
        try {
            NIOUtils.transferFullyFrom(inChannel, 0, len, fileCh); // REVIEWME really an atomic operation?
        } finally {
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

    protected void postFileAppend(@Nonnull File file, long startPos, long len) throws IOException {}

    protected void postAck(@Nonnull File file, long startPos, long len) throws IOException {}

    private static ReadWriteLock accquireLock(final String key, final Map<String, ReadWriteLock> locks) {
        ReadWriteLock lock;
        synchronized(locks) {
            lock = locks.get(key);
            if(lock == null) {
                lock = new ReentrantReadWriteLock();
                locks.put(key, lock);
            }
        }
        lock.writeLock().lock();
        return lock;
    }
View Full Code Here

Examples of java.util.concurrent.locks.ReadWriteLock

        if (lifecycleManagerRegistry == null) {
            throw new NullPointerException("lifecycleManagerRegistry"); //$NON-NLS-1$
        }
        this.lifecycleManagerRegistry = lifecycleManagerRegistry;
        this.cacheByClass = new HashMap<Class<?>, ResourceRecord>();
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
        readersLock = readWriteLock.readLock();
        writersLock = readWriteLock.writeLock();

        if (customProperties == null) {
            customProperties = new Properties();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.