Search in sources :

Example 6 with UNKNOWN

use of org.omg.CORBA.UNKNOWN in project ACS by ACS-Community.

the class ManagerProxyImpl method restart_component.

/**
	 * Restarts an component.
	 * @param	id 	identification of the caller. Called has to be an owner of the component.
	 * @param	component_url	CURL of the component to be restarted.
	 * @return	CORBA reference of the restarted component, <code>null</code> if it fails.
	 */
public Object restart_component(int id, String component_url) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // transform to CORBA specific
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        Component component = manager.restartComponent(id, uri);
        // extract component CORBA reference
        if (component != null)
            retVal = (Object) component.getObject();
        return retVal;
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } catch (BadParametersException bpe) {
        BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(bpe.getMessage());
    } catch (NoResourcesException nre) {
        NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
        reportException(hnre);
        // rethrow CORBA specific
        throw new NO_RESOURCES(nre.getMessage());
    } catch (AcsJBadParameterEx bpe) {
        reportException(bpe);
        //throw bpe.toBadParameterEx();
        throw new BAD_PARAM(bpe.getMessage());
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 7 with UNKNOWN

use of org.omg.CORBA.UNKNOWN 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 8 with UNKNOWN

use of org.omg.CORBA.UNKNOWN in project narayana by jbosstm.

the class ArjunaTransactionImple method doAfterCompletion.

protected void doAfterCompletion(org.omg.CosTransactions.Status myStatus) throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ArjunaTransactionImple::doAfterCompletion for " + get_uid());
    }
    if (myStatus == Status.StatusActive) {
        jtsLogger.i18NLogger.warn_orbspecific_coordinator_txrun("ArjunaTransactionImple.doAfterCompletion");
        return;
    }
    boolean problem = false;
    SystemException exp = null;
    if (_synchs != null) {
        ControlWrapper cw = null;
        boolean doSuspend = false;
        try {
            // cw = OTSImpleManager.systemCurrent().getControlWrapper();
            cw = OTSImpleManager.current().getControlWrapper();
            if ((cw == null) || (!controlHandle.equals(cw.getImple()))) {
                // OTSImpleManager.systemCurrent().resumeImple(controlHandle);
                OTSImpleManager.current().resumeImple(controlHandle);
                doSuspend = true;
            }
        } catch (Exception ex) {
            /*
	             * It should still be OK to make the call without a context
	             * because a Synchronization can only be associated with a
	             * single transaction.
	             */
            problem = true;
        }
        /*
	         * Regardless of failures, we must tell all synchronizations what
	         * happened.
	         */
        // afterCompletions should run in reverse order compared to beforeCompletions
        Stack stack = new Stack();
        Iterator iterator = _synchs.iterator();
        while (iterator.hasNext()) {
            stack.push(iterator.next());
        }
        iterator = stack.iterator();
        /*
	         * Regardless of failures, we must tell all synchronizations what
	         * happened.
	         */
        while (!stack.isEmpty()) {
            SynchronizationRecord value = (SynchronizationRecord) stack.pop();
            Synchronization c = value.contents();
            try {
                c.after_completion(myStatus);
            } catch (SystemException e) {
                if (jtsLogger.logger.isTraceEnabled()) {
                    jtsLogger.logger.trace("ArjunaTransactionImple.doAfterCompletion - caught exception " + e);
                }
                problem = true;
                if (exp == null)
                    exp = e;
            }
        }
        if (doSuspend) {
            try {
                if (cw != null)
                    OTSImpleManager.current().resumeWrapper(cw);
                else
                    OTSImpleManager.current().suspend();
            } catch (Exception ex) {
            }
        }
        _synchs = null;
    }
    boolean superProblem = !super.afterCompletion(myStatus == Status.StatusCommitted ? ActionStatus.COMMITTED : ActionStatus.ABORTED);
    if (problem || superProblem) {
        if (exp != null)
            throw exp;
        else
            throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION, CompletionStatus.COMPLETED_NO);
    }
}
Also used : SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) Iterator(java.util.Iterator) UNKNOWN(org.omg.CORBA.UNKNOWN) Synchronization(org.omg.CosTransactions.Synchronization) ManagedSynchronization(com.arjuna.ArjunaOTS.ManagedSynchronization) SystemException(org.omg.CORBA.SystemException) SynchronizationRecord(com.arjuna.ats.internal.jts.resources.SynchronizationRecord) Stack(java.util.Stack)

Example 9 with UNKNOWN

use of org.omg.CORBA.UNKNOWN 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 10 with UNKNOWN

use of org.omg.CORBA.UNKNOWN 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)

Aggregations

UNKNOWN (org.omg.CORBA.UNKNOWN)51 SystemException (org.omg.CORBA.SystemException)32 BAD_PARAM (org.omg.CORBA.BAD_PARAM)27 Coordinator (org.omg.CosTransactions.Coordinator)15 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)14 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)13 BadParametersException (com.cosylab.acs.maci.BadParametersException)13 CoreException (com.cosylab.acs.maci.CoreException)13 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)13 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)12 Unavailable (org.omg.CosTransactions.Unavailable)11 Any (org.omg.CORBA.Any)9 Object (org.omg.CORBA.Object)8 URI (java.net.URI)7 URISyntaxException (java.net.URISyntaxException)7 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 BAD_OPERATION (org.omg.CORBA.BAD_OPERATION)6 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)6 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)6 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)6