|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.derby.impl.store.raw.xact.TransactionTable
public class TransactionTable
The transaction table is used by the transaction factory to keep track of
all transactions that are in the system.
The transction table serves the following purposes:
During recovery, there is only one real xact object doing all the recovery work, but there could be many outstanding transactions that are gleamed from the log. Each of these "recovery transactions" have its on entry into the transaction table but they all share the same Xact object.
Multithreading considerations:
TransactionTable must be MT-safe it is called upon by many threads
simultaneously (except during recovery)
This class depends on Hashtable synchronization!!
| Field Summary | |
|---|---|
private TransactionId |
largestUpdateXactId
|
private java.util.Hashtable |
trans
|
| Constructor Summary | |
|---|---|
TransactionTable()
MT - not needed for constructor |
|
| Method Summary | |
|---|---|
(package private) void |
add(Xact xact,
boolean exclude)
|
void |
addUpdateTransaction(TransactionId tid,
RawTransaction tran,
int transactionStatus)
Change a transaction to update or add an update transaction to this table. |
(package private) boolean |
findAndAssumeTransaction(TransactionId id,
RawTransaction tran)
Find a transaction using the transaction id, and make the passed in transaction assume the identity and properties of that transaction. |
ContextManager |
findTransactionContextByGlobalId(GlobalXactId global_id)
Find a transaction in the table by Global transaction id. |
private TransactionTableEntry |
findTransactionEntry(TransactionId id)
generic methods called by all clients of transaction table Must be MT -safe |
LogInstant |
getFirstLogInstant()
Get the least recently added (oldest) transaction |
boolean |
getMostRecentPreparedRecoveredXact(RawTransaction tran)
Get the most recent recovered prepared transaction. |
boolean |
getMostRecentRollbackFirstTransaction(RawTransaction tran)
Get the most recently added transaction that says it needs to be rolled back first (an InternalXact) from the transaction table and make the passed in transaction assume its identity. |
boolean |
getMostRecentTransactionForRollback(RawTransaction tran)
Get the most recently non-prepared added transaction from the transaction table and make the passed in transaction assume its identity. |
java.util.Hashtable |
getTableForXA()
Return the hash table to the XA layer. |
TransactionInfo[] |
getTransactionInfo()
Get a printable version of the transaction table |
int |
getTypeFormatId()
Return my format identifier. |
(package private) boolean |
hasActiveUpdateTransaction()
Return true if there is no transaction actively updating the database. |
boolean |
hasPreparedRecoveredXact()
Is there a prepared transaction that are recovered durring the recovery in the transaction table. |
boolean |
hasPreparedXact()
Is there a prepared transaction in the transaction table. |
private boolean |
hasPreparedXact(boolean recovered)
Is there a prepared transaction in the transaction table. |
boolean |
hasRollbackFirstTransaction()
Is there an active internal transaction in the transaction table. |
TransactionId |
largestUpdateXactId()
Return the largest update transactionId I have seen so far. |
(package private) void |
prepareTransaction(TransactionId id)
Change transaction to prepared. |
void |
readExternal(java.io.ObjectInput in)
|
(package private) boolean |
remove(TransactionId id)
remove the transaction Id an return false iff the transaction is found in the table and it doesn't need exclusion during quiesce state |
(package private) void |
removeUpdateTransaction(TransactionId id)
Change update transaction to non-update MT - MT safe, since vector is MT-safe. |
java.lang.String |
toString()
|
void |
writeExternal(java.io.ObjectOutput out)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private java.util.Hashtable trans
private TransactionId largestUpdateXactId
| Constructor Detail |
|---|
public TransactionTable()
| Method Detail |
|---|
private TransactionTableEntry findTransactionEntry(TransactionId id)
void add(Xact xact,
boolean exclude)
boolean remove(TransactionId id)
public void addUpdateTransaction(TransactionId tid,
RawTransaction tran,
int transactionStatus)
tid - the transaction idtran - the transaction to be addedtransactionStatus - the transaction status that is stored in the
BeginXact log recordvoid removeUpdateTransaction(TransactionId id)
MT - MT safe, since vector is MT-safe.
id - the transaction Idpublic java.util.Hashtable getTableForXA()
The XA code will do linear read-only operations on the hash table, write operations are only done in this module. It is a little ugly to export the hash table, but I wanted to move the XA specific code into the XA module, so that we could configure out the XA code if necessary.
Must be MT -safe, depends on sync hash table, and must get synchronized(hash_table) for linear searches.
void prepareTransaction(TransactionId id)
MT - unsafe, caller is recovery, which is single threaded.
id - the transaction Idpublic ContextManager findTransactionContextByGlobalId(GlobalXactId global_id)
This routine use to be only called during offline recovery so performance was not critical. Since that time more calls have been made, including one in startGlobalTransaction() so a linear search may no longer be appropriate. See DERBY-828.
global_id - The global transaction we are searching for.
boolean hasActiveUpdateTransaction()
MT - safe
public int getTypeFormatId()
getTypeFormatId in interface TypedFormat
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOException - problem reading the transaction table
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOException - problem reading the transaction table
java.lang.ClassNotFoundException - problem reading the transaction tablepublic TransactionId largestUpdateXactId()
MT - unsafe, caller is recovery, which is single threaded.
public boolean hasRollbackFirstTransaction()
MT - unsafe, caller is recovery, which is single threaded.
public boolean hasPreparedRecoveredXact()
MT - unsafe, caller is recovery, which is single threaded.
public boolean hasPreparedXact()
MT - unsafe, called during boot, which is single threaded.
private boolean hasPreparedXact(boolean recovered)
MT - unsafe, caller is recovery/at boot, which is single threaded.
recovered - true to search for transaction
that are in prepared during recovery.
recovered tranaction.
false > to search for just prepared
transactons.
- Returns:
true if there is a prepared transaction and
recovered when recovered argument is
true public boolean getMostRecentRollbackFirstTransaction(RawTransaction tran)
MT - unsafe, caller is recovery, which is single threaded.
public boolean getMostRecentTransactionForRollback(RawTransaction tran)
MT - unsafe, caller is recovery, which is single threaded.
public boolean getMostRecentPreparedRecoveredXact(RawTransaction tran)
Get the most recently added transaction that says it is prepared during recovery the transaction table and make the passed in transaction assume its identity.
This routine, unlike the redo and rollback getMostRecent*() routines expects a brand new transaction to be passed in. If a candidate transaction is found, then upon return the transaction table will be altered such that the old entry no longer exists, and a new entry will exist pointing to the transaction passed in. The new entry will look the same as if the prepared transaction had been created during runtime rather than recovery. Should only be used in recovery handle prepare after undo !!
MT - unsafe, caller is recovery, which is single threaded.
tran - Newly allocated transaction to add to link to a entry.
public LogInstant getFirstLogInstant()
MT - safe, caller can be recovery or checkpoint
boolean findAndAssumeTransaction(TransactionId id,
RawTransaction tran)
MT - unsafe, caller is recovery, which is single threaded.
id - transaction Idtran - the transaction that was made to assume the transactionID
and all other relavent information stored in the transaction table
public TransactionInfo[] getTransactionInfo()
public java.lang.String toString()
toString in class java.lang.Object
|
Built on Wed 2009-11-25 18:43:31-0800, from revision 884373 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||