org.ehcache.transactions.xa.journal
Class TransientJournal<K>

java.lang.Object
  extended by org.ehcache.transactions.xa.journal.TransientJournal<K>
All Implemented Interfaces:
Journal<K>
Direct Known Subclasses:
PersistentJournal

public class TransientJournal<K>
extends java.lang.Object
implements Journal<K>

An in-memory only Journal implementation.


Nested Class Summary
protected static class TransientJournal.Entry<K>
           
 
Field Summary
protected  ConcurrentHashMap<TransactionId,TransientJournal.Entry<K>> states
           
 
Constructor Summary
TransientJournal()
           
 
Method Summary
 void close()
          Close the journal.
 void forget(TransactionId transactionId)
          Forget a transaction that was terminated upon a heuristic decision.
 java.util.Collection<K> getInDoubtKeys(TransactionId transactionId)
          Get a Collection of keys modified by a transaction still in-doubt.
 java.util.Map<TransactionId,java.lang.Boolean> heuristicDecisions()
          Recover the state of all transactions that were terminated upon a heuristic decision.
 boolean isHeuristicallyTerminated(TransactionId transactionId)
          Check if a transaction has been terminated by a heuristic decision.
 boolean isInDoubt(TransactionId transactionId)
          Check if a transaction has been saved as in-doubt.
 void open()
          Open the journal.
 java.util.Map<TransactionId,java.util.Collection<K>> recover()
          Recover the state of all in-doubt transactions.
 void saveCommitted(TransactionId transactionId, boolean heuristicDecision)
          Save that a transaction has committed.
 void saveInDoubt(TransactionId transactionId, java.util.Collection<K> inDoubtKeys)
          Save that a transaction is in-doubt.
 void saveRolledBack(TransactionId transactionId, boolean heuristicDecision)
          Save that a transaction has rolled back.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

states

protected final ConcurrentHashMap<TransactionId,TransientJournal.Entry<K>> states
Constructor Detail

TransientJournal

public TransientJournal()
Method Detail

saveCommitted

public void saveCommitted(TransactionId transactionId,
                          boolean heuristicDecision)
Description copied from interface: Journal
Save that a transaction has committed.

Specified by:
saveCommitted in interface Journal<K>
Parameters:
transactionId - the ID of the transaction.
heuristicDecision - true if the state change is being done upon a heuristic decision.

saveRolledBack

public void saveRolledBack(TransactionId transactionId,
                           boolean heuristicDecision)
Description copied from interface: Journal
Save that a transaction has rolled back.

Specified by:
saveRolledBack in interface Journal<K>
Parameters:
transactionId - the ID of the transaction.
heuristicDecision - true if the state change is being done upon a heuristic decision.

saveInDoubt

public void saveInDoubt(TransactionId transactionId,
                        java.util.Collection<K> inDoubtKeys)
Description copied from interface: Journal
Save that a transaction is in-doubt.

Specified by:
saveInDoubt in interface Journal<K>
Parameters:
transactionId - the ID of the transaction.
inDoubtKeys - a Collection of keys modified by the transaction.

isInDoubt

public boolean isInDoubt(TransactionId transactionId)
Description copied from interface: Journal
Check if a transaction has been saved as in-doubt.

Specified by:
isInDoubt in interface Journal<K>
Parameters:
transactionId - the ID of the transaction.
Returns:
true if the transaction is in-doubt.

getInDoubtKeys

public java.util.Collection<K> getInDoubtKeys(TransactionId transactionId)
Description copied from interface: Journal
Get a Collection of keys modified by a transaction still in-doubt.

Specified by:
getInDoubtKeys in interface Journal<K>
Parameters:
transactionId - the ID of the transaction.
Returns:
a Collection of keys modified by the transaction.

recover

public java.util.Map<TransactionId,java.util.Collection<K>> recover()
Description copied from interface: Journal
Recover the state of all in-doubt transactions.

Specified by:
recover in interface Journal<K>
Returns:
a map using the transaction ID as the key and the state as value.

isHeuristicallyTerminated

public boolean isHeuristicallyTerminated(TransactionId transactionId)
Description copied from interface: Journal
Check if a transaction has been terminated by a heuristic decision.

Specified by:
isHeuristicallyTerminated in interface Journal<K>
Parameters:
transactionId - the ID of the transaction.
Returns:
true if the transaction has been terminated by a heuristic decision.

forget

public void forget(TransactionId transactionId)
Description copied from interface: Journal
Forget a transaction that was terminated upon a heuristic decision.

Specified by:
forget in interface Journal<K>
Parameters:
transactionId - the Id of the transaction.

heuristicDecisions

public java.util.Map<TransactionId,java.lang.Boolean> heuristicDecisions()
Description copied from interface: Journal
Recover the state of all transactions that were terminated upon a heuristic decision.

Specified by:
heuristicDecisions in interface Journal<K>
Returns:
a map using the transaction ID as the key and the value true if the state is committed, false if it is rolled back.

open

public void open()
          throws java.io.IOException
Description copied from interface: Journal
Open the journal.

Specified by:
open in interface Journal<K>
Throws:
java.io.IOException - if there was an error opening the journal.

close

public void close()
           throws java.io.IOException
Description copied from interface: Journal
Close the journal.

Specified by:
close in interface Journal<K>
Throws:
java.io.IOException - if there was an error closing the journal.