Search in sources :

Example 1 with FreeListImpl

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);
}
Also used : FreeListImpl(org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 2 with FreeListImpl

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;
    }
}
Also used : FreeListImpl(org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 3 with FreeListImpl

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);
}
Also used : NoOpPageEvictionTracker(org.apache.ignite.internal.processors.cache.database.evict.NoOpPageEvictionTracker) FreeListImpl(org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl) MemoryPolicy(org.apache.ignite.internal.processors.cache.database.MemoryPolicy) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) MemoryMetricsImpl(org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)

Aggregations

MemoryPolicyConfiguration (org.apache.ignite.configuration.MemoryPolicyConfiguration)3 FreeListImpl (org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl)3 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)1 MemoryMetricsImpl (org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)1 MemoryPolicy (org.apache.ignite.internal.processors.cache.database.MemoryPolicy)1 NoOpPageEvictionTracker (org.apache.ignite.internal.processors.cache.database.evict.NoOpPageEvictionTracker)1