Search in sources :

Example 1 with GlobalTID

use of com.sun.jts.CosTransactions.GlobalTID in project Payara by payara.

the class TransactionManagerImpl method recreate.

/**
 * Recreate a transaction based on the Xid. This call causes the calling
 * thread to be associated with the specified transaction.
 *
 * @param xid the Xid object representing a transaction.
 * @param timeout positive, non-zero value for transaction timeout.
 */
public static void recreate(Xid xid, long timeout) throws WorkException {
    // check if xid is valid
    if (xid == null || xid.getFormatId() == 0 || xid.getBranchQualifier() == null || xid.getGlobalTransactionId() == null) {
        WorkException workExc = new WorkCompletedException("Invalid Xid");
        workExc.setErrorCode(WorkException.TX_RECREATE_FAILED);
        throw workExc;
    }
    // has TransactionService been initialized?
    if (!DefaultTransactionService.isActive()) {
        WorkException workExc = new WorkCompletedException("Transaction Manager unavailable");
        workExc.setErrorCode(WorkException.TX_RECREATE_FAILED);
        throw workExc;
    }
    // recreate the transaction
    GlobalTID tid = new GlobalTID(xid);
    try {
        CurrentTransaction.recreate(tid, (int) ((timeout <= 0) ? 0 : timeout));
    } catch (Throwable exc) {
        String errorCode = WorkException.TX_RECREATE_FAILED;
        if (exc instanceof INVALID_TRANSACTION && (((INVALID_TRANSACTION) exc).minor == MinorCode.TX_CONCURRENT_WORK_DISALLOWED)) {
            errorCode = WorkException.TX_CONCURRENT_WORK_DISALLOWED;
        }
        WorkException workExc = new WorkCompletedException(exc);
        workExc.setErrorCode(errorCode);
        throw workExc;
    }
}
Also used : WorkException(javax.resource.spi.work.WorkException) GlobalTID(com.sun.jts.CosTransactions.GlobalTID) WorkCompletedException(javax.resource.spi.work.WorkCompletedException)

Example 2 with GlobalTID

use of com.sun.jts.CosTransactions.GlobalTID in project Payara by payara.

the class FailureInducer method getGlobalTID.

private static GlobalTID getGlobalTID() {
    GlobalTID gtid = null;
    Coordinator coord = Utility.getCoordinator(Utility.getControl());
    JCoordinator jcoord = JCoordinatorHelper.narrow(coord);
    if (jcoord != null) {
        gtid = new GlobalTID(jcoord.getGlobalTID());
    } else {
        ControlImpl control = CurrentTransaction.getCurrent();
        if (control != null) {
            gtid = control.getGlobalTID();
        }
    }
    return gtid;
}
Also used : JCoordinator(com.sun.jts.codegen.otsidl.JCoordinator) ControlImpl(com.sun.jts.CosTransactions.ControlImpl) JCoordinator(com.sun.jts.codegen.otsidl.JCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) GlobalTID(com.sun.jts.CosTransactions.GlobalTID)

Example 3 with GlobalTID

use of com.sun.jts.CosTransactions.GlobalTID in project Payara by payara.

the class FailureInducer method setWaitPoint.

/**
 * Setting a wait point will cause the TM to wait at the
 * failure point, for the stipulated wait duration.
 *
 * @param crashPoint pre-defined failure points
 *  (PREPARING, PREPARED, COMMITTING, COMMITTED).
 * @param waitDuration time duration (seconds) for RM failure to happen.
 */
public static void setWaitPoint(Integer waitPoint, int waitDuration) {
    // sanity check
    if (waitPoint == null) {
        _logger.log(Level.SEVERE, "jts.invalid_wait_point");
        return;
    }
    GlobalTID gtid = getGlobalTID();
    if (gtid != null) {
        waitList.put(gtid, waitPoint);
        waitTime.put(gtid, waitDuration);
    }
}
Also used : GlobalTID(com.sun.jts.CosTransactions.GlobalTID)

Example 4 with GlobalTID

use of com.sun.jts.CosTransactions.GlobalTID in project Payara by payara.

the class TransactionManagerImpl method createTransactionImpl.

/**
 *    TransactionState getOrCreateTransactionState(GlobalTID gtid,
 *                                                 Transaction tran)
 *        throws SystemException {
 *
 *        synchronized (transactionStates) {
 *            TransactionState result =
 *                (TransactionState) transactionStates.get(gtid);
 *            if (result == null) {
 *                result = new TransactionState(gtid);
 *                transactionStates.put(gtid, result);
 *                try {
 *                    // remove Transaction State on transaction completion
 *                    Synchronization sync =
 *                        new SynchronizationListener(gtid, result);
 *                    tran.registerSynchronization(sync);
 *                } catch (Exception ex) {
 *					_logger.log(Level.WARNING,
 *							"jts.unexpected_error_in_get_or_create_transaction_state",ex);
 *                    throw new SystemException();
 *                }
 *            }
 *            return result;
 *        }
 *    }
 *
 *    TransactionState getTransactionState(GlobalTID gtid,
 *                                         Transaction tran)
 *        throws SystemException {
 *
 *        synchronized (transactionStates) {
 *            return (TransactionState) transactionStates.get(gtid);
 *        }
 *    }
 */
private Transaction createTransactionImpl(Control control) throws Unavailable, SystemException {
    GlobalTID gtid = null;
    if (Configuration.isLocalFactory()) {
        gtid = ((ControlImpl) control).getGlobalTID();
    } else {
        ControlImpl cntrlImpl = ControlImpl.servant(JControlHelper.narrow(control));
        gtid = cntrlImpl.getGlobalTID();
    }
    // return new TransactionImpl(this, control, gtid);
    return new TransactionImpl(control, gtid);
}
Also used : GlobalTID(com.sun.jts.CosTransactions.GlobalTID)

Aggregations

GlobalTID (com.sun.jts.CosTransactions.GlobalTID)4 ControlImpl (com.sun.jts.CosTransactions.ControlImpl)1 JCoordinator (com.sun.jts.codegen.otsidl.JCoordinator)1 WorkCompletedException (javax.resource.spi.work.WorkCompletedException)1 WorkException (javax.resource.spi.work.WorkException)1 Coordinator (org.omg.CosTransactions.Coordinator)1