use of org.apache.ignite.configuration.WarmUpConfiguration in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method checkRegionWarmUpConfiguration.
/**
* Checking data region warm-up configuration.
*
* @param regCfg DataRegionConfiguration to validate.
* @param warmUpStrategies Available warming-up strategies.
* @throws IgniteCheckedException If config is invalid.
*/
private void checkRegionWarmUpConfiguration(DataRegionConfiguration regCfg, Map<Class<? extends WarmUpConfiguration>, WarmUpStrategy> warmUpStrategies) throws IgniteCheckedException {
WarmUpConfiguration warmUpCfg = regCfg.getWarmUpConfiguration();
if (isNull(warmUpCfg))
return;
Supplier<String> errPostfix = () -> "[name=" + regCfg.getName() + ", warmUpConfig=" + warmUpCfg + ']';
if (!regCfg.isPersistenceEnabled()) {
throw new IgniteCheckedException("Warm-up setting is not expected for a non-persistent data region: " + errPostfix.get());
}
checkExistenceWarmUpConfiguration(regCfg.getWarmUpConfiguration(), warmUpStrategies, (warmUpConfig) -> "Unknown data region warm-up configuration: " + errPostfix.get());
}
use of org.apache.ignite.configuration.WarmUpConfiguration in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method validateConfiguration.
/**
* @param memCfg configuration to validate.
* @throws IgniteCheckedException In case of validation violation.
*/
private void validateConfiguration(DataStorageConfiguration memCfg) throws IgniteCheckedException {
checkPageSize(memCfg);
DataRegionConfiguration[] regCfgs = memCfg.getDataRegionConfigurations();
Set<String> regNames = new HashSet<>();
checkSystemDataRegionSizeConfiguration(memCfg.getSystemDataRegionConfiguration().getInitialSize(), memCfg.getSystemDataRegionConfiguration().getMaxSize());
Map<Class<? extends WarmUpConfiguration>, WarmUpStrategy> warmUpStrategies = CU.warmUpStrategies(cctx.kernalContext());
if (regCfgs != null) {
for (DataRegionConfiguration regCfg : regCfgs) checkDataRegionConfiguration(memCfg, regNames, regCfg, warmUpStrategies);
}
checkDataRegionConfiguration(memCfg, regNames, memCfg.getDefaultDataRegionConfiguration(), warmUpStrategies);
checkWalArchiveSizeConfiguration(memCfg, log);
checkExistenceWarmUpConfiguration(memCfg.getDefaultWarmUpConfiguration(), warmUpStrategies, (warmUpCfg) -> "Unknown default warm-up configuration: " + warmUpCfg);
}
use of org.apache.ignite.configuration.WarmUpConfiguration in project ignite by apache.
the class WarmUpSelfTest method testUnknownDefaultWarmUpConfiguration.
/**
* Test checks that an unknown default warm-up configuration cannot be passed.
* <p>
* Steps:
* 1)Adding an unknown warm-up configuration to {@link DataStorageConfiguration};
* 2)Starting node and getting an error.
*
* @throws Exception If failed.
*/
@Test
public void testUnknownDefaultWarmUpConfiguration() throws Exception {
IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(0)).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultWarmUpConfiguration(new WarmUpConfiguration() {
}));
assertThrowsAnyCause(log, () -> startGrid(cfg), IgniteCheckedException.class, "Unknown default warm-up configuration");
}
use of org.apache.ignite.configuration.WarmUpConfiguration in project ignite by apache.
the class WarmUpSelfTest method testUnknownDataRegionWarmUpConfiguration.
/**
* Test checks that an unknown data region warm-up configuration cannot be passed.
* <p>
* Steps:
* 1)Adding an unknown warm-up configuration to {@link DataRegionConfiguration};
* 2)Starting node and getting an error.
*
* @throws Exception If failed.
*/
@Test
public void testUnknownDataRegionWarmUpConfiguration() throws Exception {
String regName = "error";
IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(0)).setDataStorageConfiguration(new DataStorageConfiguration().setDataRegionConfigurations(new DataRegionConfiguration().setName(regName).setPersistenceEnabled(true).setWarmUpConfiguration(new WarmUpConfiguration() {
})));
assertThrowsAnyCause(log, () -> startGrid(cfg), IgniteCheckedException.class, "Unknown data region warm-up configuration: [name=" + regName);
}
use of org.apache.ignite.configuration.WarmUpConfiguration in project ignite by apache.
the class GridCacheUtils method warmUpStrategies.
/**
* Getting available warming strategies.
*
* @param kernalCtx Kernal context.
* @return Mapping configuration to strategy.
*/
public static Map<Class<? extends WarmUpConfiguration>, WarmUpStrategy> warmUpStrategies(GridKernalContext kernalCtx) {
Map<Class<? extends WarmUpConfiguration>, WarmUpStrategy> strategies = new HashMap<>();
// Adding default strategies.
WarmUpStrategy[] defStrats = { new NoOpWarmUpStrategy(), new LoadAllWarmUpStrategy(kernalCtx.log(LoadAllWarmUpStrategy.class), () -> kernalCtx.cache().cacheGroups()) };
for (WarmUpStrategy<?> strategy : defStrats) strategies.putIfAbsent(strategy.configClass(), strategy);
// Adding strategies from plugins.
WarmUpStrategySupplier[] suppliers = kernalCtx.plugins().extensions(WarmUpStrategySupplier.class);
if (nonNull(suppliers)) {
for (WarmUpStrategySupplier supplier : suppliers) {
for (WarmUpStrategy<?> strategy : supplier.strategies()) strategies.putIfAbsent(strategy.configClass(), strategy);
}
}
return strategies;
}
Aggregations