Search in sources :

Example 6 with PendingEntriesTree

use of org.apache.ignite.internal.processors.cache.tree.PendingEntriesTree in project ignite by apache.

the class UpgradePendingTreeToPerPartitionTask method processCacheGroup.

/**
 * Converts CacheGroup pending tree to per-partition basis.
 *
 * @param grp Cache group.
 * @throws IgniteCheckedException If error occurs.
 */
private void processCacheGroup(CacheGroupContext grp) throws IgniteCheckedException {
    assert grp.offheap() instanceof GridCacheOffheapManager;
    PendingEntriesTree oldPendingTree;
    final IgniteCacheDatabaseSharedManager db = grp.shared().database();
    db.checkpointReadLock();
    try {
        IndexStorage indexStorage = ((GridCacheOffheapManager) grp.offheap()).getIndexStorage();
        // TODO: IGNITE-5874: replace with some check-method to avoid unnecessary page allocation.
        RootPage pendingRootPage = indexStorage.allocateIndex(PENDING_ENTRIES_TREE_NAME);
        if (pendingRootPage.isAllocated()) {
            log.info("No pending tree found for cache group: [grpId=" + grp.groupId() + ", grpName=" + grp.name() + ']');
            // Nothing to do here as just allocated tree is obviously empty.
            indexStorage.dropIndex(PENDING_ENTRIES_TREE_NAME);
            return;
        }
        oldPendingTree = new PendingEntriesTree(grp, PENDING_ENTRIES_TREE_NAME, grp.dataRegion().pageMemory(), pendingRootPage.pageId().pageId(), ((GridCacheOffheapManager) grp.offheap()).reuseListForIndex(null), false, grp.shared().diagnostic().pageLockTracker(), PageIdAllocator.FLAG_IDX);
    } finally {
        db.checkpointReadUnlock();
    }
    processPendingTree(grp, oldPendingTree);
    if (Thread.currentThread().isInterrupted())
        return;
    db.checkpointReadLock();
    try {
        oldPendingTree.destroy();
    } finally {
        db.checkpointReadUnlock();
    }
}
Also used : GridCacheOffheapManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager) RootPage(org.apache.ignite.internal.processors.cache.persistence.RootPage) IndexStorage(org.apache.ignite.internal.processors.cache.persistence.IndexStorage) PendingEntriesTree(org.apache.ignite.internal.processors.cache.tree.PendingEntriesTree) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Aggregations

PendingEntriesTree (org.apache.ignite.internal.processors.cache.tree.PendingEntriesTree)6 PendingRow (org.apache.ignite.internal.processors.cache.tree.PendingRow)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Duration (javax.cache.expiry.Duration)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 CacheGroupContext (org.apache.ignite.internal.processors.cache.CacheGroupContext)1 IgniteCacheOffheapManager (org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager)1 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)1 GridCacheOffheapManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager)1 IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)1 IndexStorage (org.apache.ignite.internal.processors.cache.persistence.IndexStorage)1 RootPage (org.apache.ignite.internal.processors.cache.persistence.RootPage)1 SimpleDataRow (org.apache.ignite.internal.processors.cache.persistence.freelist.SimpleDataRow)1 AbstractDataLeafIO (org.apache.ignite.internal.processors.cache.tree.AbstractDataLeafIO)1 CacheDataTree (org.apache.ignite.internal.processors.cache.tree.CacheDataTree)1 DataRow (org.apache.ignite.internal.processors.cache.tree.DataRow)1 GridAtomicLong (org.apache.ignite.internal.util.GridAtomicLong)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1