use of org.apache.ignite.configuration.SystemDataRegionConfiguration in project ignite by apache.
the class OutOfMemoryVolatileRegionTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setDataStorageConfiguration(new DataStorageConfiguration().setPageSize(4096).setSystemDataRegionConfiguration(new SystemDataRegionConfiguration().setInitialSize(DATA_REGION_SIZE).setMaxSize(DATA_REGION_SIZE)).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true).setMetricsEnabled(true)));
cfg.setFailureHandler(new AbstractFailureHandler() {
/**
* {@inheritDoc}
*/
@Override
protected boolean handle(Ignite ignite, FailureContext failureCtx) {
failure = true;
// Do not invalidate a node context.
return false;
}
});
cfg.setCacheConfiguration(cacheConfiguration(ATOMIC), cacheConfiguration(TRANSACTIONAL));
return cfg;
}
use of org.apache.ignite.configuration.SystemDataRegionConfiguration 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);
}
Aggregations