use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.
the class ClusterPageTest method testDeleteAddLowerVersion.
public void testDeleteAddLowerVersion() 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);
deleteAddLowerVersion(localPage);
deleteAddLowerVersion(directLocalPage);
assertChangesTracking(localPage, directBuffer, bufferPool);
} finally {
cacheEntry.releaseExclusiveLock();
directCacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
directCachePointer.decrementReferrer();
}
}
use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.
the class ClusterPageTest method testReplaceOneRecordLowerVersion.
public void testReplaceOneRecordLowerVersion() 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);
replaceOneRecordLowerVersion(localPage);
replaceOneRecordLowerVersion(directLocalPage);
assertChangesTracking(localPage, directBuffer, bufferPool);
} finally {
cacheEntry.releaseExclusiveLock();
directCacheEntry.releaseExclusiveLock();
cachePointer.decrementReferrer();
directCachePointer.decrementReferrer();
}
}
use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.
the class WALChangesTreeTest method testAddOverlappedVersionsTwoDM.
public void testAddOverlappedVersionsTwoDM() {
final OWALChangesTree tree = new OWALChangesTree();
tree.setDebug(true);
tree.add(new byte[] { 11, 12, 13 }, 1);
tree.add(new byte[] { 33, 34, 35 }, 3);
tree.add(new byte[] { 22, 23, 24, 25, 26 }, 2);
OByteBufferPool bufferPool = new OByteBufferPool(20);
ByteBuffer buffer = bufferPool.acquireDirect(true);
tree.applyChanges(buffer);
Assert.assertEquals(getByteArray(buffer, 1, 6), new byte[] { 11, 22, 23, 24, 25, 26 });
}
use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.
the class WALChangesTreeTest method testInsertRandomDM.
public void testInsertRandomDM() {
final OWALChangesTree tree = new OWALChangesTree();
tree.setDebug(true);
final byte[] data = new byte[30];
final long ts = System.currentTimeMillis();
System.out.println("TestInsertRandomDM seed : " + ts);
final Random rnd = new Random(ts);
for (int i = 0; i < 100; i++) {
final int start = rnd.nextInt(data.length) - 3;
final int length = rnd.nextInt(3) + 4;
int cend = start + length;
if (cend > data.length)
cend = data.length;
int cstart = start;
if (cstart < 0)
cstart = 0;
byte[] value = new byte[cend - cstart];
rnd.nextBytes(value);
System.arraycopy(value, 0, data, cstart, cend - cstart);
tree.add(value, cstart);
}
OByteBufferPool bufferPool = new OByteBufferPool(30);
ByteBuffer buffer = bufferPool.acquireDirect(true);
tree.applyChanges(buffer);
Assert.assertEquals(getByteArray(buffer, 0, 30), data);
}
use of com.orientechnologies.common.directmemory.OByteBufferPool in project orientdb by orientechnologies.
the class ReadWriteCacheConcurrentTest method initBuffer.
private void initBuffer() throws IOException {
writeBuffer = new OWOWCache(false, 8 + systemOffset, new OByteBufferPool(8 + systemOffset), 10000, null, -1, 15000 * (8 + systemOffset), 4 * (8 + systemOffset) + 15000 * (8 + systemOffset), storageLocal, true, files, 1);
writeBuffer.loadRegisteredFiles();
readBuffer = new O2QCache(4 * (8 + systemOffset), 8 + systemOffset, true, 20);
}
Aggregations