use of org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method initPageMemoryDataStructures.
/**
* @param dbCfg Database config.
*/
protected void initPageMemoryDataStructures(MemoryConfiguration dbCfg) throws IgniteCheckedException {
freeListMap = U.newHashMap(memPlcMap.size());
String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
for (MemoryPolicy memPlc : memPlcMap.values()) {
MemoryPolicyConfiguration memPlcCfg = memPlc.config();
MemoryMetricsImpl memMetrics = (MemoryMetricsImpl) memMetricsMap.get(memPlcCfg.getName());
FreeListImpl freeList = new FreeListImpl(0, cctx.igniteInstanceName(), memMetrics, memPlc, null, cctx.wal(), 0L, true);
memMetrics.freeList(freeList);
freeListMap.put(memPlcCfg.getName(), freeList);
}
dfltFreeList = freeListMap.get(dfltMemPlcName);
}
use of org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method ensureFreeSpace.
/**
* See {@link GridCacheMapEntry#ensureFreeSpace()}
*
* @param memPlc Memory policy.
*/
public void ensureFreeSpace(MemoryPolicy memPlc) throws IgniteCheckedException {
if (memPlc == null)
return;
MemoryPolicyConfiguration plcCfg = memPlc.config();
if (plcCfg.getPageEvictionMode() == DataPageEvictionMode.DISABLED)
return;
long memorySize = plcCfg.getMaxSize();
PageMemory pageMem = memPlc.pageMemory();
int sysPageSize = pageMem.systemPageSize();
FreeListImpl freeListImpl = freeListMap.get(plcCfg.getName());
for (; ; ) {
long allocatedPagesCnt = pageMem.loadedPages();
int emptyDataPagesCnt = freeListImpl.emptyDataPages();
boolean shouldEvict = allocatedPagesCnt > (memorySize / sysPageSize * plcCfg.getEvictionThreshold()) && emptyDataPagesCnt < plcCfg.getEmptyPagesPoolSize();
if (shouldEvict)
memPlc.evictionTracker().evictDataPage();
else
break;
}
}
use of org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl in project ignite by apache.
the class FreeListImplSelfTest method createFreeList.
/**
* @param pageSize Page size.
* @return Free list.
* @throws Exception If failed.
*/
protected FreeList createFreeList(int pageSize) throws Exception {
MemoryPolicyConfiguration plcCfg = new MemoryPolicyConfiguration().setMaxSize(1024 * MB);
pageMem = createPageMemory(pageSize, plcCfg);
long metaPageId = pageMem.allocatePage(1, 1, PageIdAllocator.FLAG_DATA);
MemoryMetricsImpl metrics = new MemoryMetricsImpl(plcCfg);
MemoryPolicy memPlc = new MemoryPolicy(pageMem, plcCfg, metrics, new NoOpPageEvictionTracker());
return new FreeListImpl(1, "freelist", metrics, memPlc, null, null, metaPageId, true);
}
Aggregations