Search in sources :

Example 1 with NotPrepared

use of org.omg.CosTransactions.NotPrepared in project narayana by jbosstm.

the class JavaIdlRCDefaultServant method replay_completion.

public Status replay_completion(Resource res) throws SystemException, NotPrepared {
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("JavaIdlRCDefaultServant::replay_completion)");
    }
    try {
        // Begin New
        org.omg.CORBA.Object obj = _ourOrb.resolve_initial_references("POACurrent");
        org.omg.PortableServer.Current poa_current = org.omg.PortableServer.CurrentHelper.narrow(obj);
        byte[] objectId = poa_current.get_object_id();
        // End New
        String objectIdString = new String(objectId, StandardCharsets.UTF_8);
        String poaName = poa_current.get_POA().the_name();
        if (objectIdString.startsWith(poaName)) {
            // strip off the POA name prefix from the object name - the remainder encodes our Uids
            int index = poaName.length();
            if (objectIdString.length() > index)
                index += 1;
            objectIdString = objectIdString.substring(index);
        }
        // convert that to the structured id
        RecoveryCoordinatorId recovCoId = RecoveryCoordinatorId.reconstruct(objectIdString);
        if (jtsLogger.logger.isDebugEnabled()) {
            jtsLogger.logger.debug("JavaIdlDefaultServant replay_completion for Id " + recovCoId);
        }
        // and do the real replay
        return GenericRecoveryCoordinator.replay_completion(recovCoId, res);
    }/**
     */
     catch (NotPrepared exp) {
        throw exp;
    }/**/
     catch (Exception ex) {
        jtsLogger.i18NLogger.warn_orbspecific_jacorb_recoverycoordinators_JacOrbRCDefaultServant_3(ex);
        return Status.StatusUnknown;
    }
}
Also used : RecoveryCoordinatorId(com.arjuna.ats.internal.jts.orbspecific.recovery.recoverycoordinators.RecoveryCoordinatorId) NotPrepared(org.omg.CosTransactions.NotPrepared) SystemException(org.omg.CORBA.SystemException)

Example 2 with NotPrepared

use of org.omg.CosTransactions.NotPrepared in project narayana by jbosstm.

the class ServerTopLevelAction method commit.

public void commit() throws NotPrepared, HeuristicRollback, HeuristicMixed, HeuristicHazard, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ServerTopLevelAction::commit for " + _theUid);
    }
    if (_theControl == null) {
        throw new INVALID_TRANSACTION(ExceptionCodes.SERVERAA_NO_CONTROL, CompletionStatus.COMPLETED_NO);
    }
    if (_theControl.isWrapper()) {
        destroyResource();
        return;
    }
    ServerTransaction theTransaction = (ServerTransaction) _theControl.getImplHandle();
    // LockManager needs to know if there is a transaction
    ThreadActionData.pushAction(theTransaction);
    int actionStatus = theTransaction.status();
    boolean notPrepared = false;
    if (actionStatus == ActionStatus.PREPARED) {
        /*
	     * This will also call any after_completions on
	     * registered synchronizations.
	     */
        actionStatus = theTransaction.doPhase2Commit();
    } else {
        if (actionStatus == ActionStatus.RUNNING) {
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ServerTopLevelAction::commit for " + _theUid + " : NotPrepared");
            }
            notPrepared = true;
        }
    }
    ThreadActionData.popAction();
    if (notPrepared)
        throw new NotPrepared();
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ServerTopLevelAction::commit for " + _theUid + " : " + ActionStatus.stringForm(actionStatus));
    }
    switch(actionStatus) {
        case ActionStatus.PREPARED:
            throw new INVALID_TRANSACTION(ExceptionCodes.SERVERAA_NO_CONTROL, CompletionStatus.COMPLETED_NO);
        case ActionStatus.COMMITTED:
        case ActionStatus.H_COMMIT:
            destroyResource();
            break;
        case ActionStatus.ABORTED:
        case ActionStatus.H_ROLLBACK:
            if (TxControl.getMaintainHeuristics())
                destroyResource();
            throw new HeuristicRollback();
        case ActionStatus.H_MIXED:
            if (TxControl.getMaintainHeuristics())
                destroyResource();
            throw new HeuristicMixed();
        case ActionStatus.H_HAZARD:
            if (TxControl.getMaintainHeuristics())
                destroyResource();
            throw new HeuristicHazard();
        default:
            destroyResource();
            break;
    }
}
Also used : HeuristicRollback(org.omg.CosTransactions.HeuristicRollback) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) ServerTransaction(com.arjuna.ats.internal.jts.orbspecific.interposition.coordinator.ServerTransaction) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) NotPrepared(org.omg.CosTransactions.NotPrepared) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard)

Example 3 with NotPrepared

use of org.omg.CosTransactions.NotPrepared in project narayana by jbosstm.

the class XAResourceRecord method commit.

