Search in sources :

Example 11 with DataPageIO

use of org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO in project ignite by apache.

the class MvccUtils method invoke.

/**
 * Encapsulates common logic for working with row mvcc info: page locking/unlocking, checks and other.
 * Strategy pattern.
 *
 * @param cctx Cache group.
 * @param link Row link.
 * @param clo Closure to apply.
 * @param snapshot Mvcc snapshot.
 * @param <R> Return type.
 * @return Result.
 * @throws IgniteCheckedException If failed.
 */
private static <R> R invoke(GridCacheContext cctx, long link, MvccClosure<R> clo, MvccSnapshot snapshot) throws IgniteCheckedException {
    assert cctx.mvccEnabled();
    PageMemory pageMem = cctx.dataRegion().pageMemory();
    int grpId = cctx.groupId();
    int pageSize = pageMem.realPageSize(grpId);
    long pageId = pageId(link);
    int itemId = itemId(link);
    long page = pageMem.acquirePage(grpId, pageId);
    try {
        long pageAddr = pageMem.readLock(grpId, pageId, page);
        try {
            DataPageIO dataIo = DataPageIO.VERSIONS.forPage(pageAddr);
            return invoke(cctx, dataIo, pageAddr, itemId, pageSize, clo, snapshot);
        } finally {
            pageMem.readUnlock(grpId, pageId, page);
        }
    } finally {
        pageMem.releasePage(grpId, pageId, page);
    }
}
Also used : DataPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO) PageMemory(org.apache.ignite.internal.pagemem.PageMemory)

Aggregations

DataPageIO (org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO)11 DataPagePayload (org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPagePayload)3 ByteBuffer (java.nio.ByteBuffer)2 CacheDataRowAdapter (org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)2 File (java.io.File)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 OpenOption (java.nio.file.OpenOption)1 StandardOpenOption (java.nio.file.StandardOpenOption)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Pattern (java.util.regex.Pattern)1 FileUtils (org.apache.commons.io.FileUtils)1 IgniteCache (org.apache.ignite.IgniteCache)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)1 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)1 ClusterState (org.apache.ignite.cluster.ClusterState)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1