use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridCacheNearOneNodeSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration() throws Exception {
IgniteConfiguration cfg = super.getConfiguration();
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));
cfg.setDiscoverySpi(disco);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setBackups(1);
cacheCfg.setAtomicityMode(TRANSACTIONAL);
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheCfg.setCacheStoreFactory(singletonFactory(store));
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setLoadPreviousValue(true);
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridCacheNearMetricsSelfTest method cacheConfiguration.
/** {@inheritDoc} */
@Override
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration cc = super.cacheConfiguration(igniteInstanceName);
cc.setCacheMode(CacheMode.PARTITIONED);
cc.setBackups(1);
return cc;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridCacheNearMultiGetSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings({ "ConstantConditions" })
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
c.getTransactionConfiguration().setTxSerializableEnabled(true);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(PARTITIONED);
cc.setBackups(1);
cc.setAtomicityMode(TRANSACTIONAL);
cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cc.setRebalanceMode(NONE);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
c.setFailureDetectionTimeout(Integer.MAX_VALUE);
c.setDiscoverySpi(spi);
c.setCacheConfiguration(cc);
if (CACHE_DEBUG)
resetLog4j(Level.DEBUG, false, GridCacheProcessor.class.getPackage().getName());
return c;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class CacheContinuousQueryConcurrentPartitionUpdateTest method concurrentUpdatesAndQueryStart.
/**
* @param atomicityMode Cache atomicity mode.
* @throws Exception If failed.
*/
private void concurrentUpdatesAndQueryStart(CacheAtomicityMode atomicityMode) throws Exception {
Ignite srv = startGrid(0);
client = true;
Ignite client = startGrid(1);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setAtomicityMode(atomicityMode);
IgniteCache clientCache = client.createCache(ccfg);
Affinity<Integer> aff = srv.affinity(DEFAULT_CACHE_NAME);
final List<Integer> keys = new ArrayList<>();
final int KEYS = 10;
for (int i = 0; i < 100_000; i++) {
if (aff.partition(i) == 0) {
keys.add(i);
if (keys.size() == KEYS)
break;
}
}
assertEquals(KEYS, keys.size());
final int THREADS = 10;
final int UPDATES = 1000;
for (int i = 0; i < 5; i++) {
log.info("Iteration: " + i);
ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();
final AtomicInteger evtCnt = new AtomicInteger();
qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() {
@Override
public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) {
for (CacheEntryEvent evt : evts) {
assertNotNull(evt.getKey());
assertNotNull(evt.getValue());
if ((Integer) evt.getValue() >= 0)
evtCnt.incrementAndGet();
}
}
});
QueryCursor cur;
final IgniteCache<Object, Object> srvCache = srv.cache(DEFAULT_CACHE_NAME);
final AtomicBoolean stop = new AtomicBoolean();
try {
IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
while (!stop.get()) srvCache.put(keys.get(rnd.nextInt(KEYS)), rnd.nextInt(100) - 200);
return null;
}
}, THREADS, "update");
U.sleep(1000);
cur = clientCache.query(qry);
U.sleep(1000);
stop.set(true);
fut.get();
} finally {
stop.set(true);
}
GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
for (int i = 0; i < UPDATES; i++) srvCache.put(keys.get(rnd.nextInt(KEYS)), i);
return null;
}
}, THREADS, "update");
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
log.info("Events: " + evtCnt.get());
return evtCnt.get() >= THREADS * UPDATES;
}
}, 5000);
assertEquals(THREADS * UPDATES, evtCnt.get());
cur.close();
}
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridServiceProcessorStopSelfTest method testStopDuringHangedDeployment.
/**
* @throws Exception If failed.
*/
public void testStopDuringHangedDeployment() throws Exception {
final CountDownLatch depLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
final IgniteEx node0 = startGrid(0);
final IgniteEx node1 = startGrid(1);
final IgniteEx node2 = startGrid(2);
final IgniteCache<Object, Object> cache = node2.getOrCreateCache(new CacheConfiguration<Object, Object>("def").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
node0.services().deployNodeSingleton("myService", new TestServiceImpl());
// Guarantee lock owner will never left topology unexpectedly.
final Integer lockKey = keyForNode(node2.affinity("def"), new AtomicInteger(1), node2.cluster().localNode());
// Lock to hold topology version undone.
final Lock lock = cache.lock(lockKey);
// Try to change topology once service has deployed.
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
depLatch.await();
node1.close();
return null;
}
}, "top-change-thread");
// Stop node on unstable topology.
GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
depLatch.await();
Thread.sleep(1000);
node0.close();
finishLatch.countDown();
return null;
}
}, "stopping-node-thread");
assertNotNull(node0.services().service("myService"));
// Freeze topology changing
lock.lock();
depLatch.countDown();
boolean wait = finishLatch.await(15, TimeUnit.SECONDS);
if (!wait)
U.dumpThreads(log);
assertTrue("Deploy future isn't completed", wait);
fut.get();
Ignition.stopAll(true);
}
Aggregations