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();
}
}
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();
}
}
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();
}
}
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;
}
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);
}
}
Aggregations