use of org.jboss.jbossts.star.resource.RecoveringTransaction in project narayana by jbosstm.
the class Coordinator method updateTransactions.
private void updateTransactions() {
Map<String, RecoveringTransaction> txns = new HashMap<String, RecoveringTransaction>(recoveringTransactions);
// remove all those uids that are still recovering
for (Uid uid : getUids(new HashSet<Uid>(), REST_TXN_TYPE)) {
txns.remove(uid.fileStringForm());
}
// the remaining entries must have been recovered
for (String txId : txns.keySet()) {
recoveringTransactions.remove(txId);
transactions.remove(txId);
}
}
use of org.jboss.jbossts.star.resource.RecoveringTransaction in project narayana by jbosstm.
the class Coordinator method getRecoveringTransactions.
private static Map<String, RecoveringTransaction> getRecoveringTransactions(Map<String, Transaction> transactions) {
Map<String, RecoveringTransaction> recoveringTransactions = new ConcurrentHashMap<String, RecoveringTransaction>();
for (Uid uid : getUids(new HashSet<Uid>(), REST_TXN_TYPE)) {
String key = uid.fileStringForm();
RecoveringTransaction txn = new RecoveringTransaction(uid);
try {
// so it needs activate in order to make it available to anyone that wants to obtain it:
if (txn.activate()) {
for (RESTRecord r : txn.getParticipants(new ArrayList<RESTRecord>())) {
Map<String, String> links = new HashMap<String, String>();
links.put(TxLinkNames.PARTICIPANT_RECOVERY, r.getRecoveryURI());
links.put(TxLinkNames.TRANSACTION, r.getTxId());
participants.put(r.getCoordinatorURI(), new HashMap<>(links));
}
}
} catch (Throwable e) {
log.warnf("Could not reactivate pending transaction %s (reason: %s)", txn.get_uid(), e.getMessage());
}
recoveringTransactions.put(key, txn);
transactions.put(key, txn);
}
return recoveringTransactions;
}
Aggregations