Search in sources :

Example 6 with MemoryConfiguration

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

the class IgniteKernal method addDataStorageConfigurationAttributes.

/**
 */
private void addDataStorageConfigurationAttributes() throws IgniteCheckedException {
    MemoryConfiguration memCfg = cfg.getMemoryConfiguration();
    // Save legacy memory configuration if it's present.
    if (memCfg != null) {
        // Page size initialization is suspended, see IgniteCacheDatabaseSharedManager#checkPageSize.
        // We should copy initialized value from new configuration.
        memCfg.setPageSize(cfg.getDataStorageConfiguration().getPageSize());
        add(ATTR_MEMORY_CONFIG, memCfg);
    }
    // Save data storage configuration.
    add(ATTR_DATA_STORAGE_CONFIG, new JdkMarshaller().marshal(cfg.getDataStorageConfiguration()));
}
Also used : JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration)

Example 7 with MemoryConfiguration

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

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

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

use of org.apache.ignite.configuration.MemoryConfiguration 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)

Aggregations

MemoryConfiguration (org.apache.ignite.configuration.MemoryConfiguration)19 MemoryPolicyConfiguration (org.apache.ignite.configuration.MemoryPolicyConfiguration)15 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 PersistentStoreConfiguration (org.apache.ignite.configuration.PersistentStoreConfiguration)3 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgniteOutOfMemoryException (org.apache.ignite.internal.mem.IgniteOutOfMemoryException)2 JdkMarshaller (org.apache.ignite.marshaller.jdk.JdkMarshaller)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 GridTimeoutObject (org.apache.ignite.internal.processors.timeout.GridTimeoutObject)1 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)1