Search in sources :

Example 1 with IndexStorage

use of org.apache.ignite.internal.processors.cache.persistence.IndexStorage 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

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 PendingEntriesTree (org.apache.ignite.internal.processors.cache.tree.PendingEntriesTree)1