Search in sources :

Example 1 with Unavailable

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

the class CurrentImple method get_control.

public org.omg.CosTransactions.Control get_control() throws SystemException {
    ControlWrapper theControl = _theManager.current();
    if (theControl == null)
        return null;
    if (true) {
        try {
            return theControl.get_control();
        } catch (Unavailable e) {
            return null;
        }
    } else {
        Coordinator coord = null;
        try {
            coord = theControl.get_coordinator();
        } catch (Unavailable e) {
            coord = null;
            throw new UNKNOWN(ExceptionCodes.UNAVAILABLE_COORDINATOR, CompletionStatus.COMPLETED_NO);
        } catch (SystemException sysEx) {
            coord = null;
            throw sysEx;
        }
        org.omg.CosTransactions.Control proxyControl = TransactionFactoryImple.createPropagatedControl(coord);
        coord = null;
        theControl = null;
        return proxyControl;
    }
}
Also used : Control(org.omg.CosTransactions.Control) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) UNKNOWN(org.omg.CORBA.UNKNOWN) Coordinator(org.omg.CosTransactions.Coordinator) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable)

Example 2 with Unavailable

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

the class ArjunaTransactionImple method register_resource.

/**
 * Resources are only registered with the current transaction, whereas
 * subtransaction aware resources are registered with their parents when the
 * current transaction ends.
 */
public RecoveryCoordinator register_resource(Resource r) throws SystemException, Inactive {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::register_resource ( " + r + " ) - called for " + get_uid());
    }
    if (r == null)
        throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
    currentStatus = determineStatus(this);
    if (currentStatus != Status.StatusActive) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource - transaction not active: " + Utility.stringStatus(currentStatus));
        }
        if (currentStatus == Status.StatusMarkedRollback) {
            throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.MARKED_ROLLEDBACK, CompletionStatus.COMPLETED_NO);
        } else
            throw new Inactive();
    }
    AbstractRecord corbaRec = null;
    BasicAction registerIn = this;
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple " + get_uid() + " ::register_resource: ");
    }
    // 
    // Creation of recovery coordinator (DBI)
    // 
    // 
    // Pack the params:
    // [0] = Transaction* this
    // 
    int index = 0;
    Object[] params = new Object[10];
    params[index++] = this;
    RecoveryCoordinator recoveryCoordinator = null;
    Uid recoveryCoordinatorUid = null;
    try {
        recoveryCoordinator = RecoveryCreator.createRecoveryCoordinator(r, params);
        if (recoveryCoordinator == null)
            throw new BAD_OPERATION("RecoveryCoordinator " + jtsLogger.i18NLogger.get_orbspecific_coordinator_rcnotcreated());
    } catch (NO_IMPLEMENT ex) {
        /*
			 * This is legal, and is meant to show that this ORB or
			 * configuration simply doesn't support crash recovery.
			 */
        recoveryCoordinator = null;
    } catch (SystemException e) {
        jtsLogger.i18NLogger.warn_orbspecific_coordinator_rccreate(get_uid(), e);
        try {
            rollback_only();
        } catch (Inactive ex1) {
        } catch (SystemException ex2) {
            jtsLogger.i18NLogger.warn_orbspecific_coordinator_rbofail("ArjunaTransactionImple.register_resource", get_uid(), ex2);
            throw ex2;
        }
        throw e;
    }
    if (recoveryCoordinator != null) {
        // 
        // We got a RecoveryCoordinator, so unpack the other return values:
        // [0] = RecoveryCoordinator Uid*
        // 
        index = 0;
        recoveryCoordinatorUid = (Uid) params[index++];
    } else {
        // 
        // We didn't get a RecoveryCoordinator, so we don't assume that
        // the other return values have been populated.
        // 
        recoveryCoordinatorUid = Uid.nullUid();
    }
    try {
        SubtransactionAwareResource staResource = org.omg.CosTransactions.SubtransactionAwareResourceHelper.narrow(r);
        if (staResource != null) {
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " - subtransaction aware resource: YES");
            }
            /*
				 * If here the narrow was ok so we have a subtran aware
				 * resource.
				 */
            Coordinator coord = null;
            if (parentHandle != null) {
                /*
					 * If we are a SubTranResource then we get registered with
					 * the current transaction and its parents upon completion.
					 * The first parameter to the record indicates whether we
					 * should be propagated (registered) with the parent
					 * transaction.
					 */
                coord = parentHandle.get_coordinator();
            }
            corbaRec = createOTSRecord(true, r, coord, recoveryCoordinatorUid);
            coord = null;
            staResource = null;
        } else
            throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
    } catch (BAD_PARAM ex) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " - subtransaction aware resource: NO");
        }
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple " + get_uid() + " ::register_resource: Simple resource - " + ex);
        }
        corbaRec = createOTSRecord(true, r, null, recoveryCoordinatorUid);
    } catch (Unavailable e1) {
        throw new Inactive();
    } catch (SystemException e2) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : catch (SystemException) - " + e2);
        }
        throw e2;
    } catch (Exception e3) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : catch (...) - " + e3);
        }
        throw new UNKNOWN(e3.toString(), ExceptionCodes.UNKNOWN_EXCEPTION, CompletionStatus.COMPLETED_NO);
    }
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : try end");
    }
    if (registerIn.add(corbaRec) != AddOutcome.AR_ADDED) {
        corbaRec = null;
        throw new INVALID_TRANSACTION(ExceptionCodes.ADD_FAILED, CompletionStatus.COMPLETED_NO);
    } else {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : resource registered");
        }
    }
    return recoveryCoordinator;
}
Also used : NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) SubtransactionAwareResource(org.omg.CosTransactions.SubtransactionAwareResource) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) BAD_PARAM(org.omg.CORBA.BAD_PARAM) OTSAbstractRecord(com.arjuna.ArjunaOTS.OTSAbstractRecord) AbstractRecord(com.arjuna.ats.arjuna.coordinator.AbstractRecord) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException) SynchronizationUnavailable(org.omg.CosTransactions.SynchronizationUnavailable) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable) Uid(com.arjuna.ats.arjuna.common.Uid) SystemException(org.omg.CORBA.SystemException) Inactive(org.omg.CosTransactions.Inactive) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) UNKNOWN(org.omg.CORBA.UNKNOWN) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK)

