Package bitronix.tm.recovery
Class Recoverer
java.lang.Object
bitronix.tm.recovery.Recoverer
- All Implemented Interfaces:
RecovererMBean,Service,Runnable
Recovery process implementation. Here is Mike Spille's description of XA recovery:
Straight Line Recovery:
- 1. Find transactions that the TM considers dangling and unresolved
- 2. Find and reconstitute any
XAResources which were being used when chunk blowing occured. - 3. Call the
recover()method on each of theseXAResources. - 4. Throw out any
Xid's in theXAResource' recover lists which are not owned by this TM. - 5. Correlate
Xid's that the TM knows about with remainingXid's that theXAResources reported. - 6. For
XAResourceXid's that match the global transaction ID which the TM found dangling with a "Committing..." record, callcommit()on thoseXAResources for thoseXids. - 7. For
XAResourceXid's that do not match any dangling "Committing..." records, callrollback()on thoseXAResources for thoseXids.
- 1. For any
rollback()calls from step 6 which reported a Heuristic Commit, you are in danger or doubt, so run in circles, scream and shout. - 2. For any
commit()calls from step 7 which reported a Heuristic Rollback, you are in danger or doubt, so run in circles, scream and shout. - 3. For any resource you can't reconstitute in in step #2, or who fails on recover in step #3, or who reports anything like an XAER_RMFAILURE in step 6 or step 7, keep trying to contact them in some implementation defined manner.
- 4. For any heuristic outcome you see reported from an XAResource, call
forget()for thatXAResource/Xidpair so that the resource can stop holding onto a reference to that transaction
To achieve this, Recoverer must have access to all previously used resources, even if the journal contains
no trace of some of them. There are two ways of achieving this: either you use the ResourceLoader to configure
all your resources and everything will be working automatically or by making sure resources are re-created and re-registered.
Those are the three steps of the Bitronix implementation:
- call
recover()on all known resources (Mike's steps 1 to 5) - commit dangling COMMITTING transactions (Mike's step 6)
- rollback any remaining recovered transaction (Mike's step 7)
- Author:
- lorban
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet the amount of transactions committed during the last recovery run.Get the exception reported when recovery failed.intGet how many times the recoverer has run since the transaction manager started.intGet the amount of transactions rolled back during the last recovery run.booleanCheck if the recoverer currently is running.voidrun()Run the recovery process.voidshutdown()Shutdown the service and free all held resources.
-
Constructor Details
-
Recoverer
public Recoverer()
-
-
Method Details
-
shutdown
public void shutdown()Description copied from interface:ServiceShutdown the service and free all held resources. -
run
public void run()Run the recovery process. This method is automatically called by the transaction manager, you should never call it manually.- Specified by:
runin interfaceRecovererMBean- Specified by:
runin interfaceRunnable
-
getCompletionException
Get the exception reported when recovery failed.- Specified by:
getCompletionExceptionin interfaceRecovererMBean- Returns:
- the exception that made recovery fail or null if last recovery execution was successful.
-
getCommittedCount
public int getCommittedCount()Get the amount of transactions committed during the last recovery run.- Specified by:
getCommittedCountin interfaceRecovererMBean- Returns:
- the amount of committed transactions.
-
getRolledbackCount
public int getRolledbackCount()Get the amount of transactions rolled back during the last recovery run.- Specified by:
getRolledbackCountin interfaceRecovererMBean- Returns:
- the amount of rolled back transactions.
-
getExecutionsCount
public int getExecutionsCount()Get how many times the recoverer has run since the transaction manager started.- Specified by:
getExecutionsCountin interfaceRecovererMBean- Returns:
- how many times the recoverer has run since the transaction manager started.
-
isRunning
public boolean isRunning()Check if the recoverer currently is running.- Specified by:
isRunningin interfaceRecovererMBean- Returns:
- true if the recoverer currently is running, false otherwise.
-