use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class CacheStoreUsageMultinodeDynamicStartAbstractTest method checkStoreWithDynamicStart.
/**
* @param clientStart {@code True} if start cache from client node.
* @throws Exception If failed.
*/
private void checkStoreWithDynamicStart(boolean clientStart) throws Exception {
cacheStore = true;
CacheConfiguration ccfg = cacheConfiguration();
assertNotNull(ccfg.getCacheStoreFactory());
Ignite srv = ignite(0);
Ignite client = ignite(3);
Ignite node = clientStart ? client : srv;
IgniteCache cache = nearCache ? node.createCache(ccfg, new NearCacheConfiguration()) : node.createCache(ccfg);
assertNotNull(cache);
try {
if (nearCache)
client.createNearCache(DEFAULT_CACHE_NAME, new NearCacheConfiguration<>());
checkStoreUpdate(true);
} finally {
cache = srv.cache(DEFAULT_CACHE_NAME);
if (cache != null)
cache.destroy();
}
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class CacheTxFastFinishTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(PARTITIONED);
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setBackups(1);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
if (nearCache)
ccfg.setNearConfiguration(new NearCacheConfiguration());
cfg.setCacheConfiguration(ccfg);
cfg.setClientMode(client);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class CacheStopAndDestroySelfTest method testNearClose.
/**
* Test Near close.
*
* @throws Exception If failed.
*/
public void testNearClose() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-2189");
startGridsMultiThreaded(gridCount());
IgniteCache<String, String> cache0 = grid(0).getOrCreateCache(getNearConfig());
// GridDhtTxPrepareRequest requests to Client node will be counted.
CountingTxRequestsToClientNodeTcpCommunicationSpi.nodeFilter = grid(2).context().localNodeId();
// Near Close from client node.
IgniteCache<String, String> cache1 = grid(1).cache(CACHE_NAME_NEAR);
IgniteCache<String, String> cache2 = grid(2).createNearCache(CACHE_NAME_NEAR, new NearCacheConfiguration());
assert cache2.get(KEY_VAL) == null;
// Subscribing to events.
cache2.put(KEY_VAL, KEY_VAL);
CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.set(0);
cache0.put(KEY_VAL, "near-test");
U.sleep(1000);
//Ensure near cache was automatically updated.
assert CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.get() != 0;
assert cache2.localPeek(KEY_VAL).equals("near-test");
cache2.close();
CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.set(0);
// Should not produce messages to client node.
cache0.put(KEY_VAL, KEY_VAL + 0);
U.sleep(1000);
// Ensure near cache was NOT automatically updated.
assert CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.get() == 0;
// Not affected.
assert cache0.get(KEY_VAL).equals(KEY_VAL + 0);
// Not affected.
assert cache1.get(KEY_VAL).equals(KEY_VAL + 0);
try {
// Affected.
cache2.get(KEY_VAL);
assert false;
} catch (IllegalArgumentException | IllegalStateException ignored) {
// No-op
}
// Near Creation from client node after closed.
IgniteCache<String, String> cache2New = grid(2).createNearCache(CACHE_NAME_NEAR, new NearCacheConfiguration());
assertNotSame(cache2, cache2New);
// Subscribing to events.
cache2New.put(KEY_VAL, KEY_VAL);
assert cache2New.localPeek(KEY_VAL).equals(KEY_VAL);
cache0.put(KEY_VAL, KEY_VAL + "recreated");
assert cache0.get(KEY_VAL).equals(KEY_VAL + "recreated");
assert cache1.get(KEY_VAL).equals(KEY_VAL + "recreated");
assert cache2New.localPeek(KEY_VAL).equals(KEY_VAL + "recreated");
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class CacheStopAndDestroySelfTest method nearDestroy.
/**
* Test Near Destroy.
*
* @throws Exception If failed.
*/
private void nearDestroy() throws Exception {
grid(0).getOrCreateCache(getNearConfig());
grid(2).getOrCreateNearCache(CACHE_NAME_NEAR, new NearCacheConfiguration());
assertNull(grid(0).cache(CACHE_NAME_NEAR).get(KEY_VAL));
assertNull(grid(2).cache(CACHE_NAME_NEAR).get(KEY_VAL));
grid(2).cache(CACHE_NAME_NEAR).put(KEY_VAL, KEY_VAL);
grid(0).cache(CACHE_NAME_NEAR).put(KEY_VAL, "near-test");
assertEquals("near-test", grid(2).cache(CACHE_NAME_NEAR).localPeek(KEY_VAL));
// Near cache destroy. Cache should be removed from each node.
IgniteCache<Object, Object> cache = grid(2).cache(CACHE_NAME_NEAR);
cache.destroy();
checkDestroyed(cache);
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheVersionMultinodeTest method cacheConfiguration.
/** {@inheritDoc} */
@Override
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);
assert atomicityMode != null;
ccfg.setAtomicityMode(atomicityMode);
ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);
return ccfg;
}
Aggregations