use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheNearEvictionSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(PARTITIONED);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setBackups(1);
cc.setRebalanceMode(SYNC);
cc.setAtomicityMode(atomicityMode());
NearCacheConfiguration nearCfg = new NearCacheConfiguration();
cc.setNearConfiguration(nearCfg);
c.setCacheConfiguration(cc);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
return c;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheMultithreadedFailoverAbstractTest method configuration.
/**
* Node configuration.
*
* @param idx Node index.
* @return Node configuration.
* @throws Exception If failed.
*/
private IgniteConfiguration configuration(int idx) throws Exception {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(CACHE_NAME);
ccfg.setCacheMode(cacheMode());
ccfg.setAtomicityMode(atomicityMode());
ccfg.setRebalanceMode(SYNC);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setEvictionPolicy(null);
if (cacheMode() == PARTITIONED)
ccfg.setBackups(backups());
if (atomicityMode() != ATOMIC && cacheMode() == PARTITIONED) {
ccfg.setNearConfiguration(new NearCacheConfiguration());
}
IgniteConfiguration cfg = getConfiguration(nodeName(idx));
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discoSpi);
cfg.setLocalHost("127.0.0.1");
cfg.setCacheConfiguration(ccfg);
cfg.setConnectorConfiguration(null);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class IgniteCacheClientNodeChangingTopologyTest method lock.
/**
* @param nearCfg Near cache configuration.
* @throws Exception If failed.
*/
private void lock(NearCacheConfiguration nearCfg) throws Exception {
ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(PARTITIONED);
ccfg.setBackups(1);
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setRebalanceMode(SYNC);
ccfg.setNearConfiguration(nearCfg);
final IgniteEx ignite0 = startGrid(0);
final IgniteEx ignite1 = startGrid(1);
awaitPartitionMapExchange();
client = true;
final Ignite ignite2 = startGrid(2);
assertTrue(ignite2.configuration().isClientMode());
final List<Integer> keys = new ArrayList<>();
for (int i = 0; i < 100; i++) keys.add(i);
TestCommunicationSpi spi = (TestCommunicationSpi) ignite2.configuration().getCommunicationSpi();
spi.blockMessages(GridNearLockRequest.class, ignite0.localNode().id());
spi.blockMessages(GridNearLockRequest.class, ignite1.localNode().id());
final IgniteCache<Integer, Integer> cache = ignite2.cache(DEFAULT_CACHE_NAME);
final CountDownLatch lockedLatch = new CountDownLatch(1);
final CountDownLatch unlockLatch = new CountDownLatch(1);
IgniteInternalFuture<Lock> lockFut = GridTestUtils.runAsync(new Callable<Lock>() {
@Override
public Lock call() throws Exception {
Thread.currentThread().setName("put-thread");
Lock lock = cache.lockAll(keys);
lock.lock();
log.info("Locked");
lockedLatch.countDown();
unlockLatch.await();
lock.unlock();
return lock;
}
});
client = false;
startGrid(3);
log.info("Stop block.");
assertEquals(1, lockedLatch.getCount());
spi.stopBlock();
assertTrue(lockedLatch.await(3000, TimeUnit.MILLISECONDS));
IgniteCache<Integer, Integer> cache0 = ignite0.cache(DEFAULT_CACHE_NAME);
for (Integer key : keys) {
Lock lock = cache0.lock(key);
assertFalse(lock.tryLock());
}
unlockLatch.countDown();
lockFut.get();
awaitPartitionMapExchange();
boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
for (int i = 0; i < 4; i++) {
if (!unlocked(ignite(i)))
return false;
}
return true;
}
private boolean unlocked(Ignite ignite) {
IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME);
for (Integer key : keys) {
if (cache.isLocalLocked(key, false)) {
log.info("Key is locked [key=" + key + ", node=" + ignite.name() + ']');
return false;
}
}
return true;
}
}, 10_000);
assertTrue(wait);
for (Integer key : keys) {
Lock lock = cache0.lock(key);
assertTrue("Failed to lock: " + key, lock.tryLock());
lock.unlock();
}
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridDiscoveryManagerAliveCacheSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration cCfg = defaultCacheConfiguration();
cCfg.setCacheMode(PARTITIONED);
cCfg.setBackups(1);
cCfg.setNearConfiguration(new NearCacheConfiguration());
cCfg.setRebalanceMode(SYNC);
cCfg.setWriteSynchronizationMode(FULL_SYNC);
TcpDiscoverySpi disc = new TcpDiscoverySpi();
if (clientMode && ((igniteInstanceName.charAt(igniteInstanceName.length() - 1) - '0') & 1) != 0)
cfg.setClientMode(true);
else
cfg.setClientFailureDetectionTimeout(50000);
disc.setIpFinder(IP_FINDER);
disc.setAckTimeout(1000);
disc.setSocketTimeout(1000);
cfg.setCacheConfiguration(cCfg);
cfg.setDiscoverySpi(disc);
cfg.setMetricsUpdateFrequency(500);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCachePutAllFailoverSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
cfg.setPeerClassLoadingEnabled(false);
cfg.setDeploymentMode(DeploymentMode.CONTINUOUS);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
discoverySpi.setAckTimeout(60000);
discoverySpi.setIpFinder(ipFinder);
discoverySpi.setForceServerMode(true);
cfg.setDiscoverySpi(discoverySpi);
if (igniteInstanceName.startsWith("master")) {
cfg.setClientMode(true);
cfg.setUserAttributes(ImmutableMap.of("segment", "master"));
// For sure.
failoverSpi.setMaximumFailoverAttempts(100);
cfg.setFailoverSpi(failoverSpi);
} else if (igniteInstanceName.startsWith("worker")) {
cfg.setUserAttributes(ImmutableMap.of("segment", "worker"));
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setName("partitioned");
cacheCfg.setAtomicityMode(atomicityMode());
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setBackups(backups);
cacheCfg.setNearConfiguration(nearEnabled ? new NearCacheConfiguration() : null);
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setCacheConfiguration(cacheCfg);
} else
throw new IllegalStateException("Unexpected Ignite instance name: " + igniteInstanceName);
return cfg;
}
Aggregations