use of org.apache.ignite.configuration.MemoryPolicyConfiguration 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);
}
use of org.apache.ignite.configuration.MemoryPolicyConfiguration in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method registerMetricsMBeans.
/**
* Registers MBeans for all MemoryMetrics configured in this instance.
*/
private void registerMetricsMBeans() {
IgniteConfiguration cfg = cctx.gridConfig();
for (MemoryMetrics memMetrics : memMetricsMap.values()) {
MemoryPolicyConfiguration memPlcCfg = memPlcMap.get(memMetrics.getName()).config();
registerMetricsMBean((MemoryMetricsImpl) memMetrics, memPlcCfg, cfg);
}
}
use of org.apache.ignite.configuration.MemoryPolicyConfiguration in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method initPageMemoryPolicies.
/**
* @param memCfg Database config.
*/
protected void initPageMemoryPolicies(MemoryConfiguration memCfg) {
MemoryPolicyConfiguration[] memPlcsCfgs = memCfg.getMemoryPolicies();
if (memPlcsCfgs == null) {
//reserve place for default and system memory policies
memPlcMap = U.newHashMap(2);
memMetricsMap = U.newHashMap(2);
addMemoryPolicy(memCfg, memCfg.createDefaultPolicyConfig(), DFLT_MEM_PLC_DEFAULT_NAME);
U.warn(log, "No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
} else {
String dfltMemPlcName = memCfg.getDefaultMemoryPolicyName();
if (DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltMemPlcName) && !hasCustomDefaultMemoryPolicy(memPlcsCfgs)) {
//reserve additional place for default and system memory policies
memPlcMap = U.newHashMap(memPlcsCfgs.length + 2);
memMetricsMap = U.newHashMap(memPlcsCfgs.length + 2);
addMemoryPolicy(memCfg, memCfg.createDefaultPolicyConfig(), DFLT_MEM_PLC_DEFAULT_NAME);
U.warn(log, "No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
} else {
//reserve additional space for system memory policy only
memPlcMap = U.newHashMap(memPlcsCfgs.length + 1);
memMetricsMap = U.newHashMap(memPlcsCfgs.length + 1);
}
for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs) addMemoryPolicy(memCfg, memPlcCfg, memPlcCfg.getName());
}
addMemoryPolicy(memCfg, createSystemMemoryPolicy(memCfg.getSystemCacheInitialSize(), memCfg.getSystemCacheMaxSize()), SYSTEM_MEMORY_POLICY_NAME);
}
use of org.apache.ignite.configuration.MemoryPolicyConfiguration in project ignite by apache.
the class IgnitionEx method convertLegacyDataStorageConfigurationToNew.
/**
* @param cfg Ignite Configuration with legacy data storage configuration.
*/
private static void convertLegacyDataStorageConfigurationToNew(IgniteConfiguration cfg) throws IgniteCheckedException {
PersistentStoreConfiguration psCfg = cfg.getPersistentStoreConfiguration();
boolean persistenceEnabled = psCfg != null;
DataStorageConfiguration dsCfg = new DataStorageConfiguration();
MemoryConfiguration memCfg = cfg.getMemoryConfiguration() != null ? cfg.getMemoryConfiguration() : new MemoryConfiguration();
dsCfg.setConcurrencyLevel(memCfg.getConcurrencyLevel());
dsCfg.setPageSize(memCfg.getPageSize());
dsCfg.setSystemDataRegionConfiguration(new SystemDataRegionConfiguration().setInitialSize(memCfg.getSystemCacheInitialSize()).setMaxSize(memCfg.getSystemCacheMaxSize()));
List<DataRegionConfiguration> optionalDataRegions = new ArrayList<>();
boolean customDfltPlc = false;
if (memCfg.getMemoryPolicies() != null) {
for (MemoryPolicyConfiguration mpc : memCfg.getMemoryPolicies()) {
DataRegionConfiguration region = new DataRegionConfiguration();
region.setPersistenceEnabled(persistenceEnabled);
if (mpc.getInitialSize() != 0L)
region.setInitialSize(mpc.getInitialSize());
region.setEmptyPagesPoolSize(mpc.getEmptyPagesPoolSize());
region.setEvictionThreshold(mpc.getEvictionThreshold());
region.setMaxSize(mpc.getMaxSize());
region.setName(mpc.getName());
region.setPageEvictionMode(mpc.getPageEvictionMode());
region.setMetricsRateTimeInterval(mpc.getRateTimeInterval());
region.setMetricsSubIntervalCount(mpc.getSubIntervals());
region.setSwapPath(mpc.getSwapFilePath());
region.setMetricsEnabled(mpc.isMetricsEnabled());
if (persistenceEnabled)
region.setCheckpointPageBufferSize(psCfg.getCheckpointingPageBufferSize());
if (mpc.getName() == null) {
throw new IgniteCheckedException(new IllegalArgumentException("User-defined MemoryPolicyConfiguration must have non-null and non-empty name."));
}
if (mpc.getName().equals(memCfg.getDefaultMemoryPolicyName())) {
customDfltPlc = true;
dsCfg.setDefaultDataRegionConfiguration(region);
} else
optionalDataRegions.add(region);
}
}
if (!optionalDataRegions.isEmpty())
dsCfg.setDataRegionConfigurations(optionalDataRegions.toArray(new DataRegionConfiguration[optionalDataRegions.size()]));
if (!customDfltPlc) {
if (!DFLT_MEM_PLC_DEFAULT_NAME.equals(memCfg.getDefaultMemoryPolicyName())) {
throw new IgniteCheckedException(new IllegalArgumentException("User-defined default MemoryPolicy " + "name must be presented among configured MemoryPolices: " + memCfg.getDefaultMemoryPolicyName()));
}
dsCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(memCfg.getDefaultMemoryPolicySize()).setName(memCfg.getDefaultMemoryPolicyName()).setPersistenceEnabled(persistenceEnabled));
} else {
if (memCfg.getDefaultMemoryPolicySize() != DFLT_MEMORY_POLICY_MAX_SIZE)
throw new IgniteCheckedException(new IllegalArgumentException("User-defined MemoryPolicy " + "configuration and defaultMemoryPolicySize properties are set at the same time."));
}
if (persistenceEnabled) {
dsCfg.setCheckpointFrequency(psCfg.getCheckpointingFrequency());
dsCfg.setCheckpointThreads(psCfg.getCheckpointingThreads());
dsCfg.setCheckpointWriteOrder(psCfg.getCheckpointWriteOrder());
dsCfg.setFileIOFactory(psCfg.getFileIOFactory());
dsCfg.setLockWaitTime(psCfg.getLockWaitTime());
dsCfg.setStoragePath(psCfg.getPersistentStorePath());
dsCfg.setMetricsRateTimeInterval(psCfg.getRateTimeInterval());
dsCfg.setMetricsSubIntervalCount(psCfg.getSubIntervals());
dsCfg.setWalThreadLocalBufferSize(psCfg.getTlbSize());
dsCfg.setWalArchivePath(psCfg.getWalArchivePath());
dsCfg.setWalAutoArchiveAfterInactivity(psCfg.getWalAutoArchiveAfterInactivity());
dsCfg.setWalFlushFrequency(psCfg.getWalFlushFrequency());
dsCfg.setWalFsyncDelayNanos(psCfg.getWalFsyncDelayNanos());
dsCfg.setWalHistorySize(psCfg.getWalHistorySize());
dsCfg.setWalMode(psCfg.getWalMode());
dsCfg.setWalRecordIteratorBufferSize(psCfg.getWalRecordIteratorBufferSize());
dsCfg.setWalSegments(psCfg.getWalSegments());
dsCfg.setWalSegmentSize(psCfg.getWalSegmentSize());
dsCfg.setWalPath(psCfg.getWalStorePath());
dsCfg.setAlwaysWriteFullPages(psCfg.isAlwaysWriteFullPages());
dsCfg.setMetricsEnabled(psCfg.isMetricsEnabled());
dsCfg.setWriteThrottlingEnabled(psCfg.isWriteThrottlingEnabled());
}
cfg.setDataStorageConfiguration(dsCfg);
}
use of org.apache.ignite.configuration.MemoryPolicyConfiguration in project ignite by apache.
the class MemoryPolicyInitializationTest method prepareCustomConfigWithOverriddenDefaultName.
/**
*/
private void prepareCustomConfigWithOverriddenDefaultName() {
memCfg = new MemoryConfiguration();
memCfg.setDefaultMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME).setInitialSize(USER_CUSTOM_MEM_PLC_SIZE).setMaxSize(USER_CUSTOM_MEM_PLC_SIZE), new MemoryPolicyConfiguration().setName(DFLT_MEM_PLC_DEFAULT_NAME).setInitialSize(USER_CUSTOM_MEM_PLC_SIZE).setMaxSize(USER_DEFAULT_MEM_PLC_SIZE));
}
Aggregations