Search in sources :

Example 1 with RecoveryManager

use of org.infinispan.transaction.xa.recovery.RecoveryManager in project infinispan by infinispan.

the class TxCompletionNotificationCommand method invokeAsync.

@Override
public CompletionStage<?> invokeAsync(ComponentRegistry componentRegistry) throws Throwable {
    if (log.isTraceEnabled())
        log.tracef("Processing completed transaction %s", gtx);
    RemoteTransaction remoteTx = null;
    RecoveryManager recoveryManager = componentRegistry.getRecoveryManager().running();
    if (recoveryManager != null) {
        // recovery in use
        if (xid != null) {
            remoteTx = (RemoteTransaction) recoveryManager.removeRecoveryInformation(xid);
        } else {
            remoteTx = (RemoteTransaction) recoveryManager.removeRecoveryInformation(internalId);
        }
    }
    if (remoteTx == null && gtx != null) {
        TransactionTable txTable = componentRegistry.getTransactionTableRef().running();
        remoteTx = txTable.removeRemoteTransaction(gtx);
    }
    if (remoteTx == null)
        return CompletableFutures.completedNull();
    forwardCommandRemotely(componentRegistry.getStateTransferManager(), remoteTx);
    LockManager lockManager = componentRegistry.getLockManager().running();
    lockManager.unlockAll(remoteTx.getLockedKeys(), remoteTx.getGlobalTransaction());
    return CompletableFutures.completedNull();
}
Also used : RecoveryManager(org.infinispan.transaction.xa.recovery.RecoveryManager) LockManager(org.infinispan.util.concurrent.locks.LockManager) RemoteTransaction(org.infinispan.transaction.impl.RemoteTransaction) TransactionTable(org.infinispan.transaction.impl.TransactionTable)

Example 2 with RecoveryManager

use of org.infinispan.transaction.xa.recovery.RecoveryManager in project infinispan by infinispan.

the class ForgetTest method createCacheManagers.

@Override
protected void createCacheManagers() throws Throwable {
    ConfigurationBuilder configuration = defaultRecoveryConfig();
    createCluster(configuration, 2);
    waitForClusterToForm();
    XaTransactionTable txTable = tt(0);
    PostCommitRecoveryStateTest.RecoveryManagerDelegate recoveryManager = new PostCommitRecoveryStateTest.RecoveryManagerDelegate(TestingUtil.extractComponent(cache(0), RecoveryManager.class));
    TestingUtil.replaceField(recoveryManager, "recoveryManager", txTable, XaTransactionTable.class);
}
Also used : RecoveryManager(org.infinispan.transaction.xa.recovery.RecoveryManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) PostCommitRecoveryStateTest(org.infinispan.tx.recovery.PostCommitRecoveryStateTest) XaTransactionTable(org.infinispan.transaction.xa.XaTransactionTable)

Example 3 with RecoveryManager

use of org.infinispan.transaction.xa.recovery.RecoveryManager in project infinispan by infinispan.

the class SimpleCacheRecoveryAdminTest method checkProperlyCleanup.

@Override
protected void checkProperlyCleanup(final int managerIndex) {
    eventually(() -> TestingUtil.extractLockManager(cache(managerIndex, "test")).getNumberOfLocksHeld() == 0);
    final TransactionTable tt = TestingUtil.extractComponent(cache(managerIndex, "test"), TransactionTable.class);
    eventuallyEquals(0, tt::getRemoteTxCount);
    eventuallyEquals(0, tt::getLocalTxCount);
    final RecoveryManager rm = TestingUtil.extractComponent(cache(managerIndex, "test"), RecoveryManager.class);
    eventually(() -> rm.getInDoubtTransactions().size() == 0);
    eventually(() -> rm.getPreparedTransactionsFromCluster().all().length == 0);
}
Also used : RecoveryManager(org.infinispan.transaction.xa.recovery.RecoveryManager) TransactionTable(org.infinispan.transaction.impl.TransactionTable)

Example 4 with RecoveryManager

use of org.infinispan.transaction.xa.recovery.RecoveryManager in project infinispan by infinispan.

the class PrepareCommand method createContext.

@Override
public RemoteTxInvocationContext createContext(ComponentRegistry componentRegistry) {
    RecoveryManager recoveryManager = componentRegistry.getRecoveryManager().running();
    if (recoveryManager != null && recoveryManager.isTransactionPrepared(globalTx)) {
        log.tracef("The transaction %s is already prepared. Skipping prepare call.", globalTx);
        return null;
    }
    // 1. first create a remote transaction (or get the existing one)
    TransactionTable txTable = componentRegistry.getTransactionTableRef().running();
    RemoteTransaction remoteTransaction = txTable.getOrCreateRemoteTransaction(globalTx, modifications);
    // LockControlCommand with null modifications.
    if (hasModifications()) {
        remoteTransaction.setModifications(Arrays.asList(modifications));
    }
    // 2. then set it on the invocation context
    InvocationContextFactory icf = componentRegistry.getInvocationContextFactory().running();
    return icf.createRemoteTxInvocationContext(remoteTransaction, getOrigin());
}
Also used : RecoveryManager(org.infinispan.transaction.xa.recovery.RecoveryManager) RemoteTransaction(org.infinispan.transaction.impl.RemoteTransaction) TransactionTable(org.infinispan.transaction.impl.TransactionTable) InvocationContextFactory(org.infinispan.context.InvocationContextFactory)

Example 5 with RecoveryManager

use of org.infinispan.transaction.xa.recovery.RecoveryManager in project infinispan by infinispan.

the class GetInDoubtTransactionsCommand method invokeAsync.

@Override
public CompletionStage<?> invokeAsync(ComponentRegistry componentRegistry) throws Throwable {
    RecoveryManager recoveryManager = componentRegistry.getRecoveryManager().running();
    List<XidImpl> localInDoubtTransactions = recoveryManager.getInDoubtTransactions();
    log.tracef("Returning result %s", localInDoubtTransactions);
    return CompletableFuture.completedFuture(localInDoubtTransactions);
}
Also used : RecoveryManager(org.infinispan.transaction.xa.recovery.RecoveryManager) XidImpl(org.infinispan.commons.tx.XidImpl)

Aggregations

RecoveryManager (org.infinispan.transaction.xa.recovery.RecoveryManager)7 TransactionTable (org.infinispan.transaction.impl.TransactionTable)4 RemoteTransaction (org.infinispan.transaction.impl.RemoteTransaction)2 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)1 XidImpl (org.infinispan.commons.tx.XidImpl)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 InvocationContextFactory (org.infinispan.context.InvocationContextFactory)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 InternalCacheRegistry (org.infinispan.registry.InternalCacheRegistry)1 XaTransactionTable (org.infinispan.transaction.xa.XaTransactionTable)1 RecoveryAwareTransactionTable (org.infinispan.transaction.xa.recovery.RecoveryAwareTransactionTable)1 PostCommitRecoveryStateTest (org.infinispan.tx.recovery.PostCommitRecoveryStateTest)1 LockManager (org.infinispan.util.concurrent.locks.LockManager)1