Search in sources :

Example 6 with MemoryPolicyConfiguration

use of org.apache.ignite.configuration.MemoryPolicyConfiguration 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 7 with MemoryPolicyConfiguration

use of org.apache.ignite.configuration.MemoryPolicyConfiguration in project ignite by apache.

the class FoldersReuseCompatibilityTest method configPersistence.

/**
 * Setup persistence for compatible and current version node.
 *
 * @param cfg ignite config to setup.
 */
private static void configPersistence(IgniteConfiguration cfg) {
    final PersistentStoreConfiguration psCfg = new PersistentStoreConfiguration();
    cfg.setPersistentStoreConfiguration(psCfg);
    final MemoryConfiguration memCfg = new MemoryConfiguration();
    final MemoryPolicyConfiguration memPolCfg = new MemoryPolicyConfiguration();
    // we don't need much memory for this test
    memPolCfg.setMaxSize(32L * 1024 * 1024);
    memCfg.setMemoryPolicies(memPolCfg);
    cfg.setMemoryConfiguration(memCfg);
}
Also used : PersistentStoreConfiguration(org.apache.ignite.configuration.PersistentStoreConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 8 with MemoryPolicyConfiguration

use of org.apache.ignite.configuration.MemoryPolicyConfiguration in project ignite by apache.

the class MemoryPolicyConfigValidationTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    MemoryConfiguration memCfg = new MemoryConfiguration();
    MemoryPolicyConfiguration[] plcs = null;
    switch(violationType) {
        case NAMES_CONFLICT:
            plcs = createPlcsWithNamesConflictCfg();
            break;
        case SYSTEM_MEMORY_POLICY_NAME_MISUSE:
            plcs = createPlcWithReservedNameMisuseCfg();
            break;
        case TOO_SMALL_MEMORY_SIZE:
            plcs = createTooSmallMemoryCfg();
            break;
        case NULL_NAME_ON_USER_DEFINED_POLICY:
            plcs = createPlcWithNullName();
            break;
        case MISSING_USER_DEFINED_DEFAULT:
            plcs = createMissingUserDefinedDefault();
            memCfg.setDefaultMemoryPolicyName(MISSING_DEFAULT_MEM_PLC_NAME);
            break;
        case TOO_SMALL_USER_DEFINED_DFLT_MEM_PLC_SIZE:
            memCfg.setDefaultMemoryPolicySize(1);
            break;
        case DEFAULT_SIZE_IS_DEFINED_TWICE:
            plcs = createValidUserDefault();
            memCfg.setDefaultMemoryPolicyName(VALID_DEFAULT_MEM_PLC_NAME);
            memCfg.setDefaultMemoryPolicySize(10L * 1014 * 1024);
            break;
        case MAX_SIZE_IS_SMALLER_THAN_INITIAL_SIZE:
            plcs = createMaxSizeSmallerThanInitialSize();
            break;
        case LTE_ZERO_RATE_TIME_INTERVAL:
            plcs = createRateTimeIntervalIsNegative();
            break;
        case LTE_ZERO_SUB_INTERVALS:
            plcs = createSubIntervalsIsNegative();
            break;
        default:
            fail("Violation type was not configured: " + violationType);
    }
    memCfg.setMemoryPolicies(plcs);
    cfg.setMemoryConfiguration(memCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 9 with MemoryPolicyConfiguration

use of org.apache.ignite.configuration.MemoryPolicyConfiguration in project ignite by apache.

the class MemoryPolicyInitializationTest method prepareCustomNoDefaultConfig.

/**
 */
private void prepareCustomNoDefaultConfig() {
    memCfg = new MemoryConfiguration();
    memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME).setInitialSize(USER_CUSTOM_MEM_PLC_SIZE).setMaxSize(USER_CUSTOM_MEM_PLC_SIZE));
}
Also used : MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 10 with MemoryPolicyConfiguration

use of org.apache.ignite.configuration.MemoryPolicyConfiguration in project ignite by apache.

the class MemoryMetricsSelfTest method beforeTest.

/** {@inheritDoc} */
@Override
protected void beforeTest() throws Exception {
    MemoryPolicyConfiguration plcCfg = new MemoryPolicyConfiguration();
    memMetrics = new MemoryMetricsImpl(plcCfg);
    memMetrics.enableMetrics();
}
Also used : MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) MemoryMetricsImpl(org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)

Aggregations

MemoryPolicyConfiguration (org.apache.ignite.configuration.MemoryPolicyConfiguration)25 MemoryConfiguration (org.apache.ignite.configuration.MemoryConfiguration)14 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 MemoryMetricsImpl (org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)3 FreeListImpl (org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl)3 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 PersistentStoreConfiguration (org.apache.ignite.configuration.PersistentStoreConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgniteOutOfMemoryException (org.apache.ignite.internal.mem.IgniteOutOfMemoryException)2 ArrayList (java.util.ArrayList)1 MemoryMetrics (org.apache.ignite.MemoryMetrics)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 SystemDataRegionConfiguration (org.apache.ignite.configuration.SystemDataRegionConfiguration)1 DirectMemoryProvider (org.apache.ignite.internal.mem.DirectMemoryProvider)1 MappedFileMemoryProvider (org.apache.ignite.internal.mem.file.MappedFileMemoryProvider)1 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)1 PageMemoryNoStoreImpl (org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl)1 MemoryPolicy (org.apache.ignite.internal.processors.cache.database.MemoryPolicy)1