use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class IgniteTxStoreExceptionAbstractSelfTest method testPutBackupTx.
/**
* @throws Exception If failed.
*/
public void testPutBackupTx() throws Exception {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
checkPutTx(true, concurrency, isolation, keyForNode(grid(0).localNode(), BACKUP));
checkPutTx(false, concurrency, isolation, keyForNode(grid(0).localNode(), BACKUP));
}
}
}
use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class IgniteTxStoreExceptionAbstractSelfTest method testPutPrimaryTx.
/**
* @throws Exception If failed.
*/
public void testPutPrimaryTx() throws Exception {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
checkPutTx(true, concurrency, isolation, keyForNode(grid(0).localNode(), PRIMARY));
checkPutTx(false, concurrency, isolation, keyForNode(grid(0).localNode(), PRIMARY));
}
}
}
use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class WithKeepBinaryCacheFullApiTest method testInvokeAllTx.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("serial")
public void testInvokeAllTx() throws Exception {
if (!txShouldBeUsed())
return;
for (TransactionConcurrency conc : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
checkInvokeAllTx(conc, isolation);
jcache().removeAll();
}
}
}
use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class IgniteCacheNoReadThroughAbstractTest method testNoReadThrough.
/**
* @throws Exception If failed.
*/
public void testNoReadThrough() throws Exception {
IgniteCache<Integer, Integer> cache = jcache(0);
for (Integer key : keys()) {
log.info("Test [key=" + key + ']');
storeMap.put(key, key);
assertNull(cache.get(key));
assertEquals(key, storeMap.get(key));
assertNull(cache.getAndPut(key, -1));
assertEquals(-1, storeMap.get(key));
cache.remove(key);
assertNull(storeMap.get(key));
storeMap.put(key, key);
assertTrue(cache.putIfAbsent(key, -1));
assertEquals(-1, storeMap.get(key));
cache.remove(key);
assertNull(storeMap.get(key));
storeMap.put(key, key);
assertNull(cache.getAndRemove(key));
assertNull(storeMap.get(key));
storeMap.put(key, key);
assertNull(cache.getAndPutIfAbsent(key, -1));
assertEquals(-1, storeMap.get(key));
cache.remove(key);
assertNull(storeMap.get(key));
storeMap.put(key, key);
Object ret = cache.invoke(key, new EntryProcessor<Integer, Integer, Object>() {
@Override
public Object process(MutableEntry<Integer, Integer> e, Object... args) {
Integer val = e.getValue();
assertFalse(e.exists());
assertNull(val);
e.setValue(-1);
return String.valueOf(val);
}
});
assertEquals("null", ret);
assertEquals(-1, storeMap.get(key));
cache.remove(key);
assertNull(storeMap.get(key));
storeMap.put(key, key);
assertFalse(cache.replace(key, -1));
assertEquals(key, storeMap.get(key));
assertNull(cache.getAndReplace(key, -1));
assertEquals(key, storeMap.get(key));
assertFalse(cache.replace(key, key, -1));
assertEquals(key, storeMap.get(key));
}
Set<Integer> keys = new HashSet<>();
for (int i = 1000_0000; i < 1000_0000 + 1000; i++) {
keys.add(i);
storeMap.put(i, i);
}
assertTrue(cache.getAll(keys).isEmpty());
if (atomicityMode() == TRANSACTIONAL) {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
for (Integer key : keys()) {
log.info("Test tx [key=" + key + ", concurrency=" + concurrency + ", isolation=" + isolation + ']');
storeMap.put(key, key);
try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
assertNull(cache.get(key));
tx.commit();
}
assertEquals(key, storeMap.get(key));
try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
assertNull(cache.getAndPut(key, -1));
tx.commit();
}
assertEquals(-1, storeMap.get(key));
cache.remove(key);
assertNull(storeMap.get(key));
storeMap.put(key, key);
try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
assertTrue(cache.putIfAbsent(key, -1));
tx.commit();
}
assertEquals(-1, storeMap.get(key));
cache.remove(key);
assertNull(storeMap.get(key));
storeMap.put(key, key);
try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
Object ret = cache.invoke(key, new EntryProcessor<Integer, Integer, Object>() {
@Override
public Object process(MutableEntry<Integer, Integer> e, Object... args) {
Integer val = e.getValue();
assertFalse(e.exists());
assertNull(val);
e.setValue(-1);
return String.valueOf(val);
}
});
assertEquals("null", ret);
tx.commit();
}
assertEquals(-1, storeMap.get(key));
try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
assertTrue(cache.getAll(keys).isEmpty());
tx.commit();
}
}
}
}
}
// Check can load cache when read-through is disabled.
allowLoad = true;
Integer key = 1;
cache.remove(key);
storeMap.clear();
storeMap.put(key, 10);
cache.loadCache(null);
assertEquals(10, (int) cache.get(key));
cache.remove(key);
storeMap.put(key, 11);
CompletionListenerFuture fut = new CompletionListenerFuture();
cache.loadAll(F.asSet(key), true, fut);
fut.get();
assertEquals(11, (int) cache.get(key));
}
use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class WithKeepBinaryCacheFullApiTest method testInvokeTx.
/**
* @throws Exception If failed.
*/
public void testInvokeTx() throws Exception {
if (!txShouldBeUsed())
return;
for (TransactionConcurrency conc : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
info(">>>>> Executing test using explicit txs [concurrency=" + conc + ", isolation=" + isolation + "]");
checkInvokeTx(conc, isolation);
jcache().removeAll();
}
}
}
Aggregations