Package org.exist.storage.lock

Examples of org.exist.storage.lock.Lock.acquire()


        final byte[] fromKey = computeDocKey(doc.getDocId());
        final byte[] toKey = computeDocKey(doc.getDocId() + 1);
        final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);
            index.btree.remove(query, null);
        } catch (final LockException e) {
            NativeStructuralIndex.LOG.warn("Failed to lock structural index: " + e.getMessage(), e);
        } catch (final Exception e) {
            NativeStructuralIndex.LOG.warn("Exception caught while reading structural index for document " +
View Full Code Here


        final byte[] fromKey = computeDocKey(doc.getDocId());
        final byte[] toKey = computeDocKey(doc.getDocId() + 1);
        final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);
            index.btree.query(query, new BTreeCallback() {
                public boolean indexInfo(Value value, long pointer) throws TerminatedException {
                    final QName qname = readQName(value.getData());
                    qnames.add(qname);
                    return true;
View Full Code Here

                final byte[] toKey = computeKey(qname.getNameType(), qname, doc.getDocId() + 1);
                final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));

                final Lock lock = index.btree.getLock();
                try {
                    lock.acquire(Lock.READ_LOCK);
                    index.btree.query(query, new BTreeCallback() {
                        public boolean indexInfo(Value value, long pointer) throws TerminatedException {
                            Occurrences oc = occurrences.get(name);
                            if (oc == null) {
                                oc = new Occurrences(name);
View Full Code Here

        try {
            final Lock lock = index.btree.getLock();
            for (final Map.Entry<QName,List<NodeProxy>> entry: pending.entrySet()) {
                final QName qname = entry.getKey();
                try {
                    lock.acquire(Lock.WRITE_LOCK);
                    final List<NodeProxy> nodes = entry.getValue();
                    for (final NodeProxy proxy : nodes) {
                        final NodeId nodeId = proxy.getNodeId();
                        final byte[] key = computeKey(qname.getNameType(), qname, document.getDocId(), nodeId);
                        index.btree.addValue(new Value(key), computeValue(proxy));
View Full Code Here

     * @see org.exist.storage.ContentLoadingObserver#sync()
     */
    public void sync() {
        final Lock lock = dbTokens.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);
            dbTokens.flush();
        } catch (final LockException e) {
            LOG.warn("Failed to acquire lock for '" + dbTokens.getFile().getName() + "'", e);
            //TODO : throw an exception ? -pb
        } catch (final DBException e) {
View Full Code Here

     * @see org.exist.storage.ContentLoadingObserver#dropIndex(org.exist.collections.Collection)
     */
    public void dropIndex(Collection collection) {
        final Lock lock = dbTokens.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);
            // remove generic index
            Value value = new WordRef(collection.getId());
            dbTokens.removeAll(null, new IndexQuery(IndexQuery.TRUNC_RIGHT, value));
            // remove QName index
            value = new QNameWordRef(collection.getId());
View Full Code Here

            else {
                key = new QNameWordRef(collectionId, qname, token, broker.getBrokerPool().getSymbols());
            }
            final Lock lock = dbTokens.getLock();
            try {
                lock.acquire(Lock.READ_LOCK);
                final VariableByteInput is = dbTokens.getAsStream(key);
                //Does the token already has data in the index ?
                if (is == null)
                    {continue;}
                while (is.available() > 0) {
View Full Code Here

                    value = new QNameWordRef(collectionId, qname, broker.getBrokerPool().getSymbols());
                }
            }
            final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, value);
            try {
                lock.acquire(Lock.READ_LOCK);
                dbTokens.query(query, cb);
            } catch (final LockException e) {
                LOG.warn("Failed to acquire lock for '" + dbTokens.getFile().getName() + "'", e);
                //TODO : throw exception ? -pb
            } catch (final BTreeException e) {
View Full Code Here

            final int collectionId = ((Collection) iter.next()).getId();
            //Compute a key for the token
            final Value value = new WordRef(collectionId);
            final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, value);
            try {
                lock.acquire(Lock.READ_LOCK);
                dbTokens.query(query, cb);
            } catch (final LockException e) {
                LOG.warn("Failed to acquire lock for '" + dbTokens.getFile().getName() + "'", e);
                //TODO : throw exception ? -pb
            } catch (final IOException e) {
View Full Code Here

                final Value startRef = new WordRef(collectionId,  start.toLowerCase());
                final Value endRef = new WordRef(collectionId, end.toLowerCase());
                query = new IndexQuery(IndexQuery.BW, startRef, endRef);
            }
            try {
                lock.acquire(Lock.READ_LOCK);
                dbTokens.query(query, cb);
            } catch (final LockException e) {
                LOG.warn("Failed to acquire lock for '" + dbTokens.getFile().getName() + "'", e);
                //TODO : throw exception ? -pb
            } catch (final IOException e) {
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.