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