throws TransactionLogException, ResourceManagerException {
ExternalXid txid = new ExternalXid(xid);
switch (state.getOrd()) {
case TransactionState.OPENED_ORD:
{
TransactionLog log = getCurrentTransactionLog();
addTridLogEntry(txid, log);
log.logTransactionState(txid, _txExpiryTime * 1000, _rid,
state);
// cache the transaction state
_activeTransactions.put(txid, new LinkedList());
}
break;
case TransactionState.PREPARED_ORD:
// cache the transaction state
LinkedList list = (LinkedList) _activeTransactions.get(txid);
if (list != null) {
list.add(state);
} else {
throw new ResourceManagerException("Trasaction " + txid +
" is not active.");
}
break;
case TransactionState.CLOSED_ORD:
{
TransactionLog log = getTransactionLog(txid);
log.logTransactionState(txid, _txExpiryTime * 1000, _rid,
state);
removeTridLogEntry(txid, log);
// check whether this log has anymore open transactions
synchronized (_cacheLock) {
if ((_logToTridCache.get(log) == null) &&
(!isCurrentTransactionLog(log))) {
log.close();
// now check if gc mode is GC_SYNCHRONOUS. If it is
// remove the log file
if (_gcMode == GC_SYNCHRONOUS) {
try {
log.destroy();
} catch (TransactionLogException exception) {
exception.printStackTrace();
}
}
}