本文整理汇总了Java中org.apache.ignite.transactions.TransactionIsolation.values方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionIsolation.values方法的具体用法?Java TransactionIsolation.values怎么用?Java TransactionIsolation.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.transactions.TransactionIsolation
的用法示例。
在下文中一共展示了TransactionIsolation.values方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNearNodeKey
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testNearNodeKey() throws Exception {
if (cacheMode() != PARTITIONED)
return;
if (atomicityMode() == TRANSACTIONAL) {
for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) {
for (TransactionIsolation txIsolation : TransactionIsolation.values()) {
for (Operation op : Operation.values()) {
testNearNodeKey(txConcurrency, txIsolation, op);
afterTest();
}
}
}
}
testNearNodeKey(null, null, null);
}
示例2: testKeepBinaryTxOverwrite
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @throws Exception if failed.
*/
public void testKeepBinaryTxOverwrite() throws Exception {
if (atomicityMode() != TRANSACTIONAL)
return;
IgniteCache<Integer, TestObject> cache = ignite(0).cache(DEFAULT_CACHE_NAME);
cache.put(0, new TestObject(1));
for (TransactionConcurrency conc : TransactionConcurrency.values()) {
for (TransactionIsolation iso : TransactionIsolation.values()) {
try (Transaction tx = ignite(0).transactions().txStart(conc, iso)) {
cache.withKeepBinary().get(0);
cache.invoke(0, new ObjectEntryProcessor());
tx.commit();
}
}
}
}
示例3: testTimeoutOnPrimaryDHTNode
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* Tests timeout on DHT primary node for all tx configurations.
*
* @throws Exception If failed.
*/
public void testTimeoutOnPrimaryDHTNode() throws Exception {
final ClusterNode n0 = grid(0).affinity(CACHE_NAME).mapKeyToNode(0);
final Ignite prim = G.ignite(n0.id());
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values())
testTimeoutOnPrimaryDhtNode0(prim, concurrency, isolation);
}
}
示例4: testPutBackupTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @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));
}
}
}
示例5: threadLocalTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @param node Node.
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
private void threadLocalTx(Ignite node) throws Exception {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setBackups(2);
IgniteCache<Object, Object> cache = node.getOrCreateCache(ccfg);
checkNoTx(node);
boolean[] reads = {true, false};
boolean[] writes = {true, false};
int endOps = 5;
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
for (boolean read : reads) {
for (boolean write : writes) {
for (int i = 0; i < endOps; i++)
checkTx(concurrency, isolation, node, cache, read, write, i);
}
}
}
}
checkNoTx(node);
cache.put(1, 1);
checkNoTx(node);
}
示例6: checkLoadedValue
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
private void checkLoadedValue(int backups) throws Exception {
CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
cacheCfg.setCacheStoreFactory(new StoreFactory());
cacheCfg.setReadThrough(true);
cacheCfg.setBackups(backups);
cacheCfg.setLoadPreviousValue(true);
IgniteCache<Integer, Integer> cache = ignite(0).createCache(cacheCfg);
for (int i = 0; i < 10; i++)
assertEquals((Integer)i, cache.get(i));
cache.removeAll();
assertEquals(0, cache.size());
for (TransactionConcurrency conc : TransactionConcurrency.values()) {
for (TransactionIsolation iso : TransactionIsolation.values()) {
info("Checking transaction [conc=" + conc + ", iso=" + iso + ']');
try (Transaction tx = ignite(0).transactions().txStart(conc, iso)) {
for (int i = 0; i < 10; i++)
assertEquals("Invalid value for transaction [conc=" + conc + ", iso=" + iso + ']',
(Integer)i, cache.get(i));
tx.commit();
}
cache.removeAll();
assertEquals(0, cache.size());
}
}
cache.destroy();
}
示例7: testIndexingSpiFailure
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void testIndexingSpiFailure() throws Exception {
IgniteConfiguration cfg = configuration();
cfg.setIndexingSpi(new MyBrokenIndexingSpi());
Ignite ignite = Ignition.start(cfg);
CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(CACHE_NAME);
ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
final IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
final IgniteTransactions txs = ignite.transactions();
for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (final TransactionIsolation isolation : TransactionIsolation.values()) {
System.out.println("Run in transaction: " + concurrency + " " + isolation);
GridTestUtils.assertThrowsWithCause(new Callable<Void>() {
@Override public Void call() throws Exception {
Transaction tx;
try (Transaction tx0 = tx = txs.txStart(concurrency, isolation)) {
cache.put(1, 1);
tx0.commit();
}
assertEquals(TransactionState.ROLLED_BACK, tx.state());
return null;
}
}, IgniteTxHeuristicCheckedException.class);
}
}
}
示例8: testIndexingSpiWithTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void testIndexingSpiWithTx() throws Exception {
IgniteEx ignite = grid(0);
final IgniteCache<Integer, Integer> cache = ignite.cache("test-cache");
final IgniteTransactions txs = ignite.transactions();
for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (final TransactionIsolation isolation : TransactionIsolation.values()) {
System.out.println("Run in transaction: " + concurrency + " " + isolation);
GridTestUtils.assertThrowsWithCause(new Callable<Void>() {
@Override public Void call() throws Exception {
Transaction tx;
try (Transaction tx0 = tx = txs.txStart(concurrency, isolation)) {
cache.put(1, 1);
tx0.commit();
}
assertEquals(TransactionState.ROLLED_BACK, tx.state());
return null;
}
}, IgniteTxHeuristicCheckedException.class);
}
}
}
示例9: testDeactivationWithPendingTransaction
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* Tests that deactivation is prohibited if transaction is active in current thread.
*
* @throws Exception If failed.
*/
public void testDeactivationWithPendingTransaction() throws Exception {
startGrids(GRID_CNT);
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values())
deactivateWithPendingTransaction(concurrency, isolation);
}
}
示例10: testInvokeTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @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();
}
}
}
示例11: testReadThroughInTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
private void testReadThroughInTx(boolean needVer) throws Exception {
IgniteCache<String, Integer> cache = grid(1).cache(DEFAULT_CACHE_NAME);
for (int k = 0; k < 1000; k++)
cache.put("key" + k, k);
stopAllGrids();
startGrids(2);
awaitPartitionMapExchange();
Ignite ignite = grid(1);
cache = ignite.cache(DEFAULT_CACHE_NAME);
for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) {
for (TransactionIsolation txIsolation : TransactionIsolation.values()) {
try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation, 100000, 1000)) {
for (int k = 0; k < 1000; k++) {
String key = "key" + k;
if (needVer) {
assertNotNull("Null value for key: " + key, cache.getEntry(key));
assertNotNull("Null value for key: " + key, cache.getEntry(key));
}
else {
assertNotNull("Null value for key: " + key, cache.get(key));
assertNotNull("Null value for key: " + key, cache.get(key));
}
}
tx.commit();
}
}
}
}
示例12: testInvokeAllTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @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();
}
}
}
示例13: doTransformResourceInjectionInTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @param ignite Node.
* @param cache Cache.
* @param async Use async API.
* @param oldAsync Use old async API.
* @throws Exception If failed.
*/
private void doTransformResourceInjectionInTx(Ignite ignite, IgniteCache<String, Integer> cache, boolean async,
boolean oldAsync) throws Exception {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
IgniteTransactions txs = ignite.transactions();
try (Transaction tx = txs.txStart(concurrency, isolation)) {
doTransformResourceInjection(ignite, cache, async, oldAsync);
tx.commit();
}
}
}
}
示例14: testPutMultipleKeysTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testPutMultipleKeysTx() throws Exception {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
checkPutTx(true, concurrency, isolation,
keyForNode(grid(0).localNode(), PRIMARY),
keyForNode(grid(0).localNode(), PRIMARY),
keyForNode(grid(0).localNode(), PRIMARY));
checkPutTx(false, concurrency, isolation,
keyForNode(grid(0).localNode(), PRIMARY),
keyForNode(grid(0).localNode(), PRIMARY),
keyForNode(grid(0).localNode(), PRIMARY));
if (gridCount() > 1) {
checkPutTx(true, concurrency, isolation,
keyForNode(grid(1).localNode(), PRIMARY),
keyForNode(grid(1).localNode(), PRIMARY),
keyForNode(grid(1).localNode(), PRIMARY));
checkPutTx(false, concurrency, isolation,
keyForNode(grid(1).localNode(), PRIMARY),
keyForNode(grid(1).localNode(), PRIMARY),
keyForNode(grid(1).localNode(), PRIMARY));
}
}
}
}
示例15: testContainsInTx
import org.apache.ignite.transactions.TransactionIsolation; //导入方法依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testContainsInTx() throws Exception {
if (atomicityMode() == TRANSACTIONAL) {
String key = "1";
for (int i = 0; i < gridCount(); i++)
assertFalse("Invalid result on grid: " + i, jcache(i).containsKey(key));
IgniteCache<String, Integer> cache = jcache(0);
for (TransactionConcurrency conc : TransactionConcurrency.values()) {
for (TransactionIsolation iso : TransactionIsolation.values()) {
try (Transaction tx = grid(0).transactions().txStart(conc, iso)) {
assertFalse("Invalid result on grid inside tx", cache.containsKey(key));
assertFalse("Key was enlisted to transaction: " + tx, txContainsKey(tx, key));
cache.put(key, 1);
assertTrue("Invalid result on grid inside tx", cache.containsKey(key));
// Do not commit.
}
for (int i = 0; i < gridCount(); i++)
assertFalse("Invalid result on grid: " + i, jcache(i).containsKey(key));
}
}
}
}