Search in sources :

Example 1 with RemoteTransactionAckEntry

use of com.sun.messaging.jmq.jmsserver.cluster.api.RemoteTransactionAckEntry in project openmq by eclipse-ee4j.

the class RemoteTxnConverter method convert.

void convert(TransactionInformation txnInfo) throws BrokerException {
    if (ToTxnLogConverter.DEBUG) {
        logger.log(Logger.DEBUG, getPrefix() + " convert " + txnInfo);
    }
    // should be a prepared transaction
    int state = txnInfo.getState().getState();
    if (state != TransactionState.PREPARED) {
        String msg = getPrefix() + " convert: unknown state  " + state + " for " + txnInfo;
        logger.log(Logger.ERROR, msg);
    }
    TransactionUID txid = txnInfo.getTID();
    TransactionState newState = new TransactionState(txnInfo.getState());
    RemoteTransactionAckEntry[] rtaes = transactionList.getRecoveryRemoteTransactionAcks(txid);
    if (rtaes != null) {
        ArrayList<TransactionAcknowledgement> al = new ArrayList<>();
        for (int i = 0; i < rtaes.length; i++) {
            RemoteTransactionAckEntry rtae = rtaes[i];
            TransactionAcknowledgement[] txnAcks = rtae.getAcks();
            for (int j = 0; j < txnAcks.length; j++) {
                al.add(txnAcks[j]);
            }
        }
        TransactionAcknowledgement[] txnAcks = al.toArray(new TransactionAcknowledgement[al.size()]);
        DestinationUID[] destIds = new DestinationUID[txnAcks.length];
        for (int i = 0; i < txnAcks.length; i++) {
            SysMessageID sid = txnAcks[i].getSysMessageID();
            PacketReference p = DL.get((PartitionedStore) store, sid);
            DestinationUID destID = null;
            if (p != null) {
                destID = p.getDestinationUID();
            } else {
                logger.log(Logger.WARNING, "Could not find packet for " + sid);
            }
            destIds[i] = destID;
        }
        TransactionBroker txnBroker = transactionList.getRemoteTransactionHomeBroker(txid);
        BrokerAddress txnHomeBroker = txnBroker.getBrokerAddress();
        RemoteTransaction remoteTxn = new RemoteTransaction(txid, newState, txnAcks, destIds, txnHomeBroker);
        store.logTxn(remoteTxn);
    } else {
        logger.log(Logger.ERROR, "Could not find RemoteTransactionAckEntry for " + txid);
    }
}
Also used : ArrayList(java.util.ArrayList) BrokerAddress(com.sun.messaging.jmq.jmsserver.core.BrokerAddress) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) PacketReference(com.sun.messaging.jmq.jmsserver.core.PacketReference) SysMessageID(com.sun.messaging.jmq.io.SysMessageID) RemoteTransactionAckEntry(com.sun.messaging.jmq.jmsserver.cluster.api.RemoteTransactionAckEntry)

Aggregations

SysMessageID (com.sun.messaging.jmq.io.SysMessageID)1 RemoteTransactionAckEntry (com.sun.messaging.jmq.jmsserver.cluster.api.RemoteTransactionAckEntry)1 BrokerAddress (com.sun.messaging.jmq.jmsserver.core.BrokerAddress)1 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)1 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)1 ArrayList (java.util.ArrayList)1