Search in sources :

Example 31 with OByteBufferPool

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();
    }
}
Also used : OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OWALChangesTree(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree) OLogSequenceNumber(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber) OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) ByteBuffer(java.nio.ByteBuffer) OCachePointer(com.orientechnologies.orient.core.storage.cache.OCachePointer)

Example 32 with OByteBufferPool

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();
    }
}
Also used : OCacheEntry(com.orientechnologies.orient.core.storage.cache.OCacheEntry) OWALChangesTree(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree) OLogSequenceNumber(com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber) OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) ByteBuffer(java.nio.ByteBuffer) OCachePointer(com.orientechnologies.orient.core.storage.cache.OCachePointer)

Example 33 with OByteBufferPool

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 });
}
Also used : OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) ByteBuffer(java.nio.ByteBuffer)

Example 34 with OByteBufferPool

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);
}
Also used : Random(java.util.Random) OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) ByteBuffer(java.nio.ByteBuffer)

Example 35 with OByteBufferPool

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);
}
Also used : OWOWCache(com.orientechnologies.orient.core.storage.cache.local.OWOWCache) OByteBufferPool(com.orientechnologies.common.directmemory.OByteBufferPool) O2QCache(com.orientechnologies.orient.core.storage.cache.local.twoq.O2QCache)

Aggregations

OByteBufferPool (com.orientechnologies.common.directmemory.OByteBufferPool)78 ByteBuffer (java.nio.ByteBuffer)73 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)69 OLogSequenceNumber (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber)69 OCachePointer (com.orientechnologies.orient.core.storage.cache.OCachePointer)61 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)20 OWALChangesTree (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree)19 Test (org.testng.annotations.Test)15 Random (java.util.Random)10 ORecordId (com.orientechnologies.orient.core.id.ORecordId)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 TreeSet (java.util.TreeSet)8 OWOWCache (com.orientechnologies.orient.core.storage.cache.local.OWOWCache)4 OStorageSegmentConfiguration (com.orientechnologies.orient.core.config.OStorageSegmentConfiguration)1 O2QCache (com.orientechnologies.orient.core.storage.cache.local.twoq.O2QCache)1 ODiskWriteAheadLog (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.ODiskWriteAheadLog)1 WriteAheadLogTest (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.WriteAheadLogTest)1 File (java.io.File)1