use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class LRUListTest method testAddElevenRemoveLRU.
@Test
public void testAddElevenRemoveLRU() {
final OByteBufferPool bufferPool = new OByteBufferPool(1);
OCachePointer[] cachePointers = new OCachePointer[11];
for (int i = 0; i < 11; i++) {
ByteBuffer buffer = bufferPool.acquireDirect(true);
cachePointers[i] = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
lruList.putToMRU(new OCacheEntry(1, i * 10, cachePointers[i], false));
}
lruList.removeLRU();
Assert.assertEquals(lruList.size(), 10);
Iterator<OCacheEntry> entryIterator = lruList.iterator();
for (int i = 10; i > 0; i--) {
Assert.assertTrue(entryIterator.hasNext());
Assert.assertEquals(entryIterator.next(), new OCacheEntry(1, i * 10, cachePointers[i], false));
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ONullBucketTest method testAddGetValue.
public void testAddGetValue() throws IOException {
OByteBufferPool bufferPool = new OByteBufferPool(1024);
ByteBuffer buffer = bufferPool.acquireDirect(true);
OCachePointer cachePointer = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
cachePointer.incrementReferrer();
OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
cacheEntry.acquireExclusiveLock();
ONullBucket<String> bucket = new ONullBucket<String>(cacheEntry, null, OStringSerializer.INSTANCE, true);
bucket.setValue(new OSBTreeValue<String>(false, -1, "test"));
OSBTreeValue<String> treeValue = bucket.getValue();
Assert.assertEquals(treeValue.getValue(), "test");
cacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ONullBucketTest method testEmptyBucket.
public void testEmptyBucket() {
OByteBufferPool bufferPool = new OByteBufferPool(1024);
ByteBuffer buffer = bufferPool.acquireDirect(true);
OCachePointer cachePointer = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
cachePointer.incrementReferrer();
OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
cacheEntry.acquireExclusiveLock();
ONullBucket<String> bucket = new ONullBucket<String>(cacheEntry, null, OStringSerializer.INSTANCE, true);
Assert.assertNull(bucket.getValue());
cacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ReadWriteDiskCacheTest method testIfNotEnoughSpaceOldPagesShouldBeMovedToA1Out.
public void testIfNotEnoughSpaceOldPagesShouldBeMovedToA1Out() throws Exception {
long fileId = readBuffer.addFile(fileName, writeBuffer);
OCacheEntry[] entries = new OCacheEntry[6];
for (int i = 0; i < 6; i++) {
entries[i] = readBuffer.load(fileId, i, false, writeBuffer, 1, true);
if (entries[i] == null) {
entries[i] = readBuffer.allocateNewPage(fileId, writeBuffer, true);
Assert.assertEquals(entries[i].getPageIndex(), i);
}
entries[i].getCachePointer().acquireExclusiveLock();
entries[i].markDirty();
final ByteBuffer buffer = entries[i].getCachePointer().getSharedBuffer();
buffer.position(systemOffset);
buffer.put(new byte[] { (byte) i, 1, 2, seed, 4, 5, 6, 7 });
entries[i].getCachePointer().releaseExclusiveLock();
readBuffer.release(entries[i], writeBuffer);
}
LRUList am = readBuffer.getAm();
LRUList a1in = readBuffer.getA1in();
LRUList a1out = readBuffer.getA1out();
Assert.assertEquals(am.size(), 0);
for (int i = 0; i < 2; i++) {
OCacheEntry entry = generateRemovedEntry(fileId, i);
Assert.assertEquals(a1out.get(entry.getFileId(), entry.getPageIndex()), entry);
}
final OByteBufferPool bufferPool = OByteBufferPool.instance();
for (int i = 2; i < 6; i++) {
OCacheEntry entry = generateEntry(fileId, i, entries[i].getCachePointer().getSharedBuffer(), bufferPool, false, new OLogSequenceNumber(0, 0));
Assert.assertEquals(a1in.get(entry.getFileId(), entry.getPageIndex()), entry);
}
Assert.assertEquals(writeBuffer.getFilledUpTo(fileId), 6);
writeBuffer.flush();
for (int i = 0; i < 6; i++) {
assertFile(i, new byte[] { (byte) i, 1, 2, seed, 4, 5, 6, 7 }, new OLogSequenceNumber(0, 0));
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber in project orientdb by orientechnologies.
the class ClusterPageTest method testDeleteAddBiggerVersion.
public void testDeleteAddBiggerVersion() throws Exception {
OByteBufferPool bufferPool = OByteBufferPool.instance();
ByteBuffer buffer = bufferPool.acquireDirect(true);
OCachePointer cachePointer = new OCachePointer(buffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
cachePointer.incrementReferrer();
OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
cacheEntry.acquireExclusiveLock();
ByteBuffer directBuffer = bufferPool.acquireDirect(true);
OCachePointer directCachePointer = new OCachePointer(directBuffer, bufferPool, new OLogSequenceNumber(0, 0), 0, 0);
directCachePointer.incrementReferrer();
OCacheEntry directCacheEntry = new OCacheEntry(0, 0, directCachePointer, false);
directCacheEntry.acquireExclusiveLock();
try {
OClusterPage localPage = new OClusterPage(cacheEntry, true, new OWALChangesTree());
OClusterPage directLocalPage = new OClusterPage(directCacheEntry, true, null);
deleteAddBiggerVersion(localPage);
deleteAddBiggerVersion(directLocalPage);
assertChangesTracking(localPage, directBuffer, bufferPool);
} finally {
cacheEntry.releaseExclusiveLock();
directCacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
directCachePointer.decrementReferrer();
}
}
Aggregations