Search in sources :

Example 1 with PersistentStoreConfiguration

use of org.apache.ignite.configuration.PersistentStoreConfiguration in project ignite by apache.

the class FoldersReuseCompatibilityTest method configPersistence.

/**
 * Setup persistence for compatible and current version node.
 *
 * @param cfg ignite config to setup.
 */
private static void configPersistence(IgniteConfiguration cfg) {
    final PersistentStoreConfiguration psCfg = new PersistentStoreConfiguration();
    cfg.setPersistentStoreConfiguration(psCfg);
    final MemoryConfiguration memCfg = new MemoryConfiguration();
    final MemoryPolicyConfiguration memPolCfg = new MemoryPolicyConfiguration();
    // we don't need much memory for this test
    memPolCfg.setMaxSize(32L * 1024 * 1024);
    memCfg.setMemoryPolicies(memPolCfg);
    cfg.setMemoryConfiguration(memCfg);
}
Also used : PersistentStoreConfiguration(org.apache.ignite.configuration.PersistentStoreConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 2 with PersistentStoreConfiguration

use of org.apache.ignite.configuration.PersistentStoreConfiguration 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);
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) SystemDataRegionConfiguration(org.apache.ignite.configuration.SystemDataRegionConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PersistentStoreConfiguration(org.apache.ignite.configuration.PersistentStoreConfiguration) SystemDataRegionConfiguration(org.apache.ignite.configuration.SystemDataRegionConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ArrayList(java.util.ArrayList) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 3 with PersistentStoreConfiguration

use of org.apache.ignite.configuration.PersistentStoreConfiguration in project ignite by apache.

the class IgniteMarshallerCacheFSRestoreTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi discoSpi = new TestTcpDiscoverySpi();
    discoSpi.setIpFinder(LOCAL_IP_FINDER);
    cfg.setDiscoverySpi(discoSpi);
    CacheConfiguration singleCacheCfg = new CacheConfiguration().setName(DEFAULT_CACHE_NAME).setCacheMode(CacheMode.PARTITIONED).setBackups(1).setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cfg.setCacheConfiguration(singleCacheCfg);
    // persistence must be enabled to verify restoring mappings from FS case
    if (isPersistenceEnabled)
        cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration());
    return cfg;
}
Also used : PersistentStoreConfiguration(org.apache.ignite.configuration.PersistentStoreConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

PersistentStoreConfiguration (org.apache.ignite.configuration.PersistentStoreConfiguration)3 MemoryConfiguration (org.apache.ignite.configuration.MemoryConfiguration)2 MemoryPolicyConfiguration (org.apache.ignite.configuration.MemoryPolicyConfiguration)2 ArrayList (java.util.ArrayList)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 SystemDataRegionConfiguration (org.apache.ignite.configuration.SystemDataRegionConfiguration)1 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)1