Search in sources :

Example 1 with RecoveringTransaction

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);
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) RecoveringTransaction(org.jboss.jbossts.star.resource.RecoveringTransaction) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 2 with RecoveringTransaction

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;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) RecoveringTransaction(org.jboss.jbossts.star.resource.RecoveringTransaction) RESTRecord(org.jboss.jbossts.star.resource.RESTRecord) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 RecoveringTransaction (org.jboss.jbossts.star.resource.RecoveringTransaction)2 RESTRecord (org.jboss.jbossts.star.resource.RESTRecord)1