Class RecoveryManagerImpl
- java.lang.Object
-
- org.infinispan.transaction.xa.recovery.RecoveryManagerImpl
-
- All Implemented Interfaces:
RecoveryManager
public class RecoveryManagerImpl extends Object implements RecoveryManager
Default implementation forRecoveryManager
- Since:
- 5.0
- Author:
- Mircea.Markus@jboss.com
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.transaction.xa.recovery.RecoveryManager
RecoveryManager.InDoubtTxInfo, RecoveryManager.RecoveryIterator
-
-
Constructor Summary
Constructors Constructor Description RecoveryManagerImpl(ConcurrentMap<RecoveryInfoKey,RecoveryAwareRemoteTransaction> recoveryHolder, String cacheName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
forceTransactionCompletion(Xid xid, boolean commit)
Replays the given transaction by re-running the prepare and commit.String
forceTransactionCompletionFromCluster(Xid xid, Address where, boolean commit)
This method invokesRecoveryManager.forceTransactionCompletion(javax.transaction.xa.Xid, boolean)
on the specified node.Set<RecoveryManager.InDoubtTxInfo>
getInDoubtTransactionInfo()
Same asRecoveryManager.getInDoubtTransactionInfoFromCluster()
, but only returns transactions from the local node.Set<RecoveryManager.InDoubtTxInfo>
getInDoubtTransactionInfoFromCluster()
Returns aSet
containing all the in-doubt transactions from the cluster, including the local node.List<Xid>
getInDoubtTransactions()
Local call that returns a list containing:ConcurrentMap<RecoveryInfoKey,RecoveryAwareRemoteTransaction>
getInDoubtTransactionsMap()
RecoveryAwareRemoteTransaction
getPreparedTransaction(Xid xid)
Local call returning the remote transaction identified by the supplied xid or null.RecoveryManager.RecoveryIterator
getPreparedTransactionsFromCluster()
Returns the list of transactions in prepared state from both local and remote cluster nodes.void
init(RpcManager rpcManager, org.infinispan.commands.CommandsFactory commandsFactory, org.infinispan.factories.impl.ComponentRef<org.infinispan.transaction.impl.TransactionTable> txTable, org.infinispan.transaction.impl.TransactionCoordinator txCoordinator, TransactionFactory txFactory)
boolean
isTransactionPrepared(GlobalTransaction globalTx)
Checks both internal state and transaction table's state for the given tx.void
registerInDoubtTransaction(RecoveryAwareRemoteTransaction remoteTransaction)
RecoveryAwareTransaction
removeRecoveryInformation(Long internalId)
Same asRecoveryManager.removeRecoveryInformation(javax.transaction.xa.Xid)
but identifies the tx by its internal id.void
removeRecoveryInformation(Collection<Address> lockOwners, Xid xid, boolean sync, GlobalTransaction gtx, boolean fromCluster)
Removes from the specified nodes (or all nodes if the value of 'where' is null) the recovery information associated with these Xids.RecoveryAwareTransaction
removeRecoveryInformation(Xid xid)
Remove recovery information stored on this node (doesn't involve rpc).void
removeRecoveryInformationFromCluster(Collection<Address> where, long internalId, boolean sync)
Same asRecoveryManager.removeRecoveryInformation(java.util.Collection, javax.transaction.xa.Xid, boolean, org.infinispan.transaction.xa.GlobalTransaction, boolean)
but the transaction is identified by its internal id, and not by its xid.
-
-
-
Constructor Detail
-
RecoveryManagerImpl
public RecoveryManagerImpl(ConcurrentMap<RecoveryInfoKey,RecoveryAwareRemoteTransaction> recoveryHolder, String cacheName)
-
-
Method Detail
-
init
public void init(RpcManager rpcManager, org.infinispan.commands.CommandsFactory commandsFactory, org.infinispan.factories.impl.ComponentRef<org.infinispan.transaction.impl.TransactionTable> txTable, org.infinispan.transaction.impl.TransactionCoordinator txCoordinator, TransactionFactory txFactory)
-
getPreparedTransactionsFromCluster
public RecoveryManager.RecoveryIterator getPreparedTransactionsFromCluster()
Description copied from interface:RecoveryManager
Returns the list of transactions in prepared state from both local and remote cluster nodes. Implementation can take advantage of several optimisations:- in order to get all tx from the cluster a broadcast is performed. This can be performed only once (assuming the call is successful), the first time this method is called. After that a local, cached list of tx prepared on this node is returned.
- during the broadcast just return the list of prepared transactions that are not originated on other active nodes of the cluster.
- Specified by:
getPreparedTransactionsFromCluster
in interfaceRecoveryManager
-
removeRecoveryInformation
public void removeRecoveryInformation(Collection<Address> lockOwners, Xid xid, boolean sync, GlobalTransaction gtx, boolean fromCluster)
Description copied from interface:RecoveryManager
Removes from the specified nodes (or all nodes if the value of 'where' is null) the recovery information associated with these Xids.- Specified by:
removeRecoveryInformation
in interfaceRecoveryManager
- Parameters:
lockOwners
- on which nodes should this be executed.xid
- the list of xids to be removed.sync
- execute sync or async (false)gtx
- the global transaction
-
removeRecoveryInformationFromCluster
public void removeRecoveryInformationFromCluster(Collection<Address> where, long internalId, boolean sync)
Description copied from interface:RecoveryManager
Same asRecoveryManager.removeRecoveryInformation(java.util.Collection, javax.transaction.xa.Xid, boolean, org.infinispan.transaction.xa.GlobalTransaction, boolean)
but the transaction is identified by its internal id, and not by its xid.- Specified by:
removeRecoveryInformationFromCluster
in interfaceRecoveryManager
-
removeRecoveryInformation
public RecoveryAwareTransaction removeRecoveryInformation(Xid xid)
Description copied from interface:RecoveryManager
Remove recovery information stored on this node (doesn't involve rpc).- Specified by:
removeRecoveryInformation
in interfaceRecoveryManager
- See Also:
#removeRecoveryInformation(java.util.Collection, javax.transaction.xa.Xid, boolean)
-
removeRecoveryInformation
public RecoveryAwareTransaction removeRecoveryInformation(Long internalId)
Description copied from interface:RecoveryManager
Same asRecoveryManager.removeRecoveryInformation(javax.transaction.xa.Xid)
but identifies the tx by its internal id.- Specified by:
removeRecoveryInformation
in interfaceRecoveryManager
-
getInDoubtTransactions
public List<Xid> getInDoubtTransactions()
Description copied from interface:RecoveryManager
Local call that returns a list containing:- all the remote transactions prepared on this node for which the originator(i.e. the node where the tx stared) is no longer part of the cluster. AND - all the locally originated transactions which are prepared and for which the commit failed
- Specified by:
getInDoubtTransactions
in interfaceRecoveryManager
- See Also:
RecoveryAwareRemoteTransaction.isInDoubt()
-
getInDoubtTransactionInfo
public Set<RecoveryManager.InDoubtTxInfo> getInDoubtTransactionInfo()
Description copied from interface:RecoveryManager
Same asRecoveryManager.getInDoubtTransactionInfoFromCluster()
, but only returns transactions from the local node.- Specified by:
getInDoubtTransactionInfo
in interfaceRecoveryManager
-
getInDoubtTransactionInfoFromCluster
public Set<RecoveryManager.InDoubtTxInfo> getInDoubtTransactionInfoFromCluster()
Description copied from interface:RecoveryManager
Returns aSet
containing all the in-doubt transactions from the cluster, including the local node. This does not include transactions that are prepared successfully and for which the originator is still in the cluster.- Specified by:
getInDoubtTransactionInfoFromCluster
in interfaceRecoveryManager
- See Also:
RecoveryManager.InDoubtTxInfo
-
registerInDoubtTransaction
public void registerInDoubtTransaction(RecoveryAwareRemoteTransaction remoteTransaction)
- Specified by:
registerInDoubtTransaction
in interfaceRecoveryManager
-
getPreparedTransaction
public RecoveryAwareRemoteTransaction getPreparedTransaction(Xid xid)
Description copied from interface:RecoveryManager
Local call returning the remote transaction identified by the supplied xid or null.- Specified by:
getPreparedTransaction
in interfaceRecoveryManager
-
forceTransactionCompletion
public String forceTransactionCompletion(Xid xid, boolean commit)
Description copied from interface:RecoveryManager
Replays the given transaction by re-running the prepare and commit. This call expects the transaction to exist on this node either as a local or remote transaction.- Specified by:
forceTransactionCompletion
in interfaceRecoveryManager
- Parameters:
xid
- tx to commit or rollbackcommit
- if true tx is committed, if false it is rolled back
-
forceTransactionCompletionFromCluster
public String forceTransactionCompletionFromCluster(Xid xid, Address where, boolean commit)
Description copied from interface:RecoveryManager
This method invokesRecoveryManager.forceTransactionCompletion(javax.transaction.xa.Xid, boolean)
on the specified node.- Specified by:
forceTransactionCompletionFromCluster
in interfaceRecoveryManager
-
isTransactionPrepared
public boolean isTransactionPrepared(GlobalTransaction globalTx)
Description copied from interface:RecoveryManager
Checks both internal state and transaction table's state for the given tx. If it finds it, returns true if tx is prepared.- Specified by:
isTransactionPrepared
in interfaceRecoveryManager
-
getInDoubtTransactionsMap
public ConcurrentMap<RecoveryInfoKey,RecoveryAwareRemoteTransaction> getInDoubtTransactionsMap()
-
-