use of com.orientechnologies.orient.core.storage.cache.OCacheEntry in project orientdb by orientechnologies.
the class OPaginatedCluster method updateClusterState.
private void updateClusterState(long fileId, long pinnedStateEntryIndex, long sizeDiff, long recordsSizeDiff, OAtomicOperation atomicOperation) throws IOException {
final OCacheEntry pinnedStateEntry = loadPage(atomicOperation, fileId, pinnedStateEntryIndex, true);
pinnedStateEntry.acquireExclusiveLock();
try {
OPaginatedClusterState paginatedClusterState = new OPaginatedClusterState(pinnedStateEntry, getChanges(atomicOperation, pinnedStateEntry));
paginatedClusterState.setSize(paginatedClusterState.getSize() + sizeDiff);
paginatedClusterState.setRecordsSize(paginatedClusterState.getRecordsSize() + recordsSizeDiff);
} finally {
pinnedStateEntry.releaseExclusiveLock();
releasePage(atomicOperation, pinnedStateEntry);
}
}
use of com.orientechnologies.orient.core.storage.cache.OCacheEntry in project orientdb by orientechnologies.
the class OPaginatedCluster method updateFreePagesList.
private void updateFreePagesList(long fileId, long pinnedStateEntryIndex, int freeListIndex, long pageIndex, OAtomicOperation atomicOperation) throws IOException {
final OCacheEntry pinnedStateEntry = loadPage(atomicOperation, fileId, pinnedStateEntryIndex, true);
pinnedStateEntry.acquireExclusiveLock();
try {
OPaginatedClusterState paginatedClusterState = new OPaginatedClusterState(pinnedStateEntry, getChanges(atomicOperation, pinnedStateEntry));
paginatedClusterState.setFreeListPage(freeListIndex, pageIndex);
} finally {
pinnedStateEntry.releaseExclusiveLock();
releasePage(atomicOperation, pinnedStateEntry);
}
}
use of com.orientechnologies.orient.core.storage.cache.OCacheEntry in project orientdb by orientechnologies.
the class OPaginatedCluster method readDebug.
public OPaginatedClusterDebug readDebug(long clusterPosition) throws IOException {
startOperation();
try {
OPaginatedClusterDebug debug = new OPaginatedClusterDebug();
debug.clusterPosition = clusterPosition;
debug.fileId = fileId;
OAtomicOperation atomicOperation = storageLocal.getAtomicOperationsManager().getCurrentOperation();
OClusterPositionMapBucket.PositionEntry positionEntry = clusterPositionMap.get(clusterPosition, 1);
if (positionEntry == null) {
debug.empty = true;
return debug;
}
long pageIndex = positionEntry.getPageIndex();
int recordPosition = positionEntry.getRecordPosition();
if (getFilledUpTo(atomicOperation, fileId) <= pageIndex) {
debug.empty = true;
return debug;
}
debug.pages = new ArrayList<OClusterPageDebug>();
int contentSize = 0;
long nextPagePointer;
boolean firstEntry = true;
do {
OClusterPageDebug debugPage = new OClusterPageDebug();
debugPage.pageIndex = pageIndex;
OCacheEntry cacheEntry = loadPage(atomicOperation, fileId, pageIndex, false);
cacheEntry.acquireSharedLock();
try {
final OClusterPage localPage = new OClusterPage(cacheEntry, false, getChanges(atomicOperation, cacheEntry));
if (localPage.isDeleted(recordPosition)) {
if (debug.pages.isEmpty()) {
debug.empty = true;
return debug;
} else
throw new OPaginatedClusterException("Content of record " + new ORecordId(id, clusterPosition) + " was broken", this);
}
debugPage.inPagePosition = recordPosition;
debugPage.inPageSize = localPage.getRecordSize(recordPosition);
byte[] content = localPage.getRecordBinaryValue(recordPosition, 0, debugPage.inPageSize);
debugPage.content = content;
if (firstEntry && content[content.length - OLongSerializer.LONG_SIZE - OByteSerializer.BYTE_SIZE] == 0) {
debug.empty = true;
return debug;
}
debug.pages.add(debugPage);
nextPagePointer = OLongSerializer.INSTANCE.deserializeNative(content, content.length - OLongSerializer.LONG_SIZE);
contentSize += content.length - OLongSerializer.LONG_SIZE - OByteSerializer.BYTE_SIZE;
firstEntry = false;
} finally {
cacheEntry.releaseSharedLock();
releasePage(atomicOperation, cacheEntry);
}
pageIndex = getPageIndex(nextPagePointer);
recordPosition = getRecordPosition(nextPagePointer);
} while (nextPagePointer >= 0);
debug.contentSize = contentSize;
return debug;
} finally {
completeOperation();
}
}
use of com.orientechnologies.orient.core.storage.cache.OCacheEntry in project orientdb by orientechnologies.
the class ConcurrentLRUListConcurrentTest method assertListConsistency.
private void assertListConsistency() {
int expectedSize = list.size();
int count = 0;
List<OCacheEntry> items = new ArrayList<OCacheEntry>();
for (OCacheEntry entry : list) {
items.add(entry);
count++;
}
Assert.assertEquals(count, expectedSize);
Collections.reverse(items);
for (OCacheEntry item : items) {
OCacheEntry actual = list.removeLRU();
Assert.assertEquals(actual, item);
}
Assert.assertNull(list.removeLRU());
}
use of com.orientechnologies.orient.core.storage.cache.OCacheEntry in project orientdb by orientechnologies.
the class ConcurrentLRUListConcurrentTest method assertListConsistency.
private void assertListConsistency(int expectedSize) {
Assert.assertEquals(list.size(), expectedSize);
int count = 0;
List<OCacheEntry> items = new ArrayList<OCacheEntry>();
for (OCacheEntry entry : list) {
items.add(entry);
count++;
}
Assert.assertEquals(count, expectedSize);
Collections.reverse(items);
for (OCacheEntry item : items) {
OCacheEntry actual = list.removeLRU();
Assert.assertEquals(actual, item);
}
Assert.assertNull(list.removeLRU());
}
Aggregations