Search in sources :

Example 21 with TransactionConfiguration

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

the class GridCacheEvictionTouchSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    TransactionConfiguration txCfg = c.getTransactionConfiguration();
    txCfg.setDefaultTxConcurrency(PESSIMISTIC);
    txCfg.setDefaultTxIsolation(REPEATABLE_READ);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(REPLICATED);
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setEvictionPolicy(plc);
    cc.setOnheapCacheEnabled(true);
    CacheStore store = new GridCacheGenericTestStore<Object, Object>() {

        @Override
        public Object load(Object key) {
            return key;
        }

        @Override
        public Map<Object, Object> loadAll(Iterable<?> keys) {
            Map<Object, Object> loaded = new HashMap<>();
            for (Object key : keys) loaded.put(key, key);
            return loaded;
        }
    };
    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);
    c.setCacheConfiguration(cc);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    return c;
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) GridCacheGenericTestStore(org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) HashMap(java.util.HashMap) CacheStore(org.apache.ignite.cache.store.CacheStore) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 22 with TransactionConfiguration

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

the class IgnitePdsTransactionsHangTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(discoSpi);
    BinaryConfiguration binaryCfg = new BinaryConfiguration();
    binaryCfg.setCompactFooter(false);
    cfg.setBinaryConfiguration(binaryCfg);
    cfg.setPeerClassLoadingEnabled(true);
    TcpCommunicationSpi tcpCommSpi = new TcpCommunicationSpi();
    tcpCommSpi.setSharedMemoryPort(-1);
    cfg.setCommunicationSpi(tcpCommSpi);
    TransactionConfiguration txCfg = new TransactionConfiguration();
    txCfg.setDefaultTxIsolation(TransactionIsolation.READ_COMMITTED);
    cfg.setTransactionConfiguration(txCfg);
    DataRegionConfiguration memPlcCfg = new DataRegionConfiguration();
    memPlcCfg.setName("dfltDataRegion");
    memPlcCfg.setInitialSize(PAGE_CACHE_SIZE * 1024 * 1024);
    memPlcCfg.setMaxSize(PAGE_CACHE_SIZE * 1024 * 1024);
    memPlcCfg.setPersistenceEnabled(true);
    DataStorageConfiguration memCfg = new DataStorageConfiguration();
    memCfg.setDefaultDataRegionConfiguration(memPlcCfg);
    memCfg.setWalHistorySize(1);
    memCfg.setCheckpointFrequency(CHECKPOINT_FREQUENCY);
    memCfg.setPageSize(PAGE_SIZE * 1024);
    cfg.setDataStorageConfiguration(memCfg);
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 23 with TransactionConfiguration

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

the class IgniteCacheTxIteratorSelfTest method getConfiguration.

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

Example 24 with TransactionConfiguration

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

the class GridCacheReplicatedTxMultiThreadedSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings({ "unchecked" })
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    TransactionConfiguration tCfg = new TransactionConfiguration();
    tCfg.setTxSerializableEnabled(true);
    c.setTransactionConfiguration(tCfg);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(REPLICATED);
    cc.setEvictionPolicy(null);
    cc.setWriteSynchronizationMode(FULL_SYNC);
    c.setCacheConfiguration(cc);
    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(ipFinder);
    c.setDiscoverySpi(spi);
    if (CACHE_DEBUG)
        resetLog4j(Level.DEBUG, LOG_TO_FILE, GridCacheProcessor.class.getPackage().getName());
    return c;
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridCacheProcessor(org.apache.ignite.internal.processors.cache.GridCacheProcessor) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 25 with TransactionConfiguration

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

the class CacheJtaManager method checkJta.

/**
 * {@inheritDoc}
 */
@Override
public void checkJta() throws IgniteCheckedException {
    if (jtaTm == null) {
        try {
            CacheTmLookup tmLookup = tmLookupRef.get();
            if (tmLookup == null)
                return;
            jtaTm = tmLookup.getTm();
        } catch (Exception e) {
            throw new IgniteCheckedException("Failed to get transaction manager: " + e, e);
        }
    }
    if (jtaTm != null) {
        CacheJtaResource rsrc = this.rsrc.get();
        if (rsrc == null || rsrc.isFinished() || rsrc.cacheTx().state() == SUSPENDED) {
            try {
                Transaction jtaTx = jtaTm.getTransaction();
                if (jtaTx != null) {
                    GridNearTxLocal tx = cctx.tm().userTx();
                    if (tx == null) {
                        TransactionConfiguration tCfg = cctx.kernalContext().config().getTransactionConfiguration();
                        tx = cctx.tm().newTx(/*implicit*/
                        false, /*implicit single*/
                        false, null, tCfg.getDefaultTxConcurrency(), tCfg.getDefaultTxIsolation(), tCfg.getDefaultTxTimeout(), /*store enabled*/
                        true, /*tx size*/
                        0);
                    }
                    rsrc = new CacheJtaResource(tx, cctx.kernalContext());
                    if (useJtaSync)
                        jtaTx.registerSynchronization(rsrc);
                    else if (!jtaTx.enlistResource(rsrc))
                        throw new IgniteCheckedException("Failed to enlist XA resource to JTA user transaction.");
                    this.rsrc.set(rsrc);
                }
            } catch (SystemException e) {
                throw new IgniteCheckedException("Failed to obtain JTA transaction.", e);
            } catch (RollbackException e) {
                throw new IgniteCheckedException("Failed to enlist XAResource to JTA transaction.", e);
            }
        }
    }
}
Also used : TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) RollbackException(javax.transaction.RollbackException) CacheTmLookup(org.apache.ignite.cache.jta.CacheTmLookup) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) SystemException(javax.transaction.SystemException) RollbackException(javax.transaction.RollbackException)

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