Search in sources :

Example 6 with AbstractRecord

use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.

the class ArjunaTransactionImple method register_subtran_aware.

/**
 * Do not propagate the resource to the parent.
 */
public void register_subtran_aware(SubtransactionAwareResource r) throws Inactive, NotSubtransaction, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::register_subtran_aware called for " + get_uid());
    }
    if (r == null)
        throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
    currentStatus = determineStatus(this);
    if (currentStatus != Status.StatusActive) {
        if (currentStatus == Status.StatusMarkedRollback) {
            throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.MARKED_ROLLEDBACK, CompletionStatus.COMPLETED_NO);
        } else
            throw new Inactive();
    }
    if (this == rootAction) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_subtran_aware called for " + get_uid() + " : not a subtransaction!");
        }
        throw new NotSubtransaction();
    } else {
        Coordinator coord = null;
        AbstractRecord corbaRec = null;
        try {
            coord = parentHandle.get_coordinator();
            corbaRec = createOTSRecord(false, r, coord);
        } catch (Unavailable ex) {
            throw new UNKNOWN(ExceptionCodes.INACTIVE_TRANSACTION, // what else to raise?
            CompletionStatus.COMPLETED_NO);
        }
        coord = null;
        if (add(corbaRec) != AddOutcome.AR_ADDED) {
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ArjunaTransactionImple::register_subtran_aware called for " + get_uid() + " : could not add.");
            }
            corbaRec = null;
            // what else to raise??
            throw new Inactive();
        }
    }
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::register_subtran_aware called for " + get_uid() + " : subtran_aware_resource registered");
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) NotSubtransaction(org.omg.CosTransactions.NotSubtransaction) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) Inactive(org.omg.CosTransactions.Inactive) UNKNOWN(org.omg.CORBA.UNKNOWN) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) SynchronizationUnavailable(org.omg.CosTransactions.SynchronizationUnavailable) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable)

Example 7 with AbstractRecord

use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.

the class RecoveredServerTransaction method addResourceRecord.

/**
 * Allows a new Resource to be added to the transaction. Typically this is
 * used to replace a Resource that has failed and cannot be recovered on
 * it's original IOR.
 */
public void addResourceRecord(Uid rcUid, Resource r) {
    Coordinator coord = null;
    AbstractRecord corbaRec = createOTSRecord(true, r, coord, rcUid);
    addRecord(corbaRec);
}
Also used : AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) Coordinator(org.omg.CosTransactions.Coordinator)

Example 8 with AbstractRecord

use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.

the class EditableAtomicAction method toString.

public String toString() {
    if (!_activated)
        return "RecoveryAction not activated.";
    else {
        String printableForm = "ActionStatus: " + ActionStatus.stringForm(super.status());
        printableForm += "\nHeuristic Decision: " + TwoPhaseOutcome.stringForm(super.getHeuristicDecision());
        if (super.preparedList.size() == 0)
            printableForm += "\nNo prepared entries.";
        else {
            printableForm += "\nPrepared entries:";
            RecordListIterator iter = new RecordListIterator(super.preparedList);
            AbstractRecord rec = iter.iterate();
            int i = 0;
            while (rec != null) {
                printableForm += "\n[" + i + "] " + rec;
                rec = iter.iterate();
                i++;
            }
        }
        if (super.heuristicList.size() == 0)
            printableForm += "\nNo heuristic entries.";
        else {
            printableForm += "\nHeuristic entries:";
            RecordListIterator iter = new RecordListIterator(super.heuristicList);
            AbstractRecord rec = iter.iterate();
            int i = 0;
            while (rec != null) {
                printableForm += "\n[" + i + "] " + rec;
                rec = iter.iterate();
                i++;
            }
        }
        return printableForm;
    }
}
Also used : RecordListIterator(com.arjuna.ats.arjuna.coordinator.RecordListIterator) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Example 9 with AbstractRecord

use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.

the class EditableAtomicAction method moveHeuristicToPrepared.

/**
 * Move a previous heuristic participant back to the prepared list so that recovery
 * can try again. If it fails again then it may end up back on the heuristic list.
 */
public void moveHeuristicToPrepared(int index) throws IndexOutOfBoundsException {
    if ((index < 0) || (index >= super.heuristicList.size()))
        throw new IndexOutOfBoundsException();
    else {
        if (super.heuristicList.size() == 0)
            throw new IndexOutOfBoundsException();
        RecordListIterator iter = new RecordListIterator(super.heuristicList);
        AbstractRecord rec = iter.iterate();
        for (int i = 0; i < index; i++) rec = iter.iterate();
        if (rec.forgetHeuristic()) {
            /*
                 * Move from heuristic list to prepared list.
                 */
            super.heuristicList.remove(rec);
            super.preparedList.insert(rec);
            if (super.heuristicList.size() == 0)
                super.setHeuristicDecision(TwoPhaseOutcome.FINISH_OK);
            super.updateState();
        } else {
            tsLogger.i18NLogger.warn_tools_log_eaa2();
        }
    }
}
Also used : RecordListIterator(com.arjuna.ats.arjuna.coordinator.RecordListIterator) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Example 10 with AbstractRecord

use of com.arjuna.ats.arjuna.coordinator.AbstractRecord in project narayana by jbosstm.

the class AtomicActionTestBase method testPrepareWithLRRFailOn2PCUnawareResourcePrepare.

protected void testPrepareWithLRRFailOn2PCUnawareResourcePrepare() {
    OnePhase onePhase = new OnePhase();
    AbstractRecord lastResourceRecord = new LastResourceShutdownRecord(onePhase, true);
    AbstractRecord basicRecord = new BasicRecord();
    executeTest(true, ActionStatus.ABORTED, null, lastResourceRecord, basicRecord);
    Assert.assertEquals(OnePhase.ROLLEDBACK, onePhase.status());
}
Also used : AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord)

Aggregations

AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)31 RecordListIterator (com.arjuna.ats.arjuna.coordinator.RecordListIterator)10 Coordinator (org.omg.CosTransactions.Coordinator)5 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)4 OTSAbstractRecord (com.arjuna.ArjunaOTS.OTSAbstractRecord)3 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)3 Uid (com.arjuna.ats.arjuna.common.Uid)3 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)3 LastResourceRecord (com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord)3 BAD_PARAM (org.omg.CORBA.BAD_PARAM)3 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)2 IOException (java.io.IOException)2 Enumeration (java.util.Enumeration)2 Test (org.junit.Test)2 SystemException (org.omg.CORBA.SystemException)2 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)2 UNKNOWN (org.omg.CORBA.UNKNOWN)2 Inactive (org.omg.CosTransactions.Inactive)2 RecoveryCoordinator (org.omg.CosTransactions.RecoveryCoordinator)2 SubtransactionsUnavailable (org.omg.CosTransactions.SubtransactionsUnavailable)2