Search in sources :

Example 11 with TransactionConfiguration

use of org.apache.ignite.configuration.TransactionConfiguration in project ignite by apache.

the class GridPartitionedCacheJtaFactorySelfTest method configureJta.

/** {@inheritDoc} */
@Override
protected void configureJta(IgniteConfiguration cfg) {
    TransactionConfiguration txCfg = cfg.getTransactionConfiguration();
    txCfg.setTxManagerFactory(new Factory<TransactionManager>() {

        private static final long serialVersionUID = 0L;

        @Override
        public TransactionManager create() {
            return jotm.getTransactionManager();
        }
    });
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) TransactionManager(org.objectweb.transaction.jta.TransactionManager)

Example 12 with TransactionConfiguration

use of org.apache.ignite.configuration.TransactionConfiguration in project ignite by apache.

the class CacheKeepBinaryTransactionTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    TransactionConfiguration txCfg = new TransactionConfiguration();
    txCfg.setDefaultTxConcurrency(TransactionConcurrency.OPTIMISTIC);
    txCfg.setDefaultTxIsolation(TransactionIsolation.REPEATABLE_READ);
    cfg.setTransactionConfiguration(txCfg);
    cfg.setMarshaller(new BinaryMarshaller());
    CacheConfiguration ccfg = new CacheConfiguration("tx-cache");
    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cfg.setCacheConfiguration(ccfg);
    return cfg;
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 13 with TransactionConfiguration

use of org.apache.ignite.configuration.TransactionConfiguration in project ignite by apache.

the class GridCacheAbstractPartitionedByteArrayValuesSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TransactionConfiguration tCfg = new TransactionConfiguration();
    tCfg.setTxSerializableEnabled(true);
    cfg.setTransactionConfiguration(tCfg);
    return cfg;
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration)

Example 14 with TransactionConfiguration

use of org.apache.ignite.configuration.TransactionConfiguration in project ignite by apache.

the class GridCacheAdapter method asyncOp.

/**
 * @param op Cache operation.
 * @param <T> Return type.
 * @return Future.
 */
@SuppressWarnings("unchecked")
private <T> IgniteInternalFuture<T> asyncOp(final AsyncOp<T> op) {
    try {
        checkJta();
    } catch (IgniteCheckedException e) {
        return new GridFinishedFuture<>(e);
    }
    if (log.isDebugEnabled())
        log.debug("Performing async op: " + op);
    GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx);
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    final TransactionConfiguration txCfg = CU.transactionConfiguration(ctx, ctx.kernalContext().config());
    if (tx == null || tx.implicit()) {
        // Save value of thread-local flag.
        boolean skipStore = ctx.skipStore();
        int retries = opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES;
        if (retries == 1) {
            tx = ctx.tm().newTx(true, op.single(), ctx.systemTx() ? ctx : null, OPTIMISTIC, READ_COMMITTED, txCfg.getDefaultTxTimeout(), !skipStore, 0);
            return asyncOp(tx, op, opCtx, /*retry*/
            false);
        } else {
            AsyncOpRetryFuture<T> fut = new AsyncOpRetryFuture<>(op, retries, opCtx);
            fut.execute(/*retry*/
            false);
            return fut;
        }
    } else
        return asyncOp(tx, op, opCtx, /*retry*/
        false);
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) BROADCAST(org.apache.ignite.internal.GridClosureCallMode.BROADCAST) IGNITE_CACHE_RETRIES_COUNT(org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_RETRIES_COUNT) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)

Example 15 with TransactionConfiguration

use of org.apache.ignite.configuration.TransactionConfiguration in project ignite by apache.

the class IgniteTransactionsImpl method txStartEx.

/**
 * {@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);
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration)

Aggregations

TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)28 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)14 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)10 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)9 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)6 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)4 TransactionManager (org.objectweb.transaction.jta.TransactionManager)4 HashMap (java.util.HashMap)3 Transaction (javax.transaction.Transaction)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)3 LinkedHashMap (java.util.LinkedHashMap)2 IGNITE_CACHE_RETRIES_COUNT (org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_RETRIES_COUNT)2 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)2 AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)2 BROADCAST (org.apache.ignite.internal.GridClosureCallMode.BROADCAST)2 PlatformDotNetBinaryConfiguration (org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration)2 NoopEventStorageSpi (org.apache.ignite.spi.eventstorage.NoopEventStorageSpi)2