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