Search in sources :

Example 1 with GlobalTxTable

use of org.infinispan.server.hotrod.tx.table.GlobalTxTable in project infinispan by infinispan.

the class LifecycleCallbacks method createGlobalTxTable.

private synchronized void createGlobalTxTable(EmbeddedCacheManager cacheManager) {
    if (!registered) {
        Cache<CacheXid, TxState> cache = cacheManager.getCache(GLOBAL_TX_TABLE_CACHE_NAME);
        GlobalTxTable txTable = new GlobalTxTable(cache, globalComponentRegistry);
        globalComponentRegistry.registerComponent(txTable, GlobalTxTable.class);
        registered = true;
    }
}
Also used : CacheXid(org.infinispan.server.hotrod.tx.table.CacheXid) TxState(org.infinispan.server.hotrod.tx.table.TxState) GlobalTxTable(org.infinispan.server.hotrod.tx.table.GlobalTxTable)

Example 2 with GlobalTxTable

use of org.infinispan.server.hotrod.tx.table.GlobalTxTable in project infinispan by infinispan.

the class TransactionRequestProcessor method forgetTransaction.

void forgetTransaction(HotRodHeader header, Subject subject, XidImpl xid) {
    // TODO authentication?
    GlobalTxTable txTable = SecurityActions.getGlobalComponentRegistry(server.getCacheManager()).getComponent(GlobalTxTable.class);
    executor.execute(() -> {
        try {
            txTable.forgetTransaction(xid);
            writeSuccess(header);
        } catch (Throwable t) {
            writeException(header, t);
        }
    });
}
Also used : GlobalTxTable(org.infinispan.server.hotrod.tx.table.GlobalTxTable)

Example 3 with GlobalTxTable

use of org.infinispan.server.hotrod.tx.table.GlobalTxTable in project infinispan by infinispan.

the class TxReaperAndRecoveryTest method initGlobalTxTable.

private void initGlobalTxTable(int index, XidImpl xid, Address address, boolean recoverable, Status status) {
    GlobalTxTable globalTxTable = globalTxTable(index);
    CacheXid cacheXid = new CacheXid(fromString(cacheName()), xid);
    List<TxFunction> functions = new ArrayList<>(5);
    GlobalTransaction gtx = address == null ? newGlobalTransaction(cacheName(), index) : newGlobalTransaction(cacheName(), index, address);
    switch(status) {
        case ACTIVE:
            functions.add(new CreateStateFunction(gtx, recoverable, 1));
            break;
        case PREPARING:
            functions.add(new CreateStateFunction(gtx, recoverable, 1));
            functions.add(new PreparingDecisionFunction(Collections.emptyList()));
            break;
        case PREPARED:
            functions.add(new CreateStateFunction(gtx, recoverable, 1));
            functions.add(new PreparingDecisionFunction(Collections.emptyList()));
            functions.add(new SetPreparedFunction());
            break;
        case MARK_ROLLBACK:
            functions.add(new CreateStateFunction(gtx, recoverable, 1));
            functions.add(new PreparingDecisionFunction(Collections.emptyList()));
            functions.add(new SetPreparedFunction());
            functions.add(new SetDecisionFunction(false));
            break;
        case MARK_COMMIT:
            functions.add(new CreateStateFunction(gtx, recoverable, 1));
            functions.add(new PreparingDecisionFunction(Collections.emptyList()));
            functions.add(new SetPreparedFunction());
            functions.add(new SetDecisionFunction(true));
            break;
        case ROLLED_BACK:
            functions.add(new CreateStateFunction(gtx, recoverable, 1));
            functions.add(new PreparingDecisionFunction(Collections.emptyList()));
            functions.add(new SetPreparedFunction());
            functions.add(new SetDecisionFunction(false));
            functions.add(new SetCompletedTransactionFunction(false));
            break;
        case COMMITTED:
            functions.add(new CreateStateFunction(gtx, recoverable, 1));
            functions.add(new PreparingDecisionFunction(Collections.emptyList()));
            functions.add(new SetPreparedFunction());
            functions.add(new SetDecisionFunction(true));
            functions.add(new SetCompletedTransactionFunction(true));
            break;
        default:
            throw new IllegalStateException();
    }
    for (TxFunction function : functions) {
        assertEquals(Status.OK, globalTxTable.update(cacheXid, function, 30000));
    }
    assertEquals(status, globalTxTable.getState(cacheXid).getStatus());
}
Also used : CacheXid(org.infinispan.server.hotrod.tx.table.CacheXid) SetCompletedTransactionFunction(org.infinispan.server.hotrod.tx.table.functions.SetCompletedTransactionFunction) ArrayList(java.util.ArrayList) GlobalTransaction(org.infinispan.transaction.xa.GlobalTransaction) TxFunction(org.infinispan.server.hotrod.tx.table.functions.TxFunction) CreateStateFunction(org.infinispan.server.hotrod.tx.table.functions.CreateStateFunction) PreparingDecisionFunction(org.infinispan.server.hotrod.tx.table.functions.PreparingDecisionFunction) GlobalTxTable(org.infinispan.server.hotrod.tx.table.GlobalTxTable) SetDecisionFunction(org.infinispan.server.hotrod.tx.table.functions.SetDecisionFunction) SetPreparedFunction(org.infinispan.server.hotrod.tx.table.functions.SetPreparedFunction)

