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);
}
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;
}
Aggregations