Example 3 with Unavailable

use of org.omg.CosTransactions.Unavailable 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 4 with Unavailable

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

the class AtomicTransaction method end.

/*
	 * public synchronized void begin () throws SubtransactionsUnavailable,
	 * SystemException { if (jtaxLogger.loggerI18N.isWarnEnabled()) {
	 * jtaxLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.jts.atomictxnobegin"); }
	 * 
	 * throw new INVALID_TRANSACTION(ExceptionCodes.ALREADY_BEGUN,
	 * CompletionStatus.COMPLETED_NO); }
	 */
/**
 * Does not change thread-to-tx association as base class commit does.
 */
public synchronized void end(boolean report_heuristics) throws NoTransaction, HeuristicMixed, HeuristicHazard, WrongTransaction, SystemException {
    if (jtaxLogger.logger.isTraceEnabled()) {
        jtaxLogger.logger.trace("AtomicTransaction::end ( " + report_heuristics + " ) for " + _theAction);
    }
    if (_theAction == null) {
        throw new NoTransaction();
    }
    try {
        _theAction.commit(report_heuristics);
        _theStatus = Status.StatusCommitted;
    } catch (Unavailable e) {
        _theStatus = Status.StatusNoTransaction;
        throw new NoTransaction();
    } catch (HeuristicMixed e) {
        _theStatus = getStatus();
        throw e;
    } catch (HeuristicHazard e) {
        _theStatus = getStatus();
        throw e;
    } catch (TRANSACTION_ROLLEDBACK e) {
        _theStatus = Status.StatusRolledBack;
        throw e;
    } catch (SystemException e) {
        _theStatus = getStatus();
        throw e;
    } finally {
        // now remove it from the reaper
        TransactionReaper.transactionReaper().remove(_theAction);
    }
}
Also used : NoTransaction(org.omg.CosTransactions.NoTransaction) SystemException(org.omg.CORBA.SystemException) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) Unavailable(org.omg.CosTransactions.Unavailable)

Example 5 with Unavailable

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

the class InterpositionClientRequestInterceptorImpl method send_request.