public void commit() throws org.omg.CORBA.SystemException, NotPrepared, HeuristicRollback, HeuristicMixed, HeuristicHazard {
    if (jtaxLogger.logger.isTraceEnabled()) {
        jtaxLogger.logger.trace("XAResourceRecord.commit for " + _tranID);
    }
    if (_tranID == null) {
        jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_nulltransaction("XAResourceRecord.commit");
    } else {
        if ((_theXAResource != null) && (!_committed)) {
            switch(_heuristic) {
                case TwoPhaseOutcome.HEURISTIC_HAZARD:
                    throw new org.omg.CosTransactions.HeuristicHazard();
                case TwoPhaseOutcome.HEURISTIC_MIXED:
                    throw new org.omg.CosTransactions.HeuristicMixed();
                case TwoPhaseOutcome.HEURISTIC_ROLLBACK:
                    throw new org.omg.CosTransactions.HeuristicRollback();
                default:
                    break;
            }
            if (!_prepared)
                throw new NotPrepared();
            boolean removeConnection = true;
            try {
                if (!_committed) {
                    _committed = true;
                    _theXAResource.commit(_tranID, false);
                    destroyState();
                }
            } catch (XAException e1) {
                if (notAProblem(e1, true)) {
                    // some other thread got there first (probably)
                    destroyState();
                } else {
                    _committed = false;
                    jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_xaerror("XAResourceRecord.commit", XAHelper.printXAErrorCode(e1), _theXAResource.toString(), XAHelper.xidToString(_tranID), e1);
                    if (jtaxLogger.logger.isTraceEnabled()) {
                        jtaxLogger.logger.tracef("XAResourceRecord.commit exception %s " + "resource_trace: txn uid=%s resource uid=%s\n", XAHelper.printXAErrorCode(e1), _tranID, get_uid());
                    }
                    switch(e1.errorCode) {
                        case XAException.XA_HEURHAZ:
                            updateState(TwoPhaseOutcome.HEURISTIC_HAZARD);
                            throw new org.omg.CosTransactions.HeuristicHazard();
                        case // what about forget? OTS doesn't support this code here.
                        XAException.XA_HEURCOM:
                            destroyState();
                            break;
                        case XAException.XA_HEURRB:
                        case XAException.XA_RBROLLBACK:
                        case XAException.XA_RBCOMMFAIL:
                        case XAException.XA_RBDEADLOCK:
                        case XAException.XA_RBINTEGRITY:
                        case XAException.XA_RBOTHER:
                        case XAException.XA_RBPROTO:
                        case XAException.XA_RBTIMEOUT:
                        case XAException.XA_RBTRANSIENT:
                        case XAException.XAER_RMERR:
                            updateState(TwoPhaseOutcome.HEURISTIC_ROLLBACK);
                            throw new org.omg.CosTransactions.HeuristicRollback();
                        case XAException.XA_HEURMIX:
                            updateState(TwoPhaseOutcome.HEURISTIC_MIXED);
                            throw new org.omg.CosTransactions.HeuristicMixed();
                        case XAException.XAER_NOTA:
                            if (// committed previously on participant
                            _phaseTwoStarted)
                                break;
                            // RM unexpectedly lost track of the tx, outcome is uncertain
                            updateState(TwoPhaseOutcome.HEURISTIC_HAZARD);
                            throw new org.omg.CosTransactions.HeuristicHazard();
                        case XAException.XAER_PROTO:
                            // presumed abort (or we could be really paranoid and throw a heuristic)
                            throw new TRANSACTION_ROLLEDBACK();
                        case XAException.XA_RETRY:
                        case XAException.XAER_RMFAIL:
                            removeConnection = false;
                            // Since JBTM-2710 this is not right because it will mean that commit is not reattempted _committed = true;  // remember for recovery later.
                            throw // will cause log to be rewritten.
                            new UNKNOWN();
                        // resource manager failed, did it rollback?
                        case XAException.XAER_INVAL:
                        default:
                            throw new org.omg.CosTransactions.HeuristicHazard();
                    }
                }
            } catch (Exception e2) {
                _committed = false;
                jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_generror("XAResourceRecord.commit", _theXAResource.toString(), XAHelper.xidToString(_tranID), e2);
                throw new UNKNOWN();
            } finally {
                _phaseTwoStarted = true;
                if (removeConnection) {
                    removeConnection();
                }
            }
        }
    }
}
Also used : XAException(javax.transaction.xa.XAException) HeuristicRollback(org.omg.CosTransactions.HeuristicRollback) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) NotPrepared(org.omg.CosTransactions.NotPrepared) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) SystemException(org.omg.CORBA.SystemException) XAException(javax.transaction.xa.XAException) NotSerializableException(java.io.NotSerializableException) HeuristicRollback(org.omg.CosTransactions.HeuristicRollback) UNKNOWN(org.omg.CORBA.UNKNOWN) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK)

