Search in sources :

Example 11 with GridCacheOffheapManager

use of org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager in project ignite by apache.

the class ReleaseSegmentOnHistoricalRebalanceTest method testReleaseDuringRebalanceIterator.

/**
 * Checks that if release the segment during {@link IgniteCacheOffheapManagerImpl#rebalanceIterator},
 * there will be no errors and the rebalance will be completed.
 *
 * @throws Exception If failed.
 */
@Test
public void testReleaseDuringRebalanceIterator() throws Exception {
    checkHistoricalRebalance(n -> {
        IgniteInternalCache<?, ?> cachex = n.cachex(DEFAULT_CACHE_NAME);
        GridCacheOffheapManager spy = spy(offheapManager(cachex));
        doAnswer(m -> {
            WALPointer reserved = dbMgr(n).latestWalPointerReservedForPreloading();
            assertNotNull(reserved);
            Object o = m.callRealMethod();
            release(n, reserved);
            assertTrue(segmentAware(n).minReserveIndex(Long.MAX_VALUE));
            return o;
        }).when(spy).rebalanceIterator(any(), any());
        offheapManager(cachex, spy);
    });
}
Also used : GridCacheOffheapManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) Test(org.junit.Test)

Example 12 with GridCacheOffheapManager

use of org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager in project ignite by apache.

the class IgniteSequentialNodeCrashRecoveryTest method captureDirtyPages.

/**
 * @param g Ignite instance.
 * @throws IgniteCheckedException If failed.
 */
private Collection<FullPageId> captureDirtyPages(IgniteEx g) throws IgniteCheckedException {
    GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) g.context().cache().context().database();
    dbMgr.checkpointReadLock();
    try {
        // Moving free list pages to offheap.
        for (CacheGroupContext group : g.context().cache().cacheGroups()) {
            ((GridCacheOffheapManager) group.offheap()).onMarkCheckpointBegin(new DummyCheckpointContext());
        }
    } finally {
        dbMgr.checkpointReadUnlock();
    }
    // Capture a set of dirty pages.
    PageMemoryImpl pageMem = (PageMemoryImpl) dbMgr.dataRegion("default").pageMemory();
    return pageMem.dirtyPages();
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) GridCacheOffheapManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager) PageMemoryImpl(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext)

Example 13 with GridCacheOffheapManager

use of org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager in project ignite by apache.

the class CheckpointFreeListTest method cacheOffheapManager.

/**
 * Extract GridCacheOffheapManager for default cache.
 *
 * @return GridCacheOffheapManager.
 */
private GridCacheOffheapManager cacheOffheapManager() {
    GridCacheAdapter<Object, Object> cacheInternal = ((IgniteKernal) ignite(0)).internalCache(CACHE_NAME);
    GridCacheAdapter cache0 = (GridCacheAdapter) cacheInternal.cache();
    return (GridCacheOffheapManager) cache0.context().group().offheap();
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) GridCacheOffheapManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager)

Aggregations

GridCacheOffheapManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager)13 HashMap (java.util.HashMap)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 CacheGroupContext (org.apache.ignite.internal.processors.cache.CacheGroupContext)5 Test (org.junit.Test)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)4 List (java.util.List)3 Map (java.util.Map)3 IgniteException (org.apache.ignite.IgniteException)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 File (java.io.File)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Comparator.comparing (java.util.Comparator.comparing)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2