Package org.exist.storage.lock

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


        final CollectionCache collectionsCache = pool.getCollectionsCache();
        synchronized(collectionsCache) {
            final Lock lock = collectionsDb.getLock();
            try {
                lock.acquire(Lock.WRITE_LOCK);
                final DocumentImpl oldDoc = destination.getDocument(this, newName);

                if(!destination.getPermissionsNoLock().validate(getSubject(), Permission.EXECUTE)) {
                    throw new PermissionDeniedException("Account '" + getSubject().getName() + "' does not have execute access on the destination collection '" + destination.getURI() + "'.");
                }
View Full Code Here


     */
    private void removeResourceMetadata(final Txn transaction, final DocumentImpl document) {
        // remove document metadata
        final Lock lock = collectionsDb.getLock();
        try {
            lock.acquire(Lock.READ_LOCK);
            if(LOG.isDebugEnabled()) {
                LOG.debug("Removing resource metadata for " + document.getDocId());
            }
            final Value key = new CollectionStore.DocumentKey(document.getCollection().getId(), document.getResourceType(), document.getDocId());
            collectionsDb.remove(transaction, key);
View Full Code Here

            return nextDocId;
        }
        nextDocId = 1;
        final Lock lock = collectionsDb.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);
            final Value key = new CollectionStore.CollectionKey(CollectionStore.NEXT_DOC_ID_KEY);
            final Value data = collectionsDb.get(key);
            if(data != null) {
                nextDocId = ByteConversion.byteToInt(data.getData(), 0);
                ++nextDocId;
View Full Code Here

    protected void rebuildIndex(final byte indexId) {
        final BTree btree = getStorage(indexId);
        final Lock lock = btree.getLock();
        try {
            lock.acquire(Lock.WRITE_LOCK);

            LOG.info("Rebuilding index " + btree.getFile().getName());
            btree.rebuild();
            LOG.info("Index " + btree.getFile().getName() + " was rebuilt.");
        } catch(LockException | IOException | TerminatedException | DBException e) {
View Full Code Here

                }
            }.run();
            if(syncEvent == Sync.MAJOR_SYNC) {
                final Lock lock = collectionsDb.getLock();
                try {
                    lock.acquire(Lock.WRITE_LOCK);
                    collectionsDb.flush();
                } catch(final LockException e) {
                    LOG.warn("Failed to acquire lock on " + collectionsDb.getFile().getName(), e);
                } finally {
                    lock.release(Lock.WRITE_LOCK);
View Full Code Here

   */
  protected StoredNode[] selectAndLock(Txn transaction, Sequence nodes) throws LockException, PermissionDeniedException,
    XPathException, TriggerException {
      final Lock globalLock = context.getBroker().getBrokerPool().getGlobalUpdateLock();
      try {
          globalLock.acquire(Lock.READ_LOCK);
        
          lockedDocuments = nodes.getDocumentSet();
         
        // acquire a lock on all documents
          // we have to avoid that node positions change
View Full Code Here

    public void sync()
    {
        final Lock lock = dbValues.getLock();

        try {
            lock.acquire( Lock.WRITE_LOCK );
            dbValues.flush();
        }
        catch( final LockException e ) {
            LOG.warn( "Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e );
            //TODO : throw an exception ? -pb
View Full Code Here

                //Write (variable) length of node IDs
                os.writeFixedInt( nodeIDsLength, os.position() - nodeIDsLength - LENGTH_NODE_IDS );

                try {
                    lock.acquire( Lock.WRITE_LOCK );
                    Value v;

                    if( section == IDX_GENERIC ) {
                        v = new SimpleValue( collectionId, ( Indexable )key );
                    } else {
View Full Code Here

                final List<NodeId> storedGIDList = entry.getValue();
                final List<NodeId> newGIDList    = new ArrayList<NodeId>();
                os.clear();

                try {
                    lock.acquire( Lock.WRITE_LOCK );

                    //Compute a key for the value
                    Value searchKey;

                    if( section == IDX_GENERIC ) {
View Full Code Here

    public void dropIndex( Collection collection )
    {
        final Lock lock = dbValues.getLock();

        try {
            lock.acquire( Lock.WRITE_LOCK );

            //TODO : flush ? -pb
            // remove generic index
            Value ref = new SimpleValue( collection.getId() );
            dbValues.removeAll( null, new IndexQuery( IndexQuery.TRUNC_RIGHT, ref ) );
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.