Example 4 with NotPrepared

use of org.omg.CosTransactions.NotPrepared in project narayana by jbosstm.

the class RecoveredServerTransaction method getStatusFromParent.

private Status getStatusFromParent() {
    Status theStatus = Status.StatusUnknown;
    // This variable is applied with Orbix
    int not_exist_count;
    if ((super._recoveryCoordinator != null) && (get_status() == Status.StatusPrepared)) {
        ServerControl sc = new ServerControl((ServerTransaction) this);
        ServerRecoveryTopLevelAction tla = new ServerRecoveryTopLevelAction(sc);
        if (tla.valid()) {
            try {
                theStatus = super._recoveryCoordinator.replay_completion(tla.getReference());
                if (jtsLogger.logger.isDebugEnabled()) {
                    jtsLogger.logger.debug("RecoveredServerTransaction.getStatusFromParent - replay_completion status = " + Utility.stringStatus(theStatus));
                }
            } catch (TRANSIENT ex_trans) {
                /*
                     * A failure that might not occur again if the request is retried. Not definite.
                     */
                jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_10(get_uid());
                theStatus = Status.StatusUnknown;
            }// What here what should be done for Orbix2000
             catch (OBJECT_NOT_EXIST ex) {
                // i believe this state should be notran - ots explicitly
                // objnotexist is
                // rollback
                theStatus = Status.StatusRolledBack;
                if (jtsLogger.logger.isDebugEnabled()) {
                    jtsLogger.logger.debug("RecoveredServerTransaction.getStatusFromParent -" + " replay_completion got object_not_exist = " + Utility.stringStatus(theStatus));
                }
            } catch (NotPrepared ex1) {
                jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_12();
                theStatus = Status.StatusActive;
            } catch (Exception e) {
                // Unknown error, so better to do nothing at this stage.
                jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_13(e);
            }
        } else {
            jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_14(get_uid());
        }
        // Make sure we "delete" these objects when we are finished
        // with them or there will be a memory leak. If they are deleted
        // "early", and the root coordinator needs them then it will find
        // them unavailable, and will have to retry recovery later.
        sc = null;
        tla = null;
    } else {
        if (jtsLogger.logger.isDebugEnabled()) {
            jtsLogger.logger.debug("RecoveredServerTransaction:getStatusFromParent - " + "no recovcoord or status not prepared");
        }
    }
    return theStatus;
}
Also used : Status(org.omg.CosTransactions.Status) StateStatus(com.arjuna.ats.arjuna.objectstore.StateStatus) RecoveryStatus(com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) ServerRecoveryTopLevelAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerRecoveryTopLevelAction) TRANSIENT(org.omg.CORBA.TRANSIENT) NotPrepared(org.omg.CosTransactions.NotPrepared) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 5 with NotPrepared

use of org.omg.CosTransactions.NotPrepared in project narayana by jbosstm.

the class XAResourceRecordUnitTest method testReadonly.

@Test
public void testReadonly() throws Exception {
    ThreadActionData.purgeActions();
    OTSImpleManager.current().contextManager().purgeActions();
    XAResourceRecord xares;
    DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
    Object[] params = new Object[1];
    params[XAResourceRecord.XACONNECTION] = rc;
    xares = new XAResourceRecord(new TransactionImple(), new TestResource(true), new XidImple(new Uid()), params);
    try {
        xares.commit();
        fail();
    } catch (final NotPrepared ex) {
    }
    assertEquals(xares.prepare(), Vote.VoteReadOnly);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) DummyRecoverableXAConnection(com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection) Uid(com.arjuna.ats.arjuna.common.Uid) XAResourceRecord(com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) TestResource(com.hp.mwtests.ts.jta.common.TestResource) NotPrepared(org.omg.CosTransactions.NotPrepared) Test(org.junit.Test)

Aggregations

NotPrepared (org.omg.CosTransactions.NotPrepared)10 SystemException (org.omg.CORBA.SystemException)7 Status (org.omg.CosTransactions.Status)4 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)3 RecoveryCoordinatorId (com.arjuna.ats.internal.jts.orbspecific.recovery.recoverycoordinators.RecoveryCoordinatorId)3 HeuristicHazard (org.omg.CosTransactions.HeuristicHazard)3 HeuristicMixed (org.omg.CosTransactions.HeuristicMixed)3 StateStatus (com.arjuna.ats.arjuna.objectstore.StateStatus)2 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)2 ServerRecoveryTopLevelAction (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerRecoveryTopLevelAction)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 OBJECT_NOT_EXIST (org.omg.CORBA.OBJECT_NOT_EXIST)2 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)2 TRANSIENT (org.omg.CORBA.TRANSIENT)2 HeuristicRollback (org.omg.CosTransactions.HeuristicRollback)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 XAResourceRecord (com.arjuna.ats.internal.jta.resources.jts.orbspecific.XAResourceRecord)1 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)1 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)1