当前位置: 首页>>代码示例>>Java>>正文


Java TransactionIsolation类代码示例

本文整理汇总了Java中org.apache.ignite.transactions.TransactionIsolation的典型用法代码示例。如果您正苦于以下问题:Java TransactionIsolation类的具体用法?Java TransactionIsolation怎么用?Java TransactionIsolation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransactionIsolation类属于org.apache.ignite.transactions包,在下文中一共展示了TransactionIsolation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isolationLevel

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/**
 * Gets DB transaction isolation level based on ongoing cache transaction isolation.
 *
 * @param isolation Cache transaction isolation.
 * @return DB transaction isolation.
 */
private int isolationLevel(TransactionIsolation isolation) {
    switch (isolation) {
        case READ_COMMITTED:
            return TransactionDefinition.ISOLATION_READ_COMMITTED;

        case REPEATABLE_READ:
            return TransactionDefinition.ISOLATION_REPEATABLE_READ;

        case SERIALIZABLE:
            return TransactionDefinition.ISOLATION_SERIALIZABLE;

        default:
            throw new IllegalStateException(); // Will never happen.
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:CacheSpringStoreSessionListener.java

示例2: testOpsProhibitedOnSuspendedTx

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/**
 * Test checking all operations(exception resume) on suspended transaction are prohibited.
 *
 * @throws Exception If failed.
 */
public void testOpsProhibitedOnSuspendedTx() throws Exception {
    executeTestForAllCaches(new CI2Exc<Ignite, IgniteCache<Integer, Integer>>() {
        @Override public void applyx(Ignite ignite, final IgniteCache<Integer, Integer> cache) throws Exception {
            for (CI1Exc<Transaction> txOperation : SUSPENDED_TX_PROHIBITED_OPS) {
                for (TransactionIsolation isolation : TransactionIsolation.values()) {
                    Transaction tx = ignite.transactions().txStart(OPTIMISTIC, isolation);

                    cache.put(1, 1);

                    tx.suspend();

                    GridTestUtils.assertThrowsWithCause(txOperation, tx, IgniteException.class);

                    tx.resume();
                    tx.close();

                    assertNull(cache.get(1));
                }
            }
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:IgniteOptimisticTxSuspendResumeTest.java

示例3: testGetReadThrough

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void testGetReadThrough() throws Exception {
    super.testGetReadThrough();

    getReadThrough(false, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    getReadThrough(true, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    getReadThrough(false, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    getReadThrough(true, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    getReadThrough(false, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
    getReadThrough(true, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);

    getReadThrough(false, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    getReadThrough(true, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    getReadThrough(false, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    getReadThrough(true, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    getReadThrough(false, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
    getReadThrough(true, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:IgniteCacheTxExpiryPolicyWithStoreTest.java

示例4: 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();
            }
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:GridCacheBinaryObjectsAbstractSelfTest.java

示例5: checkReadThrough

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/**
 * @param cache Cache.
 * @param c Cache operation Closure.
 * @param concurrency Transaction concurrency.
 * @param isolation Transaction isolation.
 * @param expLoadCnt Expected number of store 'load' calls.
 * @throws Exception If failed.
 */
private void checkReadThrough(IgniteCache<Object, Object> cache,
    IgniteRunnable c,
    @Nullable TransactionConcurrency concurrency,
    @Nullable TransactionIsolation isolation,
    int expLoadCnt) throws Exception {
    TestStore.loadCnt.set(0);

    Transaction tx = isolation != null ? cache.unwrap(Ignite.class).transactions().txStart(concurrency, isolation)
        : null;

    try {
        c.run();

        if (tx != null)
            tx.commit();
    }
    finally {
        if (tx != null)
            tx.close();
    }

    assertEquals(expLoadCnt, TestStore.loadCnt.get());
}
 
开发者ID:apache,项目名称:ignite,代码行数:32,代码来源:IgniteCacheReadThroughStoreCallTest.java

示例6: readExternal

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    readExternalMeta(in);

    xidVer = (GridCacheVersion)in.readObject();
    invalidate = in.readBoolean();
    timeout = in.readLong();
    threadId = in.readLong();
    startTime = in.readLong();

    nodeId = U.readUuid(in);

    isolation = TransactionIsolation.fromOrdinal(in.read());
    concurrency = TransactionConcurrency.fromOrdinal(in.read());

    state = TransactionState.fromOrdinal(in.read());
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:IgniteTxAdapter.java

示例7: txStart

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation,
    long timeout, int txSize) {
    A.notNull(concurrency, "concurrency");
    A.notNull(isolation, "isolation");
    A.ensure(timeout >= 0, "timeout cannot be negative");
    A.ensure(txSize >= 0, "transaction size cannot be negative");

    return txStart0(
        concurrency,
        isolation,
        timeout,
        txSize,
        null
    ).proxy();
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:IgniteTransactionsImpl.java

示例8: txStartEx

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public GridNearTxLocal txStartEx(
    GridCacheContext ctx,
    TransactionConcurrency concurrency,
    TransactionIsolation isolation)
{
    A.notNull(concurrency, "concurrency");
    A.notNull(isolation, "isolation");

    checkTransactional(ctx);

    TransactionConfiguration cfg = CU.transactionConfiguration(ctx, cctx.kernalContext().config());

    return txStart0(concurrency,
        isolation,
        cfg.getDefaultTxTimeout(),
        0,
        ctx.systemTx() ? ctx : null);
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:IgniteTransactionsImpl.java

示例9: checkPolicy0

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/**
 * Tests preset eviction policy.
 *
 * @throws Exception If failed.
 */
private void checkPolicy0() throws Exception {
    for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
        txConcurrency = concurrency;

        for (TransactionIsolation isolation : TransactionIsolation.values()) {
            txIsolation = isolation;

            Ignite g = startGrids();

            IgniteCache<String, String> cache = g.cache(DEFAULT_CACHE_NAME);

            try {
                info(">>> Checking policy [txConcurrency=" + txConcurrency + ", txIsolation=" + txIsolation +
                    ", plc=" + plc + ", nearPlc=" + nearPlc + ']');

                checkExplicitTx(g, cache);

                checkImplicitTx(cache);
            }
            finally {
                stopAllGrids();
            }
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:GridCacheEmptyEntriesAbstractSelfTest.java

示例10: testNotMapped

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/**
 * @param client Ignite client.
 */
private void testNotMapped(IgniteEx client, TransactionConcurrency concurrency, TransactionIsolation isolation) {
    IgniteCache cache2 = client.cache(CACHE2);
    IgniteCache cache1 = client.cache(CACHE).withKeepBinary();

    try(Transaction tx = client.transactions().txStart(concurrency, isolation)) {

        Map<String, Integer> param = new TreeMap<>();
        param.put(TEST_KEY + 1, 1);
        param.put(TEST_KEY + 1, 3);
        param.put(TEST_KEY, 3);

        cache1.put(TEST_KEY, 3);

        cache1.putAll(param);
        cache2.putAll(param);

        tx.commit();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:NotMappedPartitionInTxTest.java

示例11: checkReadThroughGetAndInvoke

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/**
 * @param cache Cache.
 * @param key Key.
 * @param concurrency Transaction concurrency.
 * @param isolation Transaction isolation.
 * @throws Exception If failed.
 */
private void checkReadThroughGetAndInvoke(IgniteCache<Object, Object> cache,
    Object key,
    TransactionConcurrency concurrency,
    TransactionIsolation isolation) throws Exception {
    putDataInStore(Collections.singletonMap(key, key), cache.getName());

    try (Transaction tx = cache.unwrap(Ignite.class).transactions().txStart(concurrency, isolation)) {
        cache.get(key);

        Object ret = cache.invoke(key, new TestEntryProcessor());

        assertEquals(key, ret);

        tx.commit();
    }

    checkValue(cache.getName(), key, (Integer)key + 1);
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:IgniteCacheInvokeReadThroughAbstractTest.java

示例12: 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);
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:GridCacheInterceptorAbstractSelfTest.java

示例13: testStoreSessionTx

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testStoreSessionTx() throws Exception {
    testTxPut(jcache(0), null, null);

    testTxPut(ignite(0).cache(CACHE_NAME1), null, null);

    testTxRemove(null, null);

    testTxPutRemove(null, null);

    for (TransactionConcurrency concurrency : F.asList(PESSIMISTIC)) {
        for (TransactionIsolation isolation : F.asList(REPEATABLE_READ)) {
            testTxPut(jcache(0), concurrency, isolation);

            testTxRemove(concurrency, isolation);

            testTxPutRemove(concurrency, isolation);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:IgniteCacheTxStoreSessionTest.java

示例14: deactivateWithPendingTransaction

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
/**
 * @throws Exception if failed.
 */
private void deactivateWithPendingTransaction(TransactionConcurrency concurrency,
    TransactionIsolation isolation) throws Exception {
    final Ignite ignite0 = grid(0);

    final IgniteCache<Object, Object> cache0 = ignite0.cache(CACHE_NAME);

    try (Transaction tx = ignite0.transactions().txStart(concurrency, isolation)) {
        cache0.put(1, "1");

        GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() {
            @Override public Object call() throws Exception {
                grid(0).active(false);

                return null;
            }
        }, IgniteException.class,
            "Failed to deactivate cluster (must invoke the method outside of an active transaction or lock).");
    }

    assertNull(cache0.get(1));
    assertNull(ignite0.transactions().tx());
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:ClusterStateAbstractTest.java

示例15: createConfig

import org.apache.ignite.transactions.TransactionIsolation; //导入依赖的package包/类
private IgniteConfiguration createConfig() {
	IgniteConfiguration config = new IgniteConfiguration();
	config.setClientMode( false );
	BinaryConfiguration binaryConfiguration = new BinaryConfiguration();
	binaryConfiguration.setNameMapper( new BinaryBasicNameMapper( true ) );
	binaryConfiguration.setCompactFooter( false );		// it is necessary only for embedded collections (@ElementCollection)
	config.setBinaryConfiguration( binaryConfiguration );
	TransactionConfiguration transactionConfiguration = new TransactionConfiguration();
	transactionConfiguration.setDefaultTxConcurrency( TransactionConcurrency.OPTIMISTIC );
	transactionConfiguration.setDefaultTxIsolation( TransactionIsolation.READ_COMMITTED );
	config.setTransactionConfiguration( transactionConfiguration );

	return config;
}
 
开发者ID:hibernate,项目名称:hibernate-ogm-ignite,代码行数:15,代码来源:IgniteTestConfigurationBuilder.java


注:本文中的org.apache.ignite.transactions.TransactionIsolation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。