Search in sources :

Example 16 with MemoryPolicyConfiguration

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

the class FreeListImplSelfTest method createFreeList.

/**
     * @param pageSize Page size.
     * @return Free list.
     * @throws Exception If failed.
     */
protected FreeList createFreeList(int pageSize) throws Exception {
    MemoryPolicyConfiguration plcCfg = new MemoryPolicyConfiguration().setMaxSize(1024 * MB);
    pageMem = createPageMemory(pageSize, plcCfg);
    long metaPageId = pageMem.allocatePage(1, 1, PageIdAllocator.FLAG_DATA);
    MemoryMetricsImpl metrics = new MemoryMetricsImpl(plcCfg);
    MemoryPolicy memPlc = new MemoryPolicy(pageMem, plcCfg, metrics, new NoOpPageEvictionTracker());
    return new FreeListImpl(1, "freelist", metrics, memPlc, null, null, metaPageId, true);
}
Also used : NoOpPageEvictionTracker(org.apache.ignite.internal.processors.cache.database.evict.NoOpPageEvictionTracker) FreeListImpl(org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl) MemoryPolicy(org.apache.ignite.internal.processors.cache.database.MemoryPolicy) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) MemoryMetricsImpl(org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)

Example 17 with MemoryPolicyConfiguration

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

the class IgniteCacheDatabaseSharedManager method registerMetricsMBeans.

/**
     * Registers MBeans for all MemoryMetrics configured in this instance.
     */
private void registerMetricsMBeans() {
    IgniteConfiguration cfg = cctx.gridConfig();
    for (MemoryMetrics memMetrics : memMetricsMap.values()) {
        MemoryPolicyConfiguration memPlcCfg = memPlcMap.get(memMetrics.getName()).config();
        registerMetricsMBean((MemoryMetricsImpl) memMetrics, memPlcCfg, cfg);
    }
}
Also used : MemoryMetrics(org.apache.ignite.MemoryMetrics) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 18 with MemoryPolicyConfiguration

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

the class IgniteCacheDatabaseSharedManager method initPageMemoryPolicies.

/**
     * @param memCfg Database config.
     */
protected void initPageMemoryPolicies(MemoryConfiguration memCfg) {
    MemoryPolicyConfiguration[] memPlcsCfgs = memCfg.getMemoryPolicies();
    if (memPlcsCfgs == null) {
        //reserve place for default and system memory policies
        memPlcMap = U.newHashMap(2);
        memMetricsMap = U.newHashMap(2);
        addMemoryPolicy(memCfg, memCfg.createDefaultPolicyConfig(), DFLT_MEM_PLC_DEFAULT_NAME);
        U.warn(log, "No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
    } else {
        String dfltMemPlcName = memCfg.getDefaultMemoryPolicyName();
        if (DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltMemPlcName) && !hasCustomDefaultMemoryPolicy(memPlcsCfgs)) {
            //reserve additional place for default and system memory policies
            memPlcMap = U.newHashMap(memPlcsCfgs.length + 2);
            memMetricsMap = U.newHashMap(memPlcsCfgs.length + 2);
            addMemoryPolicy(memCfg, memCfg.createDefaultPolicyConfig(), DFLT_MEM_PLC_DEFAULT_NAME);
            U.warn(log, "No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
        } else {
            //reserve additional space for system memory policy only
            memPlcMap = U.newHashMap(memPlcsCfgs.length + 1);
            memMetricsMap = U.newHashMap(memPlcsCfgs.length + 1);
        }
        for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs) addMemoryPolicy(memCfg, memPlcCfg, memPlcCfg.getName());
    }
    addMemoryPolicy(memCfg, createSystemMemoryPolicy(memCfg.getSystemCacheInitialSize(), memCfg.getSystemCacheMaxSize()), SYSTEM_MEMORY_POLICY_NAME);
}
Also used : MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Example 19 with MemoryPolicyConfiguration

use of org.apache.ignite.configuration.MemoryPolicyConfiguration 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 20 with MemoryPolicyConfiguration

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

the class MemoryPolicyInitializationTest method prepareCustomConfigWithOverriddenDefaultName.

/**
 */
private void prepareCustomConfigWithOverriddenDefaultName() {
    memCfg = new MemoryConfiguration();
    memCfg.setDefaultMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
    memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME).setInitialSize(USER_CUSTOM_MEM_PLC_SIZE).setMaxSize(USER_CUSTOM_MEM_PLC_SIZE), new MemoryPolicyConfiguration().setName(DFLT_MEM_PLC_DEFAULT_NAME).setInitialSize(USER_CUSTOM_MEM_PLC_SIZE).setMaxSize(USER_DEFAULT_MEM_PLC_SIZE));
}
Also used : MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration)

Aggregations

MemoryPolicyConfiguration (org.apache.ignite.configuration.MemoryPolicyConfiguration)25 MemoryConfiguration (org.apache.ignite.configuration.MemoryConfiguration)14 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 MemoryMetricsImpl (org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl)3 FreeListImpl (org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl)3 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 PersistentStoreConfiguration (org.apache.ignite.configuration.PersistentStoreConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgniteOutOfMemoryException (org.apache.ignite.internal.mem.IgniteOutOfMemoryException)2 ArrayList (java.util.ArrayList)1 MemoryMetrics (org.apache.ignite.MemoryMetrics)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 SystemDataRegionConfiguration (org.apache.ignite.configuration.SystemDataRegionConfiguration)1 DirectMemoryProvider (org.apache.ignite.internal.mem.DirectMemoryProvider)1 MappedFileMemoryProvider (org.apache.ignite.internal.mem.file.MappedFileMemoryProvider)1 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)1 PageMemoryNoStoreImpl (org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl)1 MemoryPolicy (org.apache.ignite.internal.processors.cache.database.MemoryPolicy)1