Search in sources :

Example 56 with OAtomicOperation

use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.

the class OHashTableDirectory method getNode.

public long[] getNode(int nodeIndex) throws IOException {
    startOperation();
    try {
        final long[] node = new long[LEVEL_SIZE];
        atomicOperationsManager.acquireReadLock(this);
        try {
            acquireSharedLock();
            try {
                OAtomicOperation atomicOperation = atomicOperationsManager.getCurrentOperation();
                final ODirectoryPage page = loadPage(nodeIndex, false, atomicOperation);
                try {
                    final int localNodeIndex = getLocalNodeIndex(nodeIndex);
                    for (int i = 0; i < LEVEL_SIZE; i++) node[i] = page.getPointer(localNodeIndex, i);
                } finally {
                    releasePage(page, false, atomicOperation);
                }
            } finally {
                releaseSharedLock();
            }
        } finally {
            atomicOperationsManager.releaseReadLock(this);
        }
        return node;
    } finally {
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)

Example 57 with OAtomicOperation

use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.

the class OHashTableDirectory method setNode.

public void setNode(int nodeIndex, long[] node) throws IOException {
    startOperation();
    try {
        OAtomicOperation atomicOperation = startAtomicOperation(true);
        acquireExclusiveLock();
        try {
            final ODirectoryPage page = loadPage(nodeIndex, true, atomicOperation);
            try {
                final int localNodeIndex = getLocalNodeIndex(nodeIndex);
                for (int i = 0; i < LEVEL_SIZE; i++) page.setPointer(localNodeIndex, i, node[i]);
            } finally {
                releasePage(page, true, atomicOperation);
            }
            endAtomicOperation(false, null);
        } catch (IOException e) {
            endAtomicOperation(true, e);
            throw e;
        } catch (Exception e) {
            endAtomicOperation(true, e);
            throw OException.wrapException(new OHashTableDirectoryException("Error during setting of node", this), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OHashTableDirectoryException(com.orientechnologies.orient.core.exception.OHashTableDirectoryException) IOException(java.io.IOException) OHashTableDirectoryException(com.orientechnologies.orient.core.exception.OHashTableDirectoryException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException)

Example 58 with OAtomicOperation

use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.

the class OHashTableDirectory method delete.

public void delete() throws IOException {
    startOperation();
    try {
        final OAtomicOperation atomicOperation = startAtomicOperation(false);
        acquireExclusiveLock();
        try {
            deleteFile(atomicOperation, fileId);
            endAtomicOperation(false, null);
        } catch (IOException e) {
            endAtomicOperation(true, e);
            throw e;
        } catch (Exception e) {
            endAtomicOperation(true, e);
            throw OException.wrapException(new OHashTableDirectoryException("Error during hash table deletion", this), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OHashTableDirectoryException(com.orientechnologies.orient.core.exception.OHashTableDirectoryException) IOException(java.io.IOException) OHashTableDirectoryException(com.orientechnologies.orient.core.exception.OHashTableDirectoryException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException)

Example 59 with OAtomicOperation

use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.

the class OHashTableDirectory method init.

private void init() throws IOException {
    OAtomicOperation atomicOperation = startAtomicOperation(false);
    try {
        OCacheEntry firstEntry = loadPage(atomicOperation, fileId, firstEntryIndex, true);
        if (firstEntry == null) {
            firstEntry = addPage(atomicOperation, fileId);
            assert firstEntry.getPageIndex() == 0;
        }
        pinPage(atomicOperation, firstEntry);
        firstEntry.acquireExclusiveLock();
        try {
            ODirectoryFirstPage firstPage = new ODirectoryFirstPage(firstEntry, getChanges(atomicOperation, firstEntry), firstEntry);
            firstPage.setTreeSize(0);
            firstPage.setTombstone(-1);
        } finally {
            firstEntry.releaseExclusiveLock();
            releasePage(atomicOperation, firstEntry);
        }
        endAtomicOperation(false, null);
    } catch (IOException e) {
        endAtomicOperation(true, e);
        throw e;
    } catch (Exception e) {
        endAtomicOperation(true, e);
        throw OException.wrapException(new OHashTableDirectoryException("Error during hash table initialization", this), e);
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OHashTableDirectoryException(com.orientechnologies.orient.core.exception.OHashTableDirectoryException) IOException(java.io.IOException) OHashTableDirectoryException(com.orientechnologies.orient.core.exception.OHashTableDirectoryException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException)

Example 60 with OAtomicOperation

use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.

the class OHashTableDirectory method setMaxRightChildDepth.

public void setMaxRightChildDepth(int nodeIndex, byte maxRightChildDepth) throws IOException {
    startOperation();
    try {
        OAtomicOperation atomicOperation = startAtomicOperation(true);
        acquireExclusiveLock();
        try {
            final ODirectoryPage page = loadPage(nodeIndex, true, atomicOperation);
            try {
                page.setMaxRightChildDepth(getLocalNodeIndex(nodeIndex), maxRightChildDepth);
            } finally {
                releasePage(page, true, atomicOperation);
            }
            endAtomicOperation(false, null);
        } catch (IOException e) {
            endAtomicOperation(true, e);
            throw e;
        } catch (Exception e) {
            endAtomicOperation(true, e);
            throw OException.wrapException(new OHashTableDirectoryException("Error during setting of right max child depth", this), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OHashTableDirectoryException(com.orientechnologies.orient.core.exception.OHashTableDirectoryException) IOException(java.io.IOException) OHashTableDirectoryException(com.orientechnologies.orient.core.exception.OHashTableDirectoryException) OException(com.orientechnologies.common.exception.OException) IOException(java.io.IOException)

Aggregations

OAtomicOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)118 IOException (java.io.IOException)94 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)76 OException (com.orientechnologies.common.exception.OException)42 OIndexException (com.orientechnologies.orient.core.index.OIndexException)28 OSessionStoragePerformanceStatistic (com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)25 OLocalHashTableException (com.orientechnologies.orient.core.exception.OLocalHashTableException)16 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)16 OSBTreeBonsaiLocalException (com.orientechnologies.orient.core.exception.OSBTreeBonsaiLocalException)13 Lock (java.util.concurrent.locks.Lock)13 OHashTableDirectoryException (com.orientechnologies.orient.core.exception.OHashTableDirectoryException)11 OTooBigIndexKeyException (com.orientechnologies.orient.core.exception.OTooBigIndexKeyException)11 OPaginatedClusterException (com.orientechnologies.orient.core.exception.OPaginatedClusterException)9 OIndexEngineException (com.orientechnologies.orient.core.index.OIndexEngineException)9 OClusterPositionMapException (com.orientechnologies.orient.core.exception.OClusterPositionMapException)8 ORecordId (com.orientechnologies.orient.core.id.ORecordId)7 ORecordNotFoundException (com.orientechnologies.orient.core.exception.ORecordNotFoundException)6 OReadCache (com.orientechnologies.orient.core.storage.cache.OReadCache)2 OWriteCache (com.orientechnologies.orient.core.storage.cache.OWriteCache)2 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)1