Search in sources :

Example 51 with OCachePointer

use of com.orientechnologies.orient.core.storage.cache.OCachePointer 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();
    }
}
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 52 with OCachePointer

use of com.orientechnologies.orient.core.storage.cache.OCachePointer in project orientdb by orientechnologies.

the class ClusterPageTest method testDeleteAddEqualVersionKeepTombstoneVersion.

public void testDeleteAddEqualVersionKeepTombstoneVersion() 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);
        deleteAddEqualVersionKeepTombstoneVersion(localPage);
        deleteAddEqualVersionKeepTombstoneVersion(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 53 with OCachePointer

use of com.orientechnologies.orient.core.storage.cache.OCachePointer in project orientdb by orientechnologies.

the class ClusterPageTest method testAddBigRecordDeleteAndAddSmallRecords.

public void testAddBigRecordDeleteAndAddSmallRecords() 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 {
        final long seed = System.currentTimeMillis();
        OClusterPage localPage = new OClusterPage(cacheEntry, true, new OWALChangesTree());
        OClusterPage directLocalPage = new OClusterPage(directCacheEntry, true, null);
        addBigRecordDeleteAndAddSmallRecords(seed, localPage);
        addBigRecordDeleteAndAddSmallRecords(seed, 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 54 with OCachePointer

use of com.orientechnologies.orient.core.storage.cache.OCachePointer in project orientdb by orientechnologies.

the class ClusterPageTest method testReplaceOneRecordWithBiggerSize.

public void testReplaceOneRecordWithBiggerSize() 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);
        replaceOneRecordWithBiggerSize(localPage);
        replaceOneRecordWithBiggerSize(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 55 with OCachePointer

use of com.orientechnologies.orient.core.storage.cache.OCachePointer in project orientdb by orientechnologies.

the class ClusterPageTest method testDeleteTwoOutOfFour.

public void testDeleteTwoOutOfFour() 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);
        deleteTwoOutOfFour(localPage);
        deleteTwoOutOfFour(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)

Aggregations

OCachePointer (com.orientechnologies.orient.core.storage.cache.OCachePointer)77 ByteBuffer (java.nio.ByteBuffer)73 OLogSequenceNumber (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber)68 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)65 OByteBufferPool (com.orientechnologies.common.directmemory.OByteBufferPool)61 Test (org.testng.annotations.Test)22 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)20 OWALChangesTree (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OWALChangesTree)19 OModifiableBoolean (com.orientechnologies.common.types.OModifiableBoolean)9 OFileClassic (com.orientechnologies.orient.core.storage.fs.OFileClassic)9 Random (java.util.Random)9 ORecordId (com.orientechnologies.orient.core.id.ORecordId)8 WriteAheadLogTest (com.orientechnologies.orient.core.storage.impl.local.paginated.wal.WriteAheadLogTest)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 TreeSet (java.util.TreeSet)8 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 OSessionStoragePerformanceStatistic (com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)2 Assert (org.testng.Assert)2