Search in sources :

Example 6 with OHashTableDirectoryException

use of com.orientechnologies.orient.core.exception.OHashTableDirectoryException 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 7 with OHashTableDirectoryException

use of com.orientechnologies.orient.core.exception.OHashTableDirectoryException in project orientdb by orientechnologies.

the class OHashTableDirectory method setMaxLeftChildDepth.

public void setMaxLeftChildDepth(int nodeIndex, byte maxLeftChildDepth) throws IOException {
    startOperation();
    try {
        OAtomicOperation atomicOperation = startAtomicOperation(true);
        acquireExclusiveLock();
        try {
            final ODirectoryPage page = loadPage(nodeIndex, true, atomicOperation);
            try {
                page.setMaxLeftChildDepth(getLocalNodeIndex(nodeIndex), maxLeftChildDepth);
            } 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 max left 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)

Example 8 with OHashTableDirectoryException

use of com.orientechnologies.orient.core.exception.OHashTableDirectoryException in project orientdb by orientechnologies.

the class OHashTableDirectory method setNodePointer.

public void setNodePointer(int nodeIndex, int index, long pointer) throws IOException {
    startOperation();
    try {
        OAtomicOperation atomicOperation = startAtomicOperation(true);
        acquireExclusiveLock();
        try {
            final ODirectoryPage page = loadPage(nodeIndex, true, atomicOperation);
            try {
                page.setPointer(getLocalNodeIndex(nodeIndex), index, pointer);
            } 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 pointer", 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 9 with OHashTableDirectoryException

use of com.orientechnologies.orient.core.exception.OHashTableDirectoryException in project orientdb by orientechnologies.

the class OHashTableDirectory method deleteWithoutOpen.

public void deleteWithoutOpen() throws IOException {
    startOperation();
    try {
        final OAtomicOperation atomicOperation = startAtomicOperation(false);
        acquireExclusiveLock();
        try {
            if (isFileExists(atomicOperation, getFullName())) {
                fileId = openFile(atomicOperation, getFullName());
                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 deletion of hash table", 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 10 with OHashTableDirectoryException

use of com.orientechnologies.orient.core.exception.OHashTableDirectoryException in project orientdb by orientechnologies.

the class OHashTableDirectory method deleteNode.

public void deleteNode(int nodeIndex) throws IOException {
    startOperation();
    try {
        final OAtomicOperation atomicOperation = startAtomicOperation(true);
        acquireExclusiveLock();
        try {
            OCacheEntry firstEntry = loadPage(atomicOperation, fileId, firstEntryIndex, true);
            firstEntry.acquireExclusiveLock();
            try {
                ODirectoryFirstPage firstPage = new ODirectoryFirstPage(firstEntry, getChanges(atomicOperation, firstEntry), firstEntry);
                if (nodeIndex < ODirectoryFirstPage.NODES_PER_PAGE) {
                    firstPage.setPointer(nodeIndex, 0, firstPage.getTombstone());
                    firstPage.setTombstone(nodeIndex);
                } else {
                    final int pageIndex = nodeIndex / ODirectoryPage.NODES_PER_PAGE;
                    final int localNodeIndex = nodeIndex % ODirectoryPage.NODES_PER_PAGE;
                    final OCacheEntry cacheEntry = loadPage(atomicOperation, fileId, pageIndex, true);
                    cacheEntry.acquireExclusiveLock();
                    try {
                        ODirectoryPage page = new ODirectoryPage(cacheEntry, getChanges(atomicOperation, cacheEntry), cacheEntry);
                        page.setPointer(localNodeIndex, 0, firstPage.getTombstone());
                        firstPage.setTombstone(nodeIndex);
                    } finally {
                        cacheEntry.releaseExclusiveLock();
                        releasePage(atomicOperation, cacheEntry);
                    }
                }
            } 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 node deletion", this), e);
        } finally {
            releaseExclusiveLock();
        }
    } finally {
        completeOperation();
    }
}
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)

Aggregations

OException (com.orientechnologies.common.exception.OException)11 OHashTableDirectoryException (com.orientechnologies.orient.core.exception.OHashTableDirectoryException)11 OAtomicOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)11 IOException (java.io.IOException)11 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)2