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