com.sun.jini.outrigger
Class TxnTable

java.lang.Object
  extended by com.sun.jini.outrigger.TxnTable

 class TxnTable
extends Object

Keeps a mapping from TransactionManager/id pairs, to Txn objects. Some Txns may be broken, that is the TransactionManager they are associated with can not be unmarshalled and prepared, and thus can't currently be used (but may be usable in the future).

Since:
2.0
Author:
Sun Microsystems, Inc.

Nested Class Summary
private  class TxnTable.Key
          Key class for the primary map (from manager/id pairs to Txn s.
 
Field Summary
private  Map brokenTxns
          Map of transaction ids to the List of broken Txn objects that have the id.
private static Logger logger
          The logger to use
private  ProxyPreparer proxyPreparer
          ProxyPreparer to use when unpacking transactions, may be null.
private static Txn[] txnArray
          An array of type Txn to pass to toArray
private  Map txns
          Map of manager,id pairs (represented as Keyss) to non-broken Txns.
 
Constructor Summary
TxnTable(ProxyPreparer proxyPreparer)
          Create a new TxnTable.
 
Method Summary
(package private)  Txn get(TransactionManager manager, long id)
          Given a TransactionManager, manager, and a transaction id, return the associated Txn, or null if there is no Txn for this manager/id pair.
(package private)  Txn put(ServerTransaction tr)
          Atomically test if there is a Txn for the specified ServerTransaction in the table, creating a new Txn, and place in table if there is not.
private  void put(Txn txn)
          Used to put a formally broken Txn in the main table.
(package private)  void recover(Txn txn)
          Restore a Txn in the table as part of log recovery.
(package private)  void remove(TransactionManager manager, long id)
          Remove the mapping for the given TransactionManager, id pair.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

txns

private final Map txns
Map of manager,id pairs (represented as Keyss) to non-broken Txns. Only Keys that have their prepared flag set should go in this Map.


brokenTxns

private Map brokenTxns
Map of transaction ids to the List of broken Txn objects that have the id. null if there are no broken Txns.


proxyPreparer

private final ProxyPreparer proxyPreparer
ProxyPreparer to use when unpacking transactions, may be null.


txnArray

private static final Txn[] txnArray
An array of type Txn to pass to toArray


logger

private static final Logger logger
The logger to use

Constructor Detail

TxnTable

TxnTable(ProxyPreparer proxyPreparer)
Create a new TxnTable.

Parameters:
proxyPreparer - the proxy preparer to use on recovered TransactionManagers.
Method Detail

get

Txn get(TransactionManager manager,
        long id)
  throws IOException,
         ClassNotFoundException
Given a TransactionManager, manager, and a transaction id, return the associated Txn, or null if there is no Txn for this manager/id pair. The only method this method will call on manager is hashCode. The returned Txn object will not be broken.

Parameters:
manager - a TransactionManager.
id - a transaction id.
Returns:
the Txn for the specified pair or null if none can be found.
Throws:
IOException - if there was one or more possible matches, but they are broken and the attempt to unpack them yielded an IOException.
ClassNotFoundException - if there was one or more possible matches, but they are broken and the attempt to unpack them yielded a ClassNotFoundException.
SecurityException - if there was one or more possible matches, but they are broken and the attempt to unpack them yielded a SecurityException.

put

Txn put(ServerTransaction tr)
Atomically test if there is a Txn for the specified ServerTransaction in the table, creating a new Txn, and place in table if there is not. If there is already a Txn for the specified ServerTransaction return the existing one, otherwise return the new one. Does not check for matches against broken txns.

Parameters:
tr - ServerTransaction to add to the table. The contained manager proxy should already been prepared
Returns:
the Txn for tr.

put

private void put(Txn txn)
Used to put a formally broken Txn in the main table. Only puts it in the table if it is not already their.

Parameters:
txn - the Txn being moved, should have been prepared

recover

void recover(Txn txn)
Restore a Txn in the table as part of log recovery. An attempt will be made unpack and prepare the transaction manager. The Txn may be broken. This method is not synchronized.

Parameters:
txn - the Txn being recovered.

remove

void remove(TransactionManager manager,
            long id)
Remove the mapping for the given TransactionManager, id pair. Will not remove broken Txns.

Parameters:
manager - the TransactionManager for transaction being removed.
id - the manager assigned to the transaction being removed.


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.