if (DEBUG) {
logger.log(Logger.INFO, "Load transaction ack "+ta[i]+" [TUID="+tid+"]");
}
ConsumerUID cuid = ta[i].getConsumerUID();
ConsumerUID scuid = ta[i].getStoredConsumerUID();
SysMessageID sysid = ta[i].getSysMessageID();
Map imap = (Map)inprocessAcks.get(sysid);
if (scuid == null) {
logger.log(Logger.WARNING,"Internal Error: " +
" Unable to locate stored ConsumerUID :" + ta);
scuid = cuid;
if (ta == null) {
logger.log(Logger.WARNING, "Internal Error: "
+ " no consumerUID stored w/ the transaction:"
+ ta);
continue;
}
}
if (imap == null) {
imap = new HashMap();
inprocessAcks.put(sysid, imap);
}
imap.put(scuid, tid);
if (openTransactions.get(tid) != null) {
TransactionInformation ti = (TransactionInformation)translist.get(tid);
if (ti == null) {
logger.log(Logger.INFO, "Unable to retrieve "
+ " transaction information " + ti +
" for " + tid +
" we may be clearing the transaction");
continue;
}
if (openTransactions.get(tid) == Boolean.TRUE) {
ti.addConsumedMessage(sysid, cuid, scuid);
}
ti.addOrphanAck(sysid, scuid);
}
}
} catch (Exception ex) {
logger.logStack(Logger.WARNING,
BrokerResources.E_INTERNAL_BROKER_ERROR,
"Error parsing transaction ", ex);
}
}
{
Object[] args = { Integer.valueOf(prepareCN), Integer.valueOf(commitWaitCN) };
logger.log(logger.INFO, Globals.getBrokerResources().getKString(
BrokerResources.I_NCLUSTER_TRANS, args));
}
HashMap remoteTrans = store.getAllRemoteTransactionStates();
// list of transactions which need to be cleaned up
HashSet clearRemoteTrans = new HashSet(remoteTrans.size());
int prepareRN = 0, rollbackRN = 0, commitRN = 0, completeRN = 0;
itr = remoteTrans.entrySet().iterator();
while (itr.hasNext()) {
try {
Map.Entry entry = (Map.Entry)itr.next();
TransactionUID tid = (TransactionUID)entry.getKey();
TransactionState ts = (TransactionState)entry.getValue();
TransactionAcknowledgement ta[] = store.getTransactionAcks(tid);
int state = ts.getState();
if (DEBUG) {
logger.log(Logger.INFO, "Load remote transaction: TUID="+tid+
"["+TransactionState.toString(state)+
(ts.getCreationTime() == 0 ? "":" createTime="+ts.getCreationTime())+"]");
}
switch (state) {
case TransactionState.CREATED:
clearRemoteTrans.add(tid);
rollbackRN++;
break;
case TransactionState.PREPARED:
prepareRN++;
logRemoteTransaction(tid, ts, ta,
store.getRemoteTransactionHomeBroker(tid), true, true, false);
openTransactions.put(tid, Boolean.TRUE);
break;
case TransactionState.COMPLETE:
if (Globals.getHAEnabled() && ta != null && ta.length > 0) {
completeRN++;
ts.setState(TransactionState.PREPARED);
logRemoteTransaction(tid, ts, ta,
store.getRemoteTransactionHomeBroker(tid), true, true, false);
openTransactions.put(tid, Boolean.TRUE);
break;
}
case TransactionState.STARTED:
case TransactionState.ROLLEDBACK:
case TransactionState.FAILED:
case TransactionState.INCOMPLETE:
openTransactions.put(tid, Boolean.FALSE);
clearRemoteTrans.add(tid);
rollbackRN++;
break;
case TransactionState.COMMITTED:
commitRN++;
logRemoteTransaction(tid, ts, ta,
store.getRemoteTransactionHomeBroker(tid), true, true, false);
committingTransactions.put(tid, "");
break;
default:
logger.log(logger.ERROR,
"Internal Error unexpected transaction state:"+
TransactionState.toString(state)+ " TUID="+tid+", set to PREPARED");
logRemoteTransaction(tid, ts, ta,
store.getRemoteTransactionHomeBroker(tid), true, true, false);
updateRemoteTransactionState(tid, TransactionState.PREPARED, true, true, true);
openTransactions.put(tid, Boolean.TRUE);
}
for (int i=0; i < ta.length; i ++) {
if (DEBUG) {
logger.log(Logger.INFO, "Load remote transaction ack "+ta[i]+" [TUID="+tid+"]");
}
ConsumerUID cuid = ta[i].getConsumerUID();
ConsumerUID scuid = ta[i].getStoredConsumerUID();
SysMessageID sysid = ta[i].getSysMessageID();
Map imap = (Map)inprocessAcks.get(sysid);
if (scuid == null) {
logger.log(Logger.WARNING,"Internal Error: " +
" Unable to locate stored ConsumerUID :" + ta);
scuid =cuid;