Search in sources :

Example 11 with MemoryPolicyConfiguration

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

the class CacheMemoryPolicyConfigurationTest method testProperlySizedMemoryPolicy.

/**
     * Verifies that with enough memory allocated adding values to cache doesn't cause any exceptions.
     */
public void testProperlySizedMemoryPolicy() throws Exception {
    memCfg = new MemoryConfiguration();
    MemoryPolicyConfiguration dfltPlcCfg = new MemoryPolicyConfiguration();
    dfltPlcCfg.setName("dfltPlc");
    dfltPlcCfg.setInitialSize(DFLT_MEM_PLC_SIZE);
    dfltPlcCfg.setMaxSize(DFLT_MEM_PLC_SIZE);
    MemoryPolicyConfiguration bigPlcCfg = new MemoryPolicyConfiguration();
    bigPlcCfg.setName("bigPlc");
    bigPlcCfg.setMaxSize(BIG_MEM_PLC_SIZE);
    memCfg.setMemoryPolicies(dfltPlcCfg, bigPlcCfg);
    memCfg.setDefaultMemoryPolicyName("dfltPlc");
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setMemoryPolicyName("bigPlc");
    IgniteEx ignite0 = startGrid(0);
    IgniteCache<Object, Object> cache = ignite0.cache(DEFAULT_CACHE_NAME);
    try {
        for (int i = 0; i < 500_000; i++) cache.put(i, "abc");
    } catch (Exception e) {
        fail("With properly sized MemoryPolicy no exceptions are expected to be thrown.");
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException)

Example 12 with MemoryPolicyConfiguration

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

the class CacheMemoryPolicyConfigurationTest method testTooSmallMemoryPolicy.

/**
     * Verifies that {@link IgniteOutOfMemoryException} is thrown when cache is configured with too small MemoryPolicy.
     */
public void testTooSmallMemoryPolicy() throws Exception {
    memCfg = new MemoryConfiguration();
    MemoryPolicyConfiguration dfltPlcCfg = new MemoryPolicyConfiguration();
    dfltPlcCfg.setName("dfltPlc");
    dfltPlcCfg.setInitialSize(10 * 1024 * 1024);
    dfltPlcCfg.setMaxSize(10 * 1024 * 1024);
    MemoryPolicyConfiguration bigPlcCfg = new MemoryPolicyConfiguration();
    bigPlcCfg.setName("bigPlc");
    bigPlcCfg.setMaxSize(1024 * 1024 * 1024);
    memCfg.setMemoryPolicies(dfltPlcCfg, bigPlcCfg);
    memCfg.setDefaultMemoryPolicyName("dfltPlc");
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    IgniteEx ignite0 = startGrid(0);
    IgniteCache<Object, Object> cache = ignite0.cache(DEFAULT_CACHE_NAME);
    boolean oomeThrown = false;
    try {
        for (int i = 0; i < 500_000; i++) cache.put(i, "abc");
    } catch (Exception e) {
        Throwable cause = e;
        do {
            if (cause instanceof IgniteOutOfMemoryException) {
                oomeThrown = true;
                break;
            }
            if (cause == null)
                break;
            if (cause.getSuppressed() == null || cause.getSuppressed().length == 0)
                cause = cause.getCause();
            else
                cause = cause.getSuppressed()[0];
        } while (true);
    }
    if (!oomeThrown)
        fail("OutOfMemoryException hasn't been thrown");
}
Also used : IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException) IgniteEx(org.apache.ignite.internal.IgniteEx) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) MemoryPolicyConfiguration(org.apache.ignite.configuration.MemoryPolicyConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException)

Example 13 with MemoryPolicyConfiguration

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

the class MemoryPolicyInitializationTest method prepareCustomConfigWithOverridingDefaultAndCustom.

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

Example 14 with MemoryPolicyConfiguration

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

the class MemoryPolicyInitializationTest method prepareCustomNoDefaultConfig.

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

Example 15 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