Search in sources :

Example 1 with PerCacheTxTable

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();
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) ServerTransactionOriginatorChecker(org.infinispan.server.hotrod.tx.ServerTransactionOriginatorChecker) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) PerCacheTxTable(org.infinispan.server.hotrod.tx.table.PerCacheTxTable) TransactionOriginatorChecker(org.infinispan.transaction.impl.TransactionOriginatorChecker) ServerTransactionOriginatorChecker(org.infinispan.server.hotrod.tx.ServerTransactionOriginatorChecker)

Example 2 with PerCacheTxTable

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());
    }
}
Also used : PerCacheTxTable(org.infinispan.server.hotrod.tx.table.PerCacheTxTable) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) GlobalTxTable(org.infinispan.server.hotrod.tx.table.GlobalTxTable)

Example 3 with PerCacheTxTable

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());
    }
}
Also used : PerCacheTxTable(org.infinispan.server.hotrod.tx.table.PerCacheTxTable) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) GlobalTxTable(org.infinispan.server.hotrod.tx.table.GlobalTxTable)

Example 4 with PerCacheTxTable

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());
        }
    }
}
Also used : PerCacheTxTable(org.infinispan.server.hotrod.tx.table.PerCacheTxTable)

Example 5 with PerCacheTxTable

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);
    }
}
Also used : EmbeddedTransaction(org.infinispan.transaction.tm.EmbeddedTransaction) CacheXid(org.infinispan.server.hotrod.tx.table.CacheXid) SetCompletedTransactionFunction(org.infinispan.server.hotrod.tx.table.functions.SetCompletedTransactionFunction) TxFunction(org.infinispan.server.hotrod.tx.table.functions.TxFunction) PerCacheTxTable(org.infinispan.server.hotrod.tx.table.PerCacheTxTable) GlobalTxTable(org.infinispan.server.hotrod.tx.table.GlobalTxTable)

Aggregations

PerCacheTxTable (org.infinispan.server.hotrod.tx.table.PerCacheTxTable)5 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 GlobalTxTable (org.infinispan.server.hotrod.tx.table.GlobalTxTable)3 Configuration (org.infinispan.configuration.cache.Configuration)1 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)1 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)1 ServerTransactionOriginatorChecker (org.infinispan.server.hotrod.tx.ServerTransactionOriginatorChecker)1 CacheXid (org.infinispan.server.hotrod.tx.table.CacheXid)1 SetCompletedTransactionFunction (org.infinispan.server.hotrod.tx.table.functions.SetCompletedTransactionFunction)1 TxFunction (org.infinispan.server.hotrod.tx.table.functions.TxFunction)1 TransactionOriginatorChecker (org.infinispan.transaction.impl.TransactionOriginatorChecker)1 EmbeddedTransaction (org.infinispan.transaction.tm.EmbeddedTransaction)1