use of org.apache.ignite.configuration.MemoryConfiguration in project ignite by apache.
the class CacheStartOnJoinTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
TcpDiscoverySpi testSpi = new TcpDiscoverySpi() {
/** */
private boolean delay = true;
@Override
protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException, IgniteCheckedException {
super.writeToSocket(sock, out, msg, timeout);
}
@Override
protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) {
if (getTestIgniteInstanceName(0).equals(ignite.name())) {
if (msg instanceof TcpDiscoveryJoinRequestMessage) {
TcpDiscoveryJoinRequestMessage msg0 = (TcpDiscoveryJoinRequestMessage) msg;
if (msg0.client() && delay) {
log.info("Delay join processing: " + msg0);
delay = false;
doSleep(5000);
}
}
}
super.startMessageProcess(msg);
}
};
testSpi.setIpFinder(ipFinder);
testSpi.setJoinTimeout(60_000);
cfg.setDiscoverySpi(testSpi);
MemoryConfiguration memCfg = new MemoryConfiguration();
memCfg.setPageSize(1024);
memCfg.setDefaultMemoryPolicySize(50 * 1024 * 1024);
cfg.setMemoryConfiguration(memCfg);
cfg.setClientMode(client);
return cfg;
}
use of org.apache.ignite.configuration.MemoryConfiguration in project ignite by apache.
the class CacheClientStoreSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
boolean client = igniteInstanceName != null && igniteInstanceName.startsWith("client");
cfg.setClientMode(client);
if (client)
cfg.setMemoryConfiguration(new MemoryConfiguration());
CacheConfiguration cc = new CacheConfiguration(DEFAULT_CACHE_NAME);
cc.setName(CACHE_NAME);
cc.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cc.setCacheMode(cacheMode);
cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cc.setBackups(1);
cc.setCacheStoreFactory(factory);
if (factory instanceof Factory3)
cc.setReadThrough(true);
if (client && nearEnabled)
cc.setNearConfiguration(new NearCacheConfiguration());
cfg.setCacheConfiguration(cc);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(disco);
return cfg;
}
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 CacheConfigurationLeakTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration() throws Exception {
IgniteConfiguration cfg = super.getConfiguration();
MemoryConfiguration memCfg = new MemoryConfiguration();
MemoryPolicyConfiguration plc = new MemoryPolicyConfiguration();
plc.setName("dfltPlc");
plc.setMaxSize(MemoryConfiguration.DFLT_MEMORY_POLICY_MAX_SIZE * 10);
memCfg.setDefaultMemoryPolicyName("dfltPlc");
memCfg.setMemoryPolicies(plc);
cfg.setMemoryConfiguration(memCfg);
return cfg;
}
Aggregations