use of com.orientechnologies.orient.core.exception.OClusterPositionMapException in project orientdb by orientechnologies.
the class OClusterPositionMap method create.
public void create() throws IOException {
startOperation();
try {
final OAtomicOperation atomicOperation = startAtomicOperation(false);
acquireExclusiveLock();
try {
fileId = addFile(atomicOperation, getFullName());
endAtomicOperation(false, null);
} catch (IOException ioe) {
endAtomicOperation(true, ioe);
throw ioe;
} catch (Exception e) {
endAtomicOperation(true, e);
throw OException.wrapException(new OClusterPositionMapException("Error during cluster position - physical position map", this), e);
} finally {
releaseExclusiveLock();
}
} finally {
completeOperation();
}
}
use of com.orientechnologies.orient.core.exception.OClusterPositionMapException in project orientdb by orientechnologies.
the class OClusterPositionMap method add.
public long add(long pageIndex, int recordPosition) throws IOException {
startOperation();
try {
OAtomicOperation atomicOperation = startAtomicOperation(true);
acquireExclusiveLock();
try {
long lastPage = getFilledUpTo(atomicOperation, fileId) - 1;
OCacheEntry cacheEntry;
if (lastPage < 0)
cacheEntry = addPage(atomicOperation, fileId);
else
cacheEntry = loadPage(atomicOperation, fileId, lastPage, false, 1);
Exception exception = null;
cacheEntry.acquireExclusiveLock();
try {
OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, getChanges(atomicOperation, cacheEntry));
if (bucket.isFull()) {
cacheEntry.releaseExclusiveLock();
releasePage(atomicOperation, cacheEntry);
cacheEntry = addPage(atomicOperation, fileId);
cacheEntry.acquireExclusiveLock();
bucket = new OClusterPositionMapBucket(cacheEntry, getChanges(atomicOperation, cacheEntry));
}
final long index = bucket.add(pageIndex, recordPosition);
return index + cacheEntry.getPageIndex() * OClusterPositionMapBucket.MAX_ENTRIES;
} catch (Exception e) {
exception = e;
throw OException.wrapException(new OClusterPositionMapException("Error during creation of mapping between logical and physical record position", this), e);
} finally {
try {
cacheEntry.releaseExclusiveLock();
releasePage(atomicOperation, cacheEntry);
} finally {
endAtomicOperation(exception != null, exception);
}
}
} finally {
releaseExclusiveLock();
}
} finally {
completeOperation();
}
}
use of com.orientechnologies.orient.core.exception.OClusterPositionMapException in project orientdb by orientechnologies.
the class OClusterPositionMap method truncate.
public void truncate() throws IOException {
startOperation();
try {
final OAtomicOperation atomicOperation = startAtomicOperation(true);
acquireExclusiveLock();
try {
truncateFile(atomicOperation, fileId);
endAtomicOperation(false, null);
} catch (IOException ioe) {
endAtomicOperation(true, ioe);
throw ioe;
} catch (Exception e) {
endAtomicOperation(true, e);
throw OException.wrapException(new OClusterPositionMapException("Error during truncation of cluster position - physical position map", this), e);
} finally {
releaseExclusiveLock();
}
} finally {
completeOperation();
}
}
Aggregations