Search in sources :

Example 1 with WarmUpConfiguration

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());
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) WarmUpConfiguration(org.apache.ignite.configuration.WarmUpConfiguration)

Example 2 with WarmUpConfiguration

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);
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) WarmUpConfiguration(org.apache.ignite.configuration.WarmUpConfiguration) WarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.WarmUpStrategy) HashSet(java.util.HashSet)

Example 3 with WarmUpConfiguration

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");
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) WarmUpConfiguration(org.apache.ignite.configuration.WarmUpConfiguration) NoOpWarmUpConfiguration(org.apache.ignite.configuration.NoOpWarmUpConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 4 with WarmUpConfiguration

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);
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) WarmUpConfiguration(org.apache.ignite.configuration.WarmUpConfiguration) NoOpWarmUpConfiguration(org.apache.ignite.configuration.NoOpWarmUpConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 with WarmUpConfiguration

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;
}
Also used : WarmUpConfiguration(org.apache.ignite.configuration.WarmUpConfiguration) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) WarmUpStrategySupplier(org.apache.ignite.internal.processors.cache.warmup.WarmUpStrategySupplier) LoadAllWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.LoadAllWarmUpStrategy) NoOpWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.NoOpWarmUpStrategy) NoOpWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.NoOpWarmUpStrategy) LoadAllWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.LoadAllWarmUpStrategy) WarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.WarmUpStrategy)

Aggregations

WarmUpConfiguration (org.apache.ignite.configuration.WarmUpConfiguration)6 NoOpWarmUpConfiguration (org.apache.ignite.configuration.NoOpWarmUpConfiguration)3 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)3 Test (org.junit.Test)3 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 WarmUpStrategy (org.apache.ignite.internal.processors.cache.warmup.WarmUpStrategy)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 GridCacheProcessor (org.apache.ignite.internal.processors.cache.GridCacheProcessor)1 LoadAllWarmUpStrategy (org.apache.ignite.internal.processors.cache.warmup.LoadAllWarmUpStrategy)1 NoOpWarmUpStrategy (org.apache.ignite.internal.processors.cache.warmup.NoOpWarmUpStrategy)1 WarmUpStrategySupplier (org.apache.ignite.internal.processors.cache.warmup.WarmUpStrategySupplier)1