Search in sources :

Example 61 with OAtomicOperation

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

the class OHashTableDirectory method getMaxRightChildDepth.

public byte getMaxRightChildDepth(int nodeIndex) throws IOException {
    startOperation();
    try {
        atomicOperationsManager.acquireReadLock(this);
        try {
            acquireSharedLock();
            try {
                OAtomicOperation atomicOperation = atomicOperationsManager.getCurrentOperation();
                final ODirectoryPage page = loadPage(nodeIndex, false, atomicOperation);
                try {
                    return page.getMaxRightChildDepth(getLocalNodeIndex(nodeIndex));
                } finally {
                    releasePage(page, false, atomicOperation);
                }
            } finally {
                releaseSharedLock();
            }
        } finally {
            atomicOperationsManager.releaseReadLock(this);
        }
    } finally {
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)

Example 62 with OAtomicOperation

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

the class OHashTableDirectory method clear.

public void clear() throws IOException {
    startOperation();
    try {
        OAtomicOperation atomicOperation = startAtomicOperation(true);
        acquireExclusiveLock();
        try {
            truncateFile(atomicOperation, fileId);
            init();
            endAtomicOperation(false, null);
        } catch (IOException e) {
            endAtomicOperation(true, e);
            throw e;
        } catch (Exception e) {
            endAtomicOperation(true, e);
            throw OException.wrapException(new OHashTableDirectoryException("Error during removing of hash table directory content", 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 63 with OAtomicOperation

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

the class OHashTableDirectory method getNodePointer.

public long getNodePointer(int nodeIndex, int index) throws IOException {
    startOperation();
    try {
        atomicOperationsManager.acquireReadLock(this);
        try {
            acquireSharedLock();
            try {
                final OAtomicOperation atomicOperation = atomicOperationsManager.getCurrentOperation();
                final ODirectoryPage page = loadPage(nodeIndex, false, atomicOperation);
                try {
                    return page.getPointer(getLocalNodeIndex(nodeIndex), index);
                } finally {
                    releasePage(page, false, atomicOperation);
                }
            } finally {
                releaseSharedLock();
            }
        } finally {
            atomicOperationsManager.releaseReadLock(this);
        }
    } finally {
        completeOperation();
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)

Example 64 with OAtomicOperation

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

the class OSBTreeCollectionManagerShared method loadTree.

@Override
protected OSBTreeBonsai<OIdentifiable, Integer> loadTree(OBonsaiCollectionPointer collectionPointer) {
    String fileName;
    OAtomicOperation atomicOperation = storage.getAtomicOperationsManager().getCurrentOperation();
    if (atomicOperation == null) {
        fileName = storage.getWriteCache().fileNameById(collectionPointer.getFileId());
    } else {
        fileName = atomicOperation.fileNameById(collectionPointer.getFileId());
    }
    OSBTreeBonsaiLocal<OIdentifiable, Integer> tree = new OSBTreeBonsaiLocal<OIdentifiable, Integer>(fileName.substring(0, fileName.length() - DEFAULT_EXTENSION.length()), DEFAULT_EXTENSION, storage);
    if (tree.load(collectionPointer.getRootPointer()))
        return tree;
    else
        return null;
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OSBTreeBonsaiLocal(com.orientechnologies.orient.core.index.sbtreebonsai.local.OSBTreeBonsaiLocal) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Example 65 with OAtomicOperation

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

the class OIndexRIDContainer method resolveFileIdByName.

private long resolveFileIdByName(String fileName) {
    final OAbstractPaginatedStorage storage = (OAbstractPaginatedStorage) ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getUnderlying();
    final OAtomicOperation atomicOperation;
    try {
        atomicOperation = storage.getAtomicOperationsManager().startAtomicOperation(fileName, true);
    } catch (IOException e) {
        throw OException.wrapException(new OIndexEngineException("Error creation of sbtree with name " + fileName, fileName), e);
    }
    try {
        final OReadCache readCache = storage.getReadCache();
        final OWriteCache writeCache = storage.getWriteCache();
        if (atomicOperation == null) {
            if (writeCache.exists(fileName))
                return writeCache.fileIdByName(fileName);
            return readCache.addFile(fileName, writeCache);
        } else {
            long fileId;
            if (atomicOperation.isFileExists(fileName))
                fileId = atomicOperation.loadFile(fileName);
            else
                fileId = atomicOperation.addFile(fileName);
            storage.getAtomicOperationsManager().endAtomicOperation(false, null, fileName);
            return fileId;
        }
    } catch (IOException e) {
        try {
            storage.getAtomicOperationsManager().endAtomicOperation(true, e, fileName);
        } catch (IOException ioe) {
            throw OException.wrapException(new OIndexEngineException("Error of rollback of atomic operation", fileName), ioe);
        }
        throw OException.wrapException(new OIndexEngineException("Error creation of sbtree with name " + fileName, fileName), e);
    }
}
Also used : OAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation) OWriteCache(com.orientechnologies.orient.core.storage.cache.OWriteCache) OReadCache(com.orientechnologies.orient.core.storage.cache.OReadCache) IOException(java.io.IOException) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) OIndexEngineException(com.orientechnologies.orient.core.index.OIndexEngineException)

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