Package org.exist.storage.lock

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


                    final Value endRef = new QNameWordRef(collectionId, qnames[q], end.toLowerCase(),
                        broker.getBrokerPool().getSymbols());
                    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


     */
    public void remove(String name) throws EXistException, LockException {
        short id = getId(name);
        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            byte[] fromKey = computeKey(id);
            byte[] toKey = computeKey((short) (id + 1));
            final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
            index.btree.remove(query, null);

View Full Code Here

    }

    private void remove(DocumentImpl doc, short id) throws LockException, EXistException {
        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            byte[] fromKey = computeKey(id, doc.getDocId());
            byte[] toKey = computeKey(id, doc.getDocId() + 1);
            final IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(toKey));
            index.btree.remove(query, null);
        } catch (BTreeException e) {
View Full Code Here

        byte[] fromKey = new byte[] { 1 };
        byte[] endKey = new byte[] { 2 };

        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(endKey));
            FindIdCallback callback = new FindIdCallback(true);
            index.btree.query(query, callback);

            for (long id : callback.allIds) {
View Full Code Here

            byte[] fromKey = { 1 };
            byte[] endKey = { 2 };
            IndexQuery query = new IndexQuery(IndexQuery.RANGE, new Value(fromKey), new Value(endKey));
            final Lock lock = index.btree.getLock();
            try {
                lock.acquire(Lock.READ_LOCK);
                FindIdCallback callback = new FindIdCallback(false);
                index.btree.query(query, callback);
                id = (short)(callback.max + 1);
                registerId(id, name);
            } catch (IOException e) {
View Full Code Here

        byte[] key = new byte[1 + UTF8.encoded(name)];
        key[0] = 1;
        UTF8.encode(name, key, 1);
        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            index.btree.addValue(new Value(key), id);
        } catch (LockException e) {
            throw new EXistException("Exception caught while reading sort index: " + e.getMessage(), e);
        } catch (BTreeException e) {
            throw new EXistException("Exception caught while reading sort index: " + e.getMessage(), e);
View Full Code Here

        byte[] key = new byte[1 + UTF8.encoded(name)];
        key[0] = 1;
        UTF8.encode(name, key, 1);
        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            index.btree.removeValue(new Value(key));
        } catch (LockException e) {
            throw new EXistException("Exception caught while reading sort index: " + e.getMessage(), e);
        } catch (BTreeException e) {
            throw new EXistException("Exception caught while reading sort index: " + e.getMessage(), e);
View Full Code Here

        byte[] key = new byte[1 + UTF8.encoded(name)];
        key[0] = 1;
        UTF8.encode(name, key, 1);
        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            return (short) index.btree.findValue(new Value(key));
        } catch (BTreeException e) {
            throw new EXistException("Exception caught while reading sort index: " + e.getMessage(), e);
        } catch (IOException e) {
            throw new EXistException("Exception caught while reading sort index: " + e.getMessage(), e);
View Full Code Here

    public void sync() throws DBException {
        if (btree == null)
            return;
        final Lock lock = btree.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);
            btree.flush();
        } catch (LockException e) {
            LOG.warn("Failed to acquire lock for '" + btree.getFile().getName() + "'", e);
            //TODO : throw an exception ? -pb
        } catch (DBException e) {
View Full Code Here

    public void createIndex(String name, List<SortItem> items) throws EXistException, LockException {
        // get an id for the new index
        short id = getOrRegisterId(name);
        final Lock lock = index.btree.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);
            long idx = 0;
            for (SortItem item : items) {
                byte[] key = computeKey(id, item.getNode());
                index.btree.addValue(new Value(key), idx++);
            }
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.