use of com.sun.messaging.jmq.jmsserver.persist.api.LoadException in project openmq by eclipse-ee4j.
the class ClusterImpl method checkStoredLastConfigServer.
/**
* Check to see if stored last config server property loaded properly
*
* System.exit if the last config server info is corrupted the last refresh timestamp info is corrupted and unable to
* reset potentially last config server info is corrupted: store LoadPropertyException occurred with key corruption and
* LastConfigServer property does not in store
*
* In future release, the System.exit behavior may be changed to allow administratively repair - eg. through imqbrokerd
* option to force set last config server info to the current master broker
*/
private void checkStoredLastConfigServer() throws BrokerException {
Store s = Globals.getStore();
boolean bad = false;
boolean potentiallyBad = false;
LoadException le = s.getLoadPropertyException();
LoadException savele = null;
while (le != null) {
Object o = le.getKey();
if (o == null || !(o instanceof String)) {
potentiallyBad = true;
savele = le;
le = le.getNextException();
continue;
}
if (((String) o).equals(ClusterGlobals.STORE_PROPERTY_LASTCONFIGSERVER)) {
logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER, le);
bad = true;
break;
}
if (((String) o).equals(ClusterGlobals.STORE_PROPERTY_LASTREFRESHTIME)) {
logger.log(Logger.WARNING, BrokerResources.W_CLUSTER_LOAD_LASTREFRESHTIME, le);
try {
s.updateProperty(ClusterGlobals.STORE_PROPERTY_LASTREFRESHTIME, Long.valueOf(-1), false);
} catch (BrokerException e) {
logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_RESET_LASTREFRESHTIME, e);
bad = true;
break;
}
}
le = le.getNextException();
}
if (potentiallyBad && !bad) {
try {
if (s.getProperty(ClusterGlobals.STORE_PROPERTY_LASTCONFIGSERVER) == null) {
logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER, savele);
bad = true;
}
} catch (BrokerException e) {
logger.log(Logger.ERROR, e.getMessage(), e);
logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER, savele);
bad = true;
}
}
if (bad) {
logger.log(Logger.ERROR, BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER);
Broker.getBroker().exit(1, Globals.getBrokerResources().getKString(BrokerResources.E_CLUSTER_LOAD_LASTCONFIGSERVER), BrokerEvent.Type.FATAL_ERROR);
}
}
use of com.sun.messaging.jmq.jmsserver.persist.api.LoadException in project openmq by eclipse-ee4j.
the class DestinationList method loadDestinations.
private void loadDestinations() throws BrokerException {
synchronized (destinationListLock) {
if (destsLoaded) {
return;
}
destsLoaded = true;
}
logger.log(Logger.INFO, br.getKString(br.I_RETRIEVE_STORED_DESTINATIONS) + logsuffix);
// before we do anything else, make sure we dont have any
// unexpected exceptions
LoadException load_ex = pstore.getLoadDestinationException();
if (load_ex != null) {
// some messages could not be loaded
LoadException processing = load_ex;
while (processing != null) {
String destid = (String) processing.getKey();
Destination d = (Destination) processing.getValue();
if (destid == null && d == null) {
logger.log(Logger.WARNING, "LoadDestinationException: " + "Both key and value are corrupted");
continue;
}
if (destid == null) {
// store with valid key
try {
pstore.storeDestination(d, PERSIST_SYNC);
} catch (Exception ex) {
logger.log(Logger.WARNING, BrokerResources.W_DST_RECREATE_FAILED, d.toString(), ex);
try {
pstore.removeDestination(d, true);
} catch (Exception ex1) {
logger.logStack(Logger.DEBUG, "Unable to remove dest", ex1);
}
}
} else {
DestinationUID duid = new DestinationUID(destid);
String name = duid.getName();
boolean isqueue = duid.isQueue();
int type = isqueue ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC;
// if this is a temp destination etc
try {
d = createDestination(name, type);
d.store();
logger.log(Logger.WARNING, BrokerResources.W_DST_REGENERATE, duid.getLocalizedName());
} catch (Exception ex) {
logger.log(Logger.WARNING, BrokerResources.W_DST_REGENERATE_ERROR, duid, ex);
try {
if (duid.isQueue()) {
d = new Queue(duid);
} else {
d = new Topic(duid);
}
pstore.removeDestination(d, true);
} catch (Exception ex1) {
logger.logStack(Logger.DEBUG, "Unable to remove dest", ex1);
}
}
}
// end if
processing = processing.getNextException();
}
// end while
}
// retrieve stored destinations
try {
Destination[] dests = pstore.getAllDestinations();
logger.log(Logger.INFO, br.getKString(br.I_RETRIEVED_STORED_DESTINATIONS, String.valueOf(dests.length)) + logsuffix);
for (int i = 0; i < dests.length; i++) {
if (dests[i] == null) {
continue;
}
if (DEBUG) {
logger.log(Logger.INFO, "Process stored destination " + dests[i]);
}
dests[i].setDestinationList(this);
if (!dests[i].isAdmin() && (dests[i].getIsDMQ() || !dests[i].isInternal())) {
dests[i].initialize();
}
if (dests[i].isAutoCreated() && dests[i].size == 0 && dests[i].bytes == 0) {
destinationList.remove(dests[i].getDestinationUID());
try {
Globals.getLogger().log(logger.INFO, br.getKString(br.I_DESTROYING_DESTINATION, dests[i].getName()) + logsuffix);
dests[i].destroy(Globals.getBrokerResources().getString(BrokerResources.M_AUTO_REAPED) + logsuffix);
} catch (BrokerException ex) {
//
if (ex.getStatusCode() == Status.NOT_FOUND) {
// someone else removed it already
return;
}
throw ex;
}
} else {
addDestination(dests[i], false);
}
}
deadMessageQueue = createDMQ();
// iterate through and deal with monitors
Iterator itr = destinationList.values().iterator();
while (itr.hasNext()) {
Destination d = (Destination) itr.next();
try {
d.initMonitor();
} catch (IOException ex) {
logger.logStack(logger.INFO, BrokerResources.I_CANT_LOAD_MONITOR, d.toString(), ex);
itr.remove();
}
}
} catch (BrokerException ex) {
logger.logStack(Logger.ERROR, BrokerResources.X_LOAD_DESTINATIONS_FAILED, ex);
throw ex;
} catch (IOException ex) {
logger.logStack(Logger.ERROR, BrokerResources.X_LOAD_DESTINATIONS_FAILED, ex);
throw new BrokerException(BrokerResources.X_LOAD_DESTINATIONS_FAILED, ex);
}
}
use of com.sun.messaging.jmq.jmsserver.persist.api.LoadException in project openmq by eclipse-ee4j.
the class Subscription method initSubscriptions.
public static void initSubscriptions() {
Logger logger = Globals.getLogger();
logger.log(Logger.DEBUG, "Initializing consumers");
synchronized (Subscription.class) {
if (loaded) {
return;
}
loaded = true;
}
// before we do anything else, make sure we dont have any
// unexpected exceptions
LoadException load_ex = null;
try {
load_ex = Globals.getStore().getLoadConsumerException();
} catch (Exception ex) {
// nothing to do
logger.logStack(Logger.DEBUG, "Error loading consumer exception ", ex);
}
if (load_ex != null) {
// some messages could not be loaded
LoadException processing = load_ex;
while (processing != null) {
ConsumerUID cuid = (ConsumerUID) processing.getKey();
Consumer con = (Consumer) processing.getValue();
if (cuid == null && con == null) {
logger.log(Logger.WARNING, "LoadConsumerException: " + "Both key and value are corrupted");
continue;
}
if (cuid == null) {
// store with valid key
try {
Globals.getStore().storeInterest(con, true);
} catch (Exception ex) {
logger.log(Logger.WARNING, BrokerResources.W_CON_RECREATE_FAILED, con.getConsumerUID(), ex);
}
} else {
// nothing we can do, remove it
logger.log(Logger.WARNING, BrokerResources.W_CON_CORRUPT_REMOVE, cuid.toString());
try {
Consumer c = new Consumer(cuid);
Globals.getStore().removeInterest(c, false);
} catch (Exception ex) {
logger.logStack(Logger.DEBUG, "Error removing " + "corrupt consumer " + cuid, ex);
}
}
// end if
processing = processing.getNextException();
}
// end while
}
try {
Consumer[] cons = Globals.getStore().getAllInterests();
for (int i = 0; i < cons.length; i++) {
Consumer c = cons[i];
if (c == null) {
continue;
}
// at this point, we only store subscriptions
assert c instanceof Subscription;
Subscription s = (Subscription) c;
String clientID = s.getClientID();
if (clientID != null && clientID.length() == 0) {
clientID = null;
}
String durableName = s.getDurableName();
logger.log(Logger.INFO, Globals.getBrokerResources().getKString(BrokerResources.I_LOAD_STORED_DURA, getDSubLogString(clientID, durableName)) + "[" + s.getDestinationUID() + "]");
String key = getDSubKey(clientID, durableName);
if (durableList.get(key) != null) {
logger.log(Logger.WARNING, BrokerResources.E_INTERNAL_BROKER_ERROR, "The loaded durable subscription " + s + getDSubLogString(clientID, durableName) + " from store already exists " + durableList.get(key) + ", replace");
}
durableList.put(key, s);
DestinationUID duid = s.getDestinationUID();
DestinationList DL = Globals.getDestinationList();
LinkedHashSet dset = null;
Map<PartitionedStore, LinkedHashSet<Destination>> dmap = null;
if (duid.isWildcard()) {
wildcardConsumers.add(c.getConsumerUID());
dmap = DL.findMatchingDestinationMap(null, duid);
Iterator<LinkedHashSet<Destination>> itr = dmap.values().iterator();
while (itr.hasNext()) {
dset = itr.next();
if (dset == null) {
continue;
}
Iterator<Destination> itr1 = dset.iterator();
while (itr1.hasNext()) {
Destination d = itr1.next();
if (d == null) {
continue;
}
if (DEBUG) {
logger.log(logger.INFO, "Add loaded durable subscription " + s + " to destination " + d);
}
d.addConsumer(s, false);
}
}
} else {
Destination[] ds = DL.getDestination(null, duid.getName(), (duid.isQueue() ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC), true, true);
for (int j = 0; j < ds.length; j++) {
if (ds[j] == null) {
continue;
}
if (DEBUG) {
logger.log(logger.INFO, "Add loaded durable subscription " + s + " to destination " + ds[j]);
}
ds[j].addConsumer(s, false);
}
}
}
} catch (Exception ex) {
logger.logStack(Logger.ERROR, BrokerResources.E_LOAD_DURABLES, ex);
}
}
use of com.sun.messaging.jmq.jmsserver.persist.api.LoadException in project openmq by eclipse-ee4j.
the class TransactionList method loadTransactions.
public void loadTransactions() throws BrokerException, IOException {
// before we do anything else, make sure we dont have any
// unexpected exceptions
// FIRST ... look at transaction table (tid,state)
LoadException load_ex = pstore.getLoadTransactionException();
if (load_ex != null) {
// some messages could not be loaded
LoadException processing = load_ex;
while (processing != null) {
TransactionUID tid = (TransactionUID) processing.getKey();
TransactionInfo ti = (TransactionInfo) processing.getValue();
if (tid == null && ti == null) {
logger.log(Logger.WARNING, "LoadTransactionException: " + "Both key and value for a transactions entry" + " are corrupted with key exception " + processing.getKeyCause().getMessage() + " and value exception " + processing.getValueCause());
processing = processing.getNextException();
continue;
}
if (tid == null) {
// at this point, there is nothing we can do ...
// store with valid key
// improve when we address 5060661
logger.logStack(Logger.WARNING, BrokerResources.W_TRANS_ID_CORRUPT, ti.toString(), processing.getKeyCause());
processing = processing.getNextException();
continue;
}
if (ti == null) {
// if we dont know ... so make it prepared
logger.log(Logger.WARNING, Globals.getBrokerResources().getKString(BrokerResources.W_TRAN_INFO_CORRUPTED, tid.toString()));
TransactionState ts = new TransactionState(AutoRollbackType.NOT_PREPARED, 0, true);
ts.setState(TransactionState.PREPARED);
try {
pstore.storeTransaction(tid, ts, false);
} catch (Exception ex) {
logger.logStack(Logger.WARNING, "Error updating transaction " + tid, ex);
}
processing = processing.getNextException();
continue;
}
if (ti.getType() == TransactionInfo.TXN_NOFLAG) {
logger.logStack(Logger.WARNING, Globals.getBrokerResources().getKString(BrokerResources.W_TXN_TYPE_CORRUPTED, tid + "[" + ti.toString() + "]", TransactionInfo.toString(TransactionInfo.TXN_LOCAL)), processing.getValueCause());
TransactionState ts = new TransactionState(AutoRollbackType.NOT_PREPARED, 0, true);
ts.setState(TransactionState.PREPARED);
try {
pstore.storeTransaction(tid, ts, false);
} catch (Exception ex) {
logger.logStack(Logger.WARNING, "Error updating transaction " + tid, ex);
}
processing = processing.getNextException();
continue;
}
if (ti.getTransactionState() == null) {
logger.log(Logger.WARNING, BrokerResources.W_TRANS_STATE_CORRUPT, tid, processing.getValueCause());
TransactionState ts = new TransactionState(AutoRollbackType.NOT_PREPARED, 0, true);
ts.setState(TransactionState.PREPARED);
try {
pstore.storeTransaction(tid, ts, false);
} catch (Exception ex) {
logger.logStack(Logger.WARNING, "Error updating transaction " + tid, ex);
}
processing = processing.getNextException();
continue;
}
if (ti.getType() == TransactionInfo.TXN_CLUSTER && ti.getTransactionBrokers() == null) {
logger.log(Logger.WARNING, BrokerResources.W_CLUSTER_TXN_BROKER_INFO_CORRUPTED, tid, processing.getValueCause());
pstore.storeClusterTransaction(tid, ti.getTransactionState(), null, false);
processing = processing.getNextException();
continue;
}
if (ti.getType() == TransactionInfo.TXN_REMOTE && ti.getTransactionHomeBroker() == null) {
logger.log(Logger.WARNING, BrokerResources.W_REMOTE_TXN_HOME_BROKER_INFO_CORRUPTED, tid, processing.getValueCause());
pstore.storeRemoteTransaction(tid, ti.getTransactionState(), null, null, false);
processing = processing.getNextException();
continue;
}
logger.log(Logger.ERROR, "XXXI18N Internal Error: unknown load error for TUID=" + tid + "[" + ti.toString() + "]");
}
// end while
}
// now look at acks load exception
load_ex = pstore.getLoadTransactionAckException();
if (load_ex != null) {
// some messages could not be loaded
LoadException processing = load_ex;
while (processing != null) {
TransactionUID tid = (TransactionUID) processing.getKey();
TransactionAcknowledgement[] ta = (TransactionAcknowledgement[]) processing.getValue();
if (tid == null && ta == null) {
logger.log(Logger.WARNING, "LoadTransactionAckException: " + "both key and value for a Transaction Ack entry" + " are corrupted");
processing = processing.getNextException();
continue;
}
if (tid == null) {
// at this point, there is nothing we can do ...
// store with valid key
// improve when we address 5060661
logger.log(Logger.WARNING, BrokerResources.W_TRANS_ID_CORRUPT, Arrays.toString(ta));
processing = processing.getNextException();
continue;
}
// ta == null, nothing we can do, remove it
logger.log(Logger.WARNING, BrokerResources.W_TRANS_ACK_CORRUPT, tid.toString());
try {
pstore.removeTransactionAck(tid, false);
} catch (Exception ex) {
logger.logStack(Logger.WARNING, "Error updating transaction acks " + tid, ex);
}
}
// end while
}
logger.log(Logger.INFO, br.getKString(br.I_PROCESSING_TRANS) + logsuffix);
// OK -> first load the list of pending
// transactions
HashMap trans = pstore.getAllTransactionStates();
// Write some info about the transactions to the log file
// for informational purposes.
logTransactionInfo(trans, AUTO_ROLLBACK, logsuffix);
// list of transactions which need to be cleaned up
HashSet clearTrans = new HashSet(trans.size());
HashSet clearAckOnlyTrans = new HashSet(trans.size());
HashMap openTransactions = new HashMap();
HashMap inprocessAcks = new HashMap();
HashMap committingTransactions = new HashMap();
// loop through the list of transactions
// placing each on the various lists
int prepareCN = 0, commitWaitCN = 0;
Iterator itr = trans.entrySet().iterator();
while (itr.hasNext()) {
try {
Map.Entry entry = (Map.Entry) itr.next();
TransactionUID tid = (TransactionUID) entry.getKey();
TransactionInfo tif = (TransactionInfo) entry.getValue();
TransactionState ts = tif.getTransactionState();
TransactionAcknowledgement[] ta = pstore.getTransactionAcks(tid);
if (ta == null) {
ta = new TransactionAcknowledgement[0];
}
int state = ts.getState();
if (DEBUG) {
logger.log(Logger.INFO, "Load transaction: TUID=" + tid + "[" + TransactionState.toString(state) + (ts.getCreationTime() == 0 ? "" : " createTime=" + ts.getCreationTime()) + "]");
}
switch(state) {
// no longer valid, ignore
case TransactionState.CREATED:
clearTrans.add(tid);
break;
case TransactionState.PREPARED:
// if autorollback, fall through to rollback
if (!AUTO_ROLLBACK) {
// nothing happens w/ preparedTransactions
// they go back into the list
// We don't persist this because it is already
// in the store
addTransactionID(tid, ts, false);
if (tif.getType() == TransactionInfo.TXN_CLUSTER) {
logClusterTransaction(tid, ts, tif.getTransactionBrokers(), true, false);
prepareCN++;
}
openTransactions.put(tid, Boolean.TRUE);
if (ts.getOnephasePrepare()) {
addDetachedTransactionID(tid);
}
break;
}
// rollback -> we didnt complete
case TransactionState.STARTED:
case TransactionState.COMPLETE:
case TransactionState.ROLLEDBACK:
case TransactionState.FAILED:
case TransactionState.INCOMPLETE:
addTransactionID(tid, ts, false);
if (tif.getType() == TransactionInfo.TXN_CLUSTER) {
logClusterTransaction(tid, ts, tif.getTransactionBrokers(), true, false);
}
openTransactions.put(tid, Boolean.FALSE);
clearTrans.add(tid);
ts.setState(TransactionState.ROLLEDBACK);
if (state == TransactionState.PREPARED) {
clearAckOnlyTrans.add(tid);
try {
updateState(tid, TransactionState.ROLLEDBACK, true);
} catch (Exception e) {
logger.logStack(Logger.WARNING, "Unable to update auto-rollback PREPARED transaction " + tid + " state to ROLLEDBACK", e);
}
}
break;
case TransactionState.COMMITTED:
committingTransactions.put(tid, "");
if (tif.getType() == TransactionInfo.TXN_CLUSTER) {
boolean completed = true;
TransactionBroker[] brokers = tif.getTransactionBrokers();
logClusterTransaction(tid, ts, brokers, false, false);
for (int i = 0; brokers != null && i < brokers.length; i++) {
completed = brokers[i].isCompleted();
if (!completed) {
if (DEBUG_CLUSTER_TXN) {
logger.log(logger.INFO, "COMMITTED cluster transaction " + tid + ", incomplete broker:" + brokers[i]);
}
break;
}
}
if (!completed) {
commitWaitCN++;
}
} else {
addTransactionID(tid, ts, false);
}
clearTrans.add(tid);
break;
default:
logger.log(logger.ERROR, "Internal Error unexpected transaction state:" + TransactionState.toString(state) + " TUID=" + tid + ", set to PREPARE");
addTransactionID(tid, ts, false);
if (tif.getType() == TransactionInfo.TXN_CLUSTER) {
logClusterTransaction(tid, ts, tif.getTransactionBrokers(), true, false);
}
updateState(tid, TransactionState.PREPARED, true);
openTransactions.put(tid, Boolean.TRUE);
}
for (int i = 0; i < ta.length; i++) {
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 :" + Arrays.toString(ta));
scuid = cuid;
}
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 = pstore.getAllRemoteTransactionStates();
// list of transactions which need to be cleaned up
HashSet clearRemoteTrans = new HashSet(remoteTrans.size());
int prepareRN = 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 = pstore.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);
break;
case TransactionState.PREPARED:
prepareRN++;
logRemoteTransaction(tid, ts, ta, pstore.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, pstore.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);
break;
case TransactionState.COMMITTED:
commitRN++;
logRemoteTransaction(tid, ts, ta, pstore.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, pstore.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 :" + Arrays.toString(ta));
scuid = cuid;
}
if (imap == null) {
imap = new HashMap();
inprocessAcks.put(sysid, imap);
}
imap.put(scuid, tid);
}
} catch (Exception ex) {
logger.logStack(Logger.WARNING, BrokerResources.E_INTERNAL_BROKER_ERROR, "Error parsing remote transaction ", ex);
}
}
if (Globals.getHAEnabled()) {
Object[] args = { String.valueOf(remoteTrans.size()), String.valueOf(prepareRN), String.valueOf(completeRN), String.valueOf(commitRN) };
logger.log(logger.INFO, Globals.getBrokerResources().getString(BrokerResources.I_NREMOTE_TRANS_HA, args));
} else {
Object[] args = { String.valueOf(remoteTrans.size()), String.valueOf(prepareRN), String.valueOf(commitRN) };
logger.log(logger.INFO, Globals.getBrokerResources().getString(BrokerResources.I_NREMOTE_TRANS, args));
}
// load the database now and fix it
if (openTransactions.size() > 0 || inprocessAcks.size() > 0) {
LinkedHashMap m = DL.processTransactions(inprocessAcks, openTransactions, committingTransactions);
if (m != null && !m.isEmpty()) {
Iterator meitr = m.entrySet().iterator();
while (meitr.hasNext()) {
Map.Entry me = (Map.Entry) meitr.next();
TransactionInformation ti = (TransactionInformation) translist.get(me.getValue());
ti.addPublishedMessage((SysMessageID) me.getKey());
}
}
}
// OK -> now clean up the cleared transactions
// this removes them from the disk
itr = clearTrans.iterator();
while (itr.hasNext()) {
TransactionUID tid = (TransactionUID) itr.next();
logger.log(Logger.DEBUG, "Clearing transaction " + tid);
if (!clearAckOnlyTrans.contains(tid)) {
removeTransactionAck(tid);
removeTransactionID(tid);
} else {
removeTransactionAck(tid, true);
}
}
itr = clearRemoteTrans.iterator();
while (itr.hasNext()) {
TransactionUID tid = (TransactionUID) itr.next();
try {
logger.log(Logger.DEBUG, "Clearing remote transaction " + tid);
removeRemoteTransactionAck(tid);
removeRemoteTransactionID(tid, true);
} catch (Exception e) {
logger.log(logger.WARNING, "Failed to remove remote transaction TUID=" + tid + ": " + e.getMessage());
}
}
}
Aggregations