Example 4 with GlobalTxTable

use of org.infinispan.server.hotrod.tx.table.GlobalTxTable in project infinispan by infinispan.

the class TransactionRequestProcessor method getPreparedTransactions.

void getPreparedTransactions(HotRodHeader header, Subject subject) {
    // TODO authentication?
    if (log.isTraceEnabled()) {
        log.trace("Fetching transactions for recovery");
    }
    executor.execute(() -> {
        try {
            GlobalTxTable txTable = SecurityActions.getGlobalComponentRegistry(server.getCacheManager()).getComponent(GlobalTxTable.class);
            Collection<XidImpl> preparedTx = txTable.getPreparedTransactions();
            writeResponse(header, createRecoveryResponse(header, preparedTx));
        } catch (Throwable t) {
            writeException(header, t);
        }
    });
}
Also used : XidImpl(org.infinispan.commons.tx.XidImpl) GlobalTxTable(org.infinispan.server.hotrod.tx.table.GlobalTxTable)

Example 5 with GlobalTxTable

use of org.infinispan.server.hotrod.tx.table.GlobalTxTable 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)

Aggregations

GlobalTxTable (org.infinispan.server.hotrod.tx.table.GlobalTxTable)9 CacheXid (org.infinispan.server.hotrod.tx.table.CacheXid)5 PerCacheTxTable (org.infinispan.server.hotrod.tx.table.PerCacheTxTable)3 TxState (org.infinispan.server.hotrod.tx.table.TxState)3 TxFunction (org.infinispan.server.hotrod.tx.table.functions.TxFunction)3 XidImpl (org.infinispan.commons.tx.XidImpl)2 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)2 CreateStateFunction (org.infinispan.server.hotrod.tx.table.functions.CreateStateFunction)2 SetCompletedTransactionFunction (org.infinispan.server.hotrod.tx.table.functions.SetCompletedTransactionFunction)2 ArrayList (java.util.ArrayList)1 RemoteTransaction (org.infinispan.server.hotrod.test.RemoteTransaction)1 PreparingDecisionFunction (org.infinispan.server.hotrod.tx.table.functions.PreparingDecisionFunction)1 SetDecisionFunction (org.infinispan.server.hotrod.tx.table.functions.SetDecisionFunction)1 SetPreparedFunction (org.infinispan.server.hotrod.tx.table.functions.SetPreparedFunction)1 EmbeddedTransaction (org.infinispan.transaction.tm.EmbeddedTransaction)1 GlobalTransaction (org.infinispan.transaction.xa.GlobalTransaction)1