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()));
}
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.");
}
}
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");
}
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));
}
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));
}
Aggregations