Java Code Examples for org.apache.ignite.configuration.DataStorageConfiguration#getDataRegionConfigurations()

The following examples show how to use org.apache.ignite.configuration.DataStorageConfiguration#getDataRegionConfigurations() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GridDiscoveryManager.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Configured data regions offheap memory in bytes.
 */
private long configuredOffheap() {
    DataStorageConfiguration memCfg = ctx.config().getDataStorageConfiguration();

    if (memCfg == null)
        return 0;

    long res = memCfg.getDefaultDataRegionConfiguration().getMaxSize();

    DataRegionConfiguration[] dataRegions = memCfg.getDataRegionConfigurations();

    if (dataRegions != null) {
        for (DataRegionConfiguration dataReg : dataRegions)
            res += dataReg.getMaxSize();
    }

    return res;
}
 
Example 2
Source File: GridCacheUtils.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return {@code true} if persistence is enabled for at least one data region, {@code false} if not.
 */
public static boolean isPersistenceEnabled(DataStorageConfiguration cfg) {
    if (cfg == null)
        return false;

    DataRegionConfiguration dfltReg = cfg.getDefaultDataRegionConfiguration();

    if (dfltReg == null)
        return false;

    if (dfltReg.isPersistenceEnabled())
        return true;

    DataRegionConfiguration[] regCfgs = cfg.getDataRegionConfigurations();

    if (regCfgs == null)
        return false;

    for (DataRegionConfiguration regCfg : regCfgs) {
        if (regCfg.isPersistenceEnabled())
            return true;
    }

    return false;
}
 
Example 3
Source File: IgniteCacheDatabaseSharedManager.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param memCfg configuration to validate.
 */
private void validateConfiguration(DataStorageConfiguration memCfg) throws IgniteCheckedException {
    checkPageSize(memCfg);

    DataRegionConfiguration[] regCfgs = memCfg.getDataRegionConfigurations();

    Set<String> regNames = (regCfgs != null) ? U.<String>newHashSet(regCfgs.length) : new HashSet<String>(0);

    checkSystemDataRegionSizeConfiguration(
        memCfg.getSystemRegionInitialSize(),
        memCfg.getSystemRegionMaxSize()
    );

    if (regCfgs != null) {
        for (DataRegionConfiguration regCfg : regCfgs)
            checkDataRegionConfiguration(memCfg, regNames, regCfg);
    }

    checkDataRegionConfiguration(memCfg, regNames, memCfg.getDefaultDataRegionConfiguration());

    checkWalArchiveSizeConfiguration(memCfg);
}
 
Example 4
Source File: IgniteAbstractBenchmark.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if persistence is enabled and activates cluster.
 */
private void activateCluster() {
    //Flag to set if there is at least one data region with persistence in Ignite configuration.
    boolean pdsInCfg = false;

    DataStorageConfiguration dsCfg = ignite().configuration().getDataStorageConfiguration();

    if (dsCfg != null) {
        pdsInCfg = dsCfg.getDefaultDataRegionConfiguration().isPersistenceEnabled();

        DataRegionConfiguration[] drCfgArr = dsCfg.getDataRegionConfigurations();

        if (drCfgArr != null) {
            for (DataRegionConfiguration drCfg : drCfgArr) {
                if (drCfg.isPersistenceEnabled()) {
                    pdsInCfg = true;

                    break;
                }
            }
        }
    }

    if ((args.persistentStoreEnabled() || pdsInCfg) && !ignite().cluster().active()) {
        BenchmarkUtils.println("Activating cluster.");

        ignite().cluster().active(true);
    }
}
 
Example 5
Source File: IgniteCacheDatabaseSharedManager.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param memCfg Database config.
 * @throws IgniteCheckedException If failed to initialize swap path.
 */
protected void initDataRegions0(DataStorageConfiguration memCfg) throws IgniteCheckedException {
    DataRegionConfiguration[] dataRegionCfgs = memCfg.getDataRegionConfigurations();

    if (dataRegionCfgs != null) {
        for (DataRegionConfiguration dataRegionCfg : dataRegionCfgs)
            addDataRegion(memCfg, dataRegionCfg, dataRegionCfg.isPersistenceEnabled());
    }

    addDataRegion(
        memCfg,
        memCfg.getDefaultDataRegionConfiguration(),
        memCfg.getDefaultDataRegionConfiguration().isPersistenceEnabled()
    );

    addDataRegion(
        memCfg,
        createSystemDataRegion(
            memCfg.getSystemRegionInitialSize(),
            memCfg.getSystemRegionMaxSize(),
            CU.isPersistenceEnabled(memCfg)
        ),
        CU.isPersistenceEnabled(memCfg)
    );

    for (DatabaseLifecycleListener lsnr : getDatabaseListeners(cctx.kernalContext()))
        lsnr.onInitDataRegions(this);
}
 
Example 6
Source File: CacheAffinitySharedManager.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Finds data region by name.
 *
 * @param dsCfg Data storage configuration.
 * @param drName Data region name.
 *
 * @return Found data region.
 */
@Nullable private DataRegionConfiguration findDataRegion(DataStorageConfiguration dsCfg, String drName) {
    if (dsCfg.getDataRegionConfigurations() == null || drName == null)
        return dsCfg.getDefaultDataRegionConfiguration();

    if (dsCfg.getDefaultDataRegionConfiguration().getName().equals(drName))
        return dsCfg.getDefaultDataRegionConfiguration();

    Optional<DataRegionConfiguration> cfgOpt = Arrays.stream(dsCfg.getDataRegionConfigurations())
        .filter(drCfg -> drCfg.getName().equals(drName))
        .findFirst();

    return cfgOpt.isPresent() ? cfgOpt.get() : null;
}