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;
}
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;
}
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;
}
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;
}
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);
}
}
}
}
Aggregations