use of org.infinispan.server.hotrod.tx.table.PerCacheTxTable in project infinispan by infinispan.
the class LifecycleCallbacks method registerServerTransactionTable.
/**
* Registers the {@link PerCacheTxTable} to a transactional cache.
*/
private void registerServerTransactionTable(ComponentRegistry componentRegistry, String cacheName) {
// skip for global tx table and non-transactional cache
if (GLOBAL_TX_TABLE_CACHE_NAME.equals(cacheName) || !componentRegistry.getComponent(Configuration.class).transaction().transactionMode().isTransactional()) {
return;
}
EmbeddedCacheManager cacheManager = globalComponentRegistry.getComponent(EmbeddedCacheManager.class);
createGlobalTxTable(cacheManager);
// TODO We need a way for a module to install a factory before the default implementation is instantiated
BasicComponentRegistry basicComponentRegistry = componentRegistry.getComponent(BasicComponentRegistry.class);
basicComponentRegistry.replaceComponent(PerCacheTxTable.class.getName(), new PerCacheTxTable(cacheManager.getAddress()), true);
basicComponentRegistry.replaceComponent(TransactionOriginatorChecker.class.getName(), new ServerTransactionOriginatorChecker(), true);
componentRegistry.rewire();
}
use of org.infinispan.server.hotrod.tx.table.PerCacheTxTable in project infinispan by infinispan.
the class TopologyChangeFunctionalTest method assertServerTransactionTableEmpty.
private void assertServerTransactionTableEmpty() {
for (Cache<?, ?> cache : caches(cacheName())) {
PerCacheTxTable perCacheTxTable = extractComponent(cache, PerCacheTxTable.class);
assertTrue(perCacheTxTable.isEmpty());
}
for (EmbeddedCacheManager cm : managers()) {
GlobalTxTable globalTxTable = extractGlobalComponent(cm, GlobalTxTable.class);
assertTrue(globalTxTable.isEmpty());
}
}
use of org.infinispan.server.hotrod.tx.table.PerCacheTxTable in project infinispan by infinispan.
the class TxFunctionalTest method assertServerTransactionTableEmpty.
private void assertServerTransactionTableEmpty() {
for (Cache<?, ?> cache : caches(cacheName())) {
PerCacheTxTable perCacheTxTable = extractComponent(cache, PerCacheTxTable.class);
assertTrue(perCacheTxTable.isEmpty());
}
for (EmbeddedCacheManager cm : managers()) {
GlobalTxTable globalTxTable = extractGlobalComponent(cm, GlobalTxTable.class);
assertTrue(globalTxTable.isEmpty());
}
}
use of org.infinispan.server.hotrod.tx.table.PerCacheTxTable in project infinispan by infinispan.
the class ServerConfigurationTest method assertServerTransactionTableEmpty.
private void assertServerTransactionTableEmpty(String cacheName) {
for (Cache<?, ?> cache : caches(cacheName)) {
if (cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) {
PerCacheTxTable perCacheTxTable = extractComponent(cache, PerCacheTxTable.class);
assertTrue(perCacheTxTable.isEmpty());
}
}
}
use of org.infinispan.server.hotrod.tx.table.PerCacheTxTable in project infinispan by infinispan.
the class Util method completeLocalTransaction.
private static void completeLocalTransaction(AdvancedCache<?, ?> cache, XidImpl xid, long timeout, boolean commit) throws HeuristicRollbackException, HeuristicMixedException, RollbackException {
PerCacheTxTable perCacheTxTable = cache.getComponentRegistry().getComponent(PerCacheTxTable.class);
GlobalTxTable globalTxTable = cache.getComponentRegistry().getGlobalComponentRegistry().getComponent(GlobalTxTable.class);
try {
// local transaction
EmbeddedTransaction tx = perCacheTxTable.getLocalTx(xid);
tx.runCommit(!commit);
CacheXid cacheXid = new CacheXid(ByteString.fromString(cache.getName()), xid);
TxFunction function = new SetCompletedTransactionFunction(commit);
globalTxTable.update(cacheXid, function, timeout);
} finally {
perCacheTxTable.removeLocalTx(xid);
}
}
Aggregations