org.infinispan.transaction.xa.recovery
Class RecoveryManagerImpl

java.lang.Object
  extended by org.infinispan.transaction.xa.recovery.RecoveryManagerImpl
All Implemented Interfaces:
RecoveryManager

public class RecoveryManagerImpl
extends Object
implements RecoveryManager

Default implementation for RecoveryManager

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
RecoveryManagerImpl(ConcurrentMap<RecoveryInfoKey,RecoveryAwareRemoteTransaction> recoveryHolder, String cacheName)
           
 
Method Summary
 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 invokes RecoveryManager.forceTransactionCompletion(javax.transaction.xa.Xid, boolean) on the specified node.
 Set<RecoveryManager.InDoubtTxInfo> getInDoubtTransactionInfo()
          Same as RecoveryManager.getInDoubtTransactionInfoFromCluster(), but only returns transactions from the local node.
 Set<RecoveryManager.InDoubtTxInfo> getInDoubtTransactionInfoFromCluster()
          Returns a Set 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, CommandsFactory commandsFactory, TransactionTable txTable, 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)
           
 void removeRecoveryInformation(Long internalId)
          Same as RecoveryManager.removeRecoveryInformation(javax.transaction.xa.Xid) but identifies the tx by its internal id.
 void removeRecoveryInformation(Xid xid)
          Remove recovery information stored on this node (doesn't involve rpc).
 void removeRecoveryInformationFromCluster(Collection<Address> where, long internalId, boolean sync)
          Same as #removeRecoveryInformationFromCluster(java.util.Collection but the transaction is identified by its internal id, and not by its xid.
 void removeRecoveryInformationFromCluster(Collection<Address> lockOwners, Xid xid, boolean sync)
          Removes from the specified nodes (or all nodes if the value of 'where' is null) the recovery information associated with these Xids.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecoveryManagerImpl

public RecoveryManagerImpl(ConcurrentMap<RecoveryInfoKey,RecoveryAwareRemoteTransaction> recoveryHolder,
                           String cacheName)
Method Detail

init

public void init(RpcManager rpcManager,
                 CommandsFactory commandsFactory,
                 TransactionTable txTable,
                 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 interface RecoveryManager

removeRecoveryInformationFromCluster

public void removeRecoveryInformationFromCluster(Collection<Address> lockOwners,
                                                 Xid xid,
                                                 boolean sync)
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:
removeRecoveryInformationFromCluster in interface RecoveryManager
Parameters:
lockOwners - on which nodes should this be executed.
xid - the list of xids to be removed.
sync - execute sync or async (false)

removeRecoveryInformationFromCluster

public void removeRecoveryInformationFromCluster(Collection<Address> where,
                                                 long internalId,
                                                 boolean sync)
Description copied from interface: RecoveryManager
Same as #removeRecoveryInformationFromCluster(java.util.Collection but the transaction is identified by its internal id, and not by its xid.

Specified by:
removeRecoveryInformationFromCluster in interface RecoveryManager

removeRecoveryInformation

public void removeRecoveryInformation(Xid xid)
Description copied from interface: RecoveryManager
Remove recovery information stored on this node (doesn't involve rpc).

Specified by:
removeRecoveryInformation in interface RecoveryManager

removeRecoveryInformation

public void removeRecoveryInformation(Long internalId)
Description copied from interface: RecoveryManager
Same as RecoveryManager.removeRecoveryInformation(javax.transaction.xa.Xid) but identifies the tx by its internal id.

Specified by:
removeRecoveryInformation in interface RecoveryManager

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 interface RecoveryManager
See Also:
RecoveryAwareRemoteTransaction.isInDoubt()

getInDoubtTransactionInfo

public Set<RecoveryManager.InDoubtTxInfo> getInDoubtTransactionInfo()
Description copied from interface: RecoveryManager
Same as RecoveryManager.getInDoubtTransactionInfoFromCluster(), but only returns transactions from the local node.

Specified by:
getInDoubtTransactionInfo in interface RecoveryManager

getInDoubtTransactionInfoFromCluster

public Set<RecoveryManager.InDoubtTxInfo> getInDoubtTransactionInfoFromCluster()
Description copied from interface: RecoveryManager
Returns a Set 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 interface RecoveryManager
See Also:
RecoveryManager.InDoubtTxInfo

registerInDoubtTransaction

public void registerInDoubtTransaction(RecoveryAwareRemoteTransaction remoteTransaction)

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 interface RecoveryManager

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 interface RecoveryManager
Parameters:
xid - tx to commit or rollback
commit - 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 invokes RecoveryManager.forceTransactionCompletion(javax.transaction.xa.Xid, boolean) on the specified node.

Specified by:
forceTransactionCompletionFromCluster in interface RecoveryManager

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 interface RecoveryManager

getInDoubtTransactionsMap

public ConcurrentMap<RecoveryInfoKey,RecoveryAwareRemoteTransaction> getInDoubtTransactionsMap()

-->

Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.