public void send_request(ClientRequestInfo request_info) throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        trace_request("send_request", request_info);
    }
    if (systemCall(request_info))
        return;
    final boolean otsAlwaysPropagate = InterceptorInfo.getAlwaysPropagate();
    try {
        if (!otsAlwaysPropagate) {
            TransactionalObject ptr = TransactionalObjectHelper.narrow(request_info.target());
            if (ptr == null)
                throw new BAD_PARAM();
        } else {
            /**
             * If the value is not null then we are currently in use *
             */
            if (_inUse.get() != null) {
                return;
            } else {
                /**
                 * Set the flag *
                 */
                _inUse.set(_inUse);
            }
        }
        try {
            /*
		 * We get back an Any, which contains a key which we must
		 * now use to get the actual transaction context. This saves
		 * use having to pack and unpack the context every time it
		 * changes, even if we don't then make a remote invocation.
		 */
            Any localData = request_info.get_slot(_localSlot);
            String threadId = null;
            boolean problem = false;
            Any data = null;
            if (localData != null && (localData.type().kind().value() != TCKind._tk_null)) {
                if ((threadId = localData.extract_string()) == null)
                    throw new UNKNOWN(jtsLogger.i18NLogger.get_orbspecific_jacorb_interceptors_interposition_invalidparam());
            } else
                threadId = ThreadUtil.getThreadId();
            if (threadId != null) {
                ControlWrapper theControl = OTSImpleManager.systemCurrent().contextManager().current(threadId);
                if (theControl != null) {
                    try {
                        Coordinator theCoordinator = theControl.get_coordinator();
                        PropagationContext ctx = null;
                        if (theCoordinator != null) {
                            ctx = theCoordinator.get_txcontext();
                            data = packPropagationContext(ctx);
                            theCoordinator = null;
                        } else
                            throw new Unavailable();
                    } catch (Unavailable ex) {
                        /*
			     * We may have to make calls during
			     * commit (e.g., after_completion)
			     * which are valid, but which will get
			     * Unavailable.
			     */
                        problem = true;
                    }
                } else
                    problem = true;
            } else
                problem = true;
            if (problem) {
                if (InterceptorInfo.getNeedTranContext())
                    throw new TRANSACTION_REQUIRED();
            }
            if (data != null) {
                byte[] octets = _codec.encode_value(data);
                ServiceContext service_context = new ServiceContext(OTSManager.serviceId, octets);
                request_info.add_request_service_context(service_context, true);
            }
        } catch (SystemException e) {
            throw e;
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new UNKNOWN(ex.toString());
        } finally {
            /**
             * If we are set to always propagate then ensure we clear the inuse flag *
             */
            if (otsAlwaysPropagate) {
                _inUse.set(null);
            }
        }
    } catch (BAD_PARAM ex) {
    // narrow failed, so not a transactional object.
    } catch (OBJECT_NOT_EXIST ex) {
    }
}
Also used : PropagationContext(org.omg.CosTransactions.PropagationContext) ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) Coordinator(org.omg.CosTransactions.Coordinator) Any(org.omg.CORBA.Any) SystemException(org.omg.CORBA.SystemException) Unavailable(org.omg.CosTransactions.Unavailable) SystemException(org.omg.CORBA.SystemException) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionalObject(org.omg.CosTransactions.TransactionalObject) UNKNOWN(org.omg.CORBA.UNKNOWN) TRANSACTION_REQUIRED(org.omg.CORBA.TRANSACTION_REQUIRED)

Aggregations

Unavailable (org.omg.CosTransactions.Unavailable)15 SystemException (org.omg.CORBA.SystemException)14 UNKNOWN (org.omg.CORBA.UNKNOWN)11 Coordinator (org.omg.CosTransactions.Coordinator)11 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)10 BAD_PARAM (org.omg.CORBA.BAD_PARAM)8 SubtransactionsUnavailable (org.omg.CosTransactions.SubtransactionsUnavailable)8 Any (org.omg.CORBA.Any)6 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)6 TransactionalObject (org.omg.CosTransactions.TransactionalObject)6 ServiceContext (org.omg.IOP.ServiceContext)6 Inactive (org.omg.CosTransactions.Inactive)5 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)4 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)4 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)4 SynchronizationUnavailable (org.omg.CosTransactions.SynchronizationUnavailable)4 NoTransaction (org.omg.CosTransactions.NoTransaction)3 PropagationContext (org.omg.CosTransactions.PropagationContext)3 OTSAbstractRecord (com.arjuna.ArjunaOTS.OTSAbstractRecord)2 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)2