Examples of ReadLock


Examples of java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock

        String currentMessage = currentMessageCache.get(topic);
        return currentMessage;
    }

    public void readLockUnlockConsumers(boolean lock) {
        ReadLock readlock = consumerListLock.readLock();
        lockUnlock(readlock, lock);
    }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock

            writeLockUnlockSubscription(false);
        }
    }

    public void readLockUnlockSubscriptions(boolean lock) {
        ReadLock readlock = subscriptionLock.readLock();
        lockUnlock(readlock, lock);
    }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock

           
            /* we are sending the diff check if we have proposals in memory to be able to
             * send a diff to the
             */
            ReentrantReadWriteLock lock = leader.zk.getZKDatabase().getLogLock();
            ReadLock rl = lock.readLock();
            try {
                rl.lock();       
                final long maxCommittedLog = leader.zk.getZKDatabase().getmaxCommittedLog();
                final long minCommittedLog = leader.zk.getZKDatabase().getminCommittedLog();
                LinkedList<Proposal> proposals = leader.zk.getZKDatabase().getCommittedLog();
                if (proposals.size() != 0) {
                    if ((maxCommittedLog >= peerLastZxid)
                            && (minCommittedLog <= peerLastZxid)) {
                        packetToSend = Leader.DIFF;
                        zxidToSend = maxCommittedLog;
                        for (Proposal propose: proposals) {
                            if (propose.packet.getZxid() > peerLastZxid) {
                                queuePacket(propose.packet);
                                QuorumPacket qcommit = new QuorumPacket(Leader.COMMIT, propose.packet.getZxid(),
                                        null, null);
                                queuePacket(qcommit);
                            }
                        }
                    } else if (peerLastZxid > maxCommittedLog) {
                        packetToSend = Leader.TRUNC;
                        zxidToSend = maxCommittedLog;
                        updates = zxidToSend;
                    }
                } else {
                    // just let the state transfer happen
                }              
               
                leaderLastZxid = leader.startForwarding(this, updates);
                if (peerLastZxid == leaderLastZxid) {
                    // We are in sync so we'll do an empty diff
                    packetToSend = Leader.DIFF;
                    zxidToSend = leaderLastZxid;
                }
            } finally {
                rl.unlock();
            }

            QuorumPacket newLeaderQP = new QuorumPacket(Leader.NEWLEADER,
                    leaderLastZxid, null, null);
            oa.writeRecord(newLeaderQP, "packet");
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.ReadLock

    /**
     * {@inheritDoc}
     */
    public boolean hasItem(NodeId id) {
        ReadLock lock = acquireReadLock();
        try {
            return stateMgr.hasItemState(id);
        } finally {
            lock.release();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.ReadLock

            throws RepositoryException {

        if (id.equals(getHistoryRootId())) {
            return null;
        }
        ReadLock lock = acquireReadLock();
        try {
            synchronized (versionItems) {
                InternalVersionItem item = versionItems.get(id);
                if (item == null) {
                    item = createInternalVersionItem(id);
                    if (item != null) {
                        versionItems.put(id, item);
                    } else {
                        return null;
                    }
                }
                return item;
            }
        } finally {
            lock.release();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.ReadLock

     * Matching items are removed from the cache.
     *
     * @param items items updated
     */
    public void itemsUpdated(Collection<InternalVersionItem> items) {
        ReadLock lock = acquireReadLock();
        try {
            synchronized (versionItems) {
                for (InternalVersionItem item : items) {
                    InternalVersionItem cached = versionItems.remove(item.getId());
                    if (cached != null) {
                        if (cached instanceof InternalVersionHistoryImpl) {
                            InternalVersionHistoryImpl vh = (InternalVersionHistoryImpl) cached;
                            try {
                                vh.reload();
                                versionItems.put(vh.getId(), vh);
                            } catch (RepositoryException e) {
                                log.warn("Unable to update version history: " + e.toString());
                            }
                        }
                    }
                }
            }
        } finally {
            lock.release();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.ReadLock

    /**
     * {@inheritDoc}
     */
    protected void itemDiscarded(InternalVersionItem item) {
        // evict removed item from cache
        ReadLock lock = acquireReadLock();
        try {
            versionItems.remove(item.getId());
        } finally {
            lock.release();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.ReadLock

     * <p/>
     * Remove item from cache on removal.
     */
    public void stateDestroyed(ItemState destroyed) {
        // evict removed item from cache
        ReadLock lock = acquireReadLock();
        try {
            versionItems.remove(destroyed.getId());
        } finally {
            lock.release();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.ReadLock

    /**
     * {@inheritDoc}
     */
    public InternalVersion[] getSuccessors() {
        ReadLock lock = vMgr.acquireReadLock();
        try {
            InternalValue[] values = node.getPropertyValues(NameConstants.JCR_SUCCESSORS);
            if (values != null) {
                InternalVersion[] versions = new InternalVersion[values.length];
                for (int i = 0; i < values.length; i++) {
                    versions[i] = versionHistory.getVersion(values[i].getNodeId());
                }
                return versions;
            } else {
                return new InternalVersion[0];
            }
        } finally {
            lock.release();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.ReadLock

     * @return the new copy
     * @throws RepositoryException if an error occurs
     */
    private InternalVersionHistoryImpl makeLocalCopy(InternalVersionHistoryImpl history)
            throws RepositoryException {
        ReadLock lock = acquireReadLock();
        try {
            NodeState state = (NodeState) stateMgr.getItemState(history.getId());
            NodeStateEx stateEx = new NodeStateEx(stateMgr, ntReg, state, null);
            return new InternalVersionHistoryImpl(this, stateEx);
        } catch (ItemStateException e) {
            throw new RepositoryException("Unable to make local copy", e);
        } finally {
            lock.release();
        }
    }
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.