Search in sources :

Example 6 with CacheFreeListImpl

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

the class CacheFreeListImplSelfTest method createFreeList.

/**
 * @param pageSize Page size.
 * @return Free list.
 * @throws Exception If failed.
 */
protected FreeList createFreeList(int pageSize) throws Exception {
    DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB).setMaxSize(1024 * MB);
    pageMem = createPageMemory(pageSize, plcCfg);
    long metaPageId = pageMem.allocatePage(1, 1, PageIdAllocator.FLAG_DATA);
    DataRegionMetricsImpl regionMetrics = new DataRegionMetricsImpl(plcCfg);
    DataRegion dataRegion = new DataRegion(pageMem, plcCfg, regionMetrics, new NoOpPageEvictionTracker());
    return new CacheFreeListImpl(1, "freelist", regionMetrics, dataRegion, null, null, metaPageId, true);
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) NoOpPageEvictionTracker(org.apache.ignite.internal.processors.cache.persistence.evict.NoOpPageEvictionTracker) CacheFreeListImpl(org.apache.ignite.internal.processors.cache.persistence.freelist.CacheFreeListImpl) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) DataRegion(org.apache.ignite.internal.processors.cache.persistence.DataRegion)

Example 7 with CacheFreeListImpl

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

the class WalRecoveryTxLogicalRecordsTest method getFreeListData.

/**
 * @param ignite Node.
 * @param cacheName Cache name.
 * @return Cache free lists data.
 */
private Map<Integer, T2<Map<Integer, long[]>, int[]>> getFreeListData(Ignite ignite, String cacheName) {
    GridCacheContext ctx = ((IgniteEx) ignite).context().cache().cache(cacheName).context();
    List<GridDhtLocalPartition> parts = ctx.topology().localPartitions();
    assertTrue(!parts.isEmpty());
    assertEquals(ctx.affinity().partitions(), parts.size());
    Map<Integer, T2<Map<Integer, long[]>, int[]>> res = new HashMap<>();
    boolean foundNonEmpty = false;
    boolean foundTails = false;
    for (GridDhtLocalPartition part : parts) {
        CacheFreeListImpl freeList = GridTestUtils.getFieldValue(part.dataStore(), "freeList");
        if (freeList == null)
            // Lazy store.
            continue;
        AtomicReferenceArray<PagesList.Stripe[]> buckets = GridTestUtils.getFieldValue(freeList, AbstractFreeList.class, "buckets");
        // AtomicIntegerArray cnts = GridTestUtils.getFieldValue(freeList, PagesList.class, "cnts");
        assertNotNull(buckets);
        // assertNotNull(cnts);
        assertTrue(buckets.length() > 0);
        // assertEquals(cnts.length(), buckets.length());
        Map<Integer, long[]> tailsPerBucket = new HashMap<>();
        for (int i = 0; i < buckets.length(); i++) {
            PagesList.Stripe[] tails = buckets.get(i);
            long[] ids = null;
            if (tails != null) {
                ids = new long[tails.length];
                for (int j = 0; j < tails.length; j++) ids[j] = tails[j].tailId;
            }
            tailsPerBucket.put(i, ids);
            if (tails != null) {
                assertTrue(tails.length > 0);
                foundTails = true;
            }
        }
        // int[] cntsPerBucket = new int[cnts.length()];
        // 
        // for (int i = 0; i < cnts.length(); i++) {
        // cntsPerBucket[i] = cnts.get(i);
        // 
        // if (cntsPerBucket[i] > 0)
        // foundNonEmpty = true;
        // }
        res.put(part.id(), new T2<>(tailsPerBucket, (int[]) null));
    }
    // assertTrue(foundNonEmpty);
    assertTrue(foundTails);
    return res;
}
Also used : CacheFreeListImpl(org.apache.ignite.internal.processors.cache.persistence.freelist.CacheFreeListImpl) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) HashMap(java.util.HashMap) PagesList(org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition) T2(org.apache.ignite.internal.util.typedef.T2)

Aggregations

CacheFreeListImpl (org.apache.ignite.internal.processors.cache.persistence.freelist.CacheFreeListImpl)7 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)3 GridDhtLocalPartition (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition)2 HashMap (java.util.HashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)1 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)1 MetaPageUpdatePartitionDataRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdatePartitionDataRecord)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1 GridDhtPartitionState (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState)1 DataRegion (org.apache.ignite.internal.processors.cache.persistence.DataRegion)1 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)1 NoOpPageEvictionTracker (org.apache.ignite.internal.processors.cache.persistence.evict.NoOpPageEvictionTracker)1 PagesList (org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList)1 PageMemoryEx (org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx)1 PagePartitionMetaIO (org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO)1 CacheDataRowStore (org.apache.ignite.internal.processors.cache.tree.CacheDataRowStore)1 T2 (org.apache.ignite.internal.util.typedef.T2)1 IgniteOutClosure (org.apache.ignite.lang.IgniteOutClosure)1