use of org.apache.ignite.internal.processors.cache.warmup.LoadAllWarmUpStrategy.LoadPartition in project ignite by apache.
the class LoadAllWarmUpStrategySelfTest method testMemoryLessPds.
/**
* Test checks that if memory is less than pds, not all pages in pds will warm-up.
* There may be evictions during warm-up, so count of pages loaded is not maximum.
* <p/>
* Steps:
* 1)Start node and fill it with data for first data region until it is 2 * {@code MIN_PAGE_MEMORY_SIZE};
* 2)Make a checkpoint;
* 3)Restart node with warm-up, change maximum data region size to {@code MIN_PAGE_MEMORY_SIZE},
* and listen for {@link LoadAllWarmUpStrategyEx#loadDataInfo};
* 4)Check that estimated count of pages to warm-up is between maximum and
* approximate minimum count of pages to load;
* 5)Checking that total count of pages loaded is between maximum and
* approximate minimum count of pages to load.
*
* Approximate value due to fact that there are already loaded pages at
* beginning of warm-up, as well as evictions occur during warm-up.
*
* @throws Exception If failed.
*/
@Test
public void testMemoryLessPds() throws Exception {
IgniteEx n = startGrid(0);
n.cluster().state(ClusterState.ACTIVE);
int i = 0;
final long minMemSize = U.field(IgniteCacheDatabaseSharedManager.class, "MIN_PAGE_MEMORY_SIZE");
DataRegion dr_0 = n.context().cache().context().database().dataRegion("dr_0");
while (dr_0.pageMemory().loadedPages() * dr_0.pageMemory().systemPageSize() < 2 * minMemSize) {
n.cache("c_0").put("c_0" + i, new Organization(i, "c_0" + i));
n.cache("c_1").put("c_1" + i, new Person(i, "c_1" + i, i));
i++;
}
forceCheckpoint();
stopAllGrids();
warmUp = true;
IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(0));
cfg.getDataStorageConfiguration().getDataRegionConfigurations()[0].setMaxSize(minMemSize);
Map<String, Map<CacheGroupContext, List<LoadPartition>>> loadDataInfoMap = new ConcurrentHashMap<>();
LoadAllWarmUpStrategyEx.loadDataInfoCb = loadDataInfoMap::put;
n = startGrid(cfg);
dr_0 = n.context().cache().context().database().dataRegion("dr_0");
long warmUpPageCnt = loadDataInfoMap.get("dr_0").values().stream().flatMap(Collection::stream).mapToLong(LoadPartition::pages).sum();
long maxLoadPages = minMemSize / dr_0.pageMemory().systemPageSize();
long minLoadPages = maxLoadPages - 100;
long loadPages = dr_0.pageMemory().loadedPages();
// There are loaded pages before warm-up.
assertTrue(warmUpPageCnt >= minLoadPages && warmUpPageCnt <= maxLoadPages);
// Pages may be evicted.
assertTrue(loadPages >= minLoadPages && loadPages <= maxLoadPages);
}
Aggregations