Search in sources :

Example 1 with NO_MEMORY

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

the class Helper method getUid.

public static final Uid getUid(UidCoordinator coord) {
    if (coord == null)
        return Uid.nullUid();
    String theUid = null;
    Uid uid = null;
    for (int i = 0; i < 1; i++) {
        try {
            theUid = coord.uid();
            uid = new Uid(theUid);
            theUid = null;
            return uid;
        } catch (OutOfMemoryError e) {
            System.gc();
        }
    }
    throw new NO_MEMORY(0, CompletionStatus.COMPLETED_NO);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) NO_MEMORY(org.omg.CORBA.NO_MEMORY)

Example 2 with NO_MEMORY

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

the class TransactionFactoryImple method createLocal.

/**
 * This creates a local instance of a transaction control, but does not
 * register it with the ORB. Either call its getControl method directly, or
 * use the create method of the factory.
 */
public ControlImple createLocal(int time_out) throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("TransactionFactoryImple::createLocal ( " + time_out + " )");
    }
    try {
        ControlImple tranControl = new ControlImple((Control) null, (ArjunaTransactionImple) null);
        int theTimeout = time_out;
        if (theTimeout == 0)
            theTimeout = TxControl.getDefaultTimeout();
        if (theTimeout > 0) {
            /*
				 * Currently we do not remove controls from the list once they
				 * have terminated. We should to save time and space!
				 */
            TransactionReaper reaper = TransactionReaper.transactionReaper();
            reaper.insert(new ControlWrapper((ControlImple) tranControl), theTimeout);
        }
        return tranControl;
    } catch (OutOfMemoryError e) {
        /*
			 * Rather than try again after running gc simply return and let the
			 * user deal with it. May help with memory!
			 */
        System.gc();
        throw new NO_MEMORY(0, CompletionStatus.COMPLETED_NO);
    }
}
Also used : NO_MEMORY(org.omg.CORBA.NO_MEMORY) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionReaper(com.arjuna.ats.arjuna.coordinator.TransactionReaper)

Example 3 with NO_MEMORY

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

the class CurrentImple method begin.

public void begin() throws SubtransactionsUnavailable, SystemException {
    ControlWrapper currentAction = _theManager.current();
    if (// no current, so create top-level action
    currentAction == null) {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("CurrentImple::begin - creating new top-level transaction.");
        }
        if (OTSImpleManager.localFactory())
            currentAction = new ControlWrapper(OTSImpleManager.factory().createLocal(get_timeout()));
        else
            currentAction = new ControlWrapper(OTSImpleManager.get_factory().create(get_timeout()));
    } else {
        if (jtsLogger.logger.isTraceEnabled()) {
            jtsLogger.logger.trace("CurrentImple::begin - creating new subtransaction.");
        }
        try {
            currentAction = currentAction.create_subtransaction();
        } catch (Unavailable ex) {
            throw new INVALID_TRANSACTION(ExceptionCodes.UNAVAILABLE_COORDINATOR, CompletionStatus.COMPLETED_NO);
        } catch (Inactive e) {
            throw new INVALID_TRANSACTION(ExceptionCodes.INACTIVE_TRANSACTION, CompletionStatus.COMPLETED_NO);
        } catch (NO_MEMORY nme) {
            System.gc();
            throw nme;
        } catch (SystemException sysEx) {
            throw new INVALID_TRANSACTION(ExceptionCodes.INACTIVE_TRANSACTION, CompletionStatus.COMPLETED_NO);
        } catch (OutOfMemoryError me) {
            System.gc();
            throw new NO_MEMORY(0, CompletionStatus.COMPLETED_NO);
        }
    }
    _theManager.pushAction(currentAction);
    try {
        ThreadAssociationControl.updateAssociation(currentAction, TX_BEGUN);
    } catch (Exception e) {
        try {
            rollback_only();
        } catch (Exception ex) {
        }
    }
    currentAction = null;
}
Also used : NO_MEMORY(org.omg.CORBA.NO_MEMORY) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) Inactive(org.omg.CosTransactions.Inactive) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable)

Aggregations

NO_MEMORY (org.omg.CORBA.NO_MEMORY)3 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 TransactionReaper (com.arjuna.ats.arjuna.coordinator.TransactionReaper)1 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)1 SystemException (org.omg.CORBA.SystemException)1 UserException (org.omg.CORBA.UserException)1 Inactive (org.omg.CosTransactions.Inactive)1 SubtransactionsUnavailable (org.omg.CosTransactions.SubtransactionsUnavailable)1 Unavailable (org.omg.CosTransactions.Unavailable)1