Search in sources :

Example 1 with SystemDataRegionConfiguration

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;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) SystemDataRegionConfiguration(org.apache.ignite.configuration.SystemDataRegionConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) SystemDataRegionConfiguration(org.apache.ignite.configuration.SystemDataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FailureContext(org.apache.ignite.failure.FailureContext) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) Ignite(org.apache.ignite.Ignite)

Example 2 with SystemDataRegionConfiguration

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);
}
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)

Aggregations

DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 SystemDataRegionConfiguration (org.apache.ignite.configuration.SystemDataRegionConfiguration)2 ArrayList (java.util.ArrayList)1 Ignite (org.apache.ignite.Ignite)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 MemoryConfiguration (org.apache.ignite.configuration.MemoryConfiguration)1 MemoryPolicyConfiguration (org.apache.ignite.configuration.MemoryPolicyConfiguration)1 PersistentStoreConfiguration (org.apache.ignite.configuration.PersistentStoreConfiguration)1 AbstractFailureHandler (org.apache.ignite.failure.AbstractFailureHandler)1 FailureContext (org.apache.ignite.failure.FailureContext)1