use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.
the class TransactionFactoryImple method getChildTransactions.
/**
* @return the list of child transactions.
*/
public org.omg.CosTransactions.otid_t[] getChildTransactions(otid_t parent) throws Inactive, NoTransaction, SystemException {
Uid u = Utility.otidToUid(parent);
org.omg.CosTransactions.otid_t[] ctx = null;
if (u == null)
throw new BAD_PARAM("otid_t " + jtsLogger.i18NLogger.get_orbspecific_otiderror());
else {
BasicAction act = ActionManager.manager().get(u);
if (act == null)
throw new NoTransaction();
else {
if (act.status() == ActionStatus.RUNNING) {
Object[] children = act.childTransactions();
int size = ((children == null) ? 0 : children.length);
if (size > 0) {
ctx = new org.omg.CosTransactions.otid_t[size];
for (int i = 0; i < size; i++) {
ctx[i] = Utility.uidToOtid((Uid) children[i]);
}
}
} else
throw new Inactive();
}
}
return ctx;
}
use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.
the class ControlWrapper method register_subtran_aware.
public final void register_subtran_aware(SubtransactionAwareResource sr) throws Inactive, NotSubtransaction, SystemException {
try {
if (_controlImpl != null)
_controlImpl.getImplHandle().register_subtran_aware(sr);
else {
try {
Coordinator coord = _control.get_coordinator();
coord.register_subtran_aware(sr);
} catch (Unavailable e2) {
throw new Inactive();
} catch (SystemException e3) {
throw new UNKNOWN();
} catch (final NullPointerException ex) {
throw new UNKNOWN();
}
}
} catch (NullPointerException e1) {
throw new Inactive();
}
}
use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.
the class ControlWrapper method register_synchronization.
public final void register_synchronization(Synchronization sync) throws Inactive, SynchronizationUnavailable, SystemException {
try {
if (_controlImpl != null)
_controlImpl.getImplHandle().register_synchronization(sync);
else {
try {
Coordinator coord = _control.get_coordinator();
coord.register_synchronization(sync);
} catch (final Unavailable e2) {
throw new Inactive();
} catch (final Exception e3) {
throw new UNKNOWN();
}
}
} catch (final NullPointerException e1) {
throw new Inactive();
}
}
use of org.omg.CosTransactions.Inactive 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;
}
use of org.omg.CosTransactions.Inactive in project narayana by jbosstm.
the class GenericRecoveryCoordinator method replay_completion.
/**
* Respond to a replay_completion request for the RecoveryCoordinator
* identified by parameter id.
*/
protected static Status replay_completion(RecoveryCoordinatorId id, Resource res) throws SystemException, NotPrepared {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("GenericRecoveryCoordinator(" + id._RCUid + ").replay_completion(" + (res != null ? "resource supplied)" : "null resource)"));
}
Status currentStatus = Status.StatusUnknown;
/*
* First check to see if the transaction is active by asking the
* per-process contact.
* If alive, return the status reported by the
* transaction. If not alive then try and recover the
* transaction from the intentions list.
*/
boolean transactionActive = true;
try {
currentStatus = get_status(id._actionUid, id._originalProcessUid);
} catch (Inactive e) {
// original process is dead.
transactionActive = false;
}
if (currentStatus == Status.StatusNoTransaction) {
/*
* There is no intentions list, so the transaction either
* committed or rolled back. However, this routine is only
* ever called by replay_completion, which means that there
* is a resource (hopefully one which was participating in
* the transaction) that is in doubt as to the
* transaction's outcome. If the transaction had committed,
* then this resource would know of the outcome. Therefore,
* it must have rolled back!
*/
/*
* Unfortunately the last statement is wrong. There is a timing
* issue here: the resource recovery may be doing an upcall while
* the downcall (from coordinator recovery) is going on and
* removing the log. What can then happen is that a resource may
* see a commit folled by a rollback.
*/
currentStatus = Status.StatusRolledBack;
}
if (!transactionActive) {
// original process is dead, so reasonable for us to try to
// recover
/*
* The RecoveredTransactionReplayer is a threaded object
* so we can get the status and return it while the
* replayer does the phase 2 commit in a new thread.
*/
String tranType = ((id._isServerTransaction) ? ServerTransaction.typeName() : ArjunaTransactionImple.typeName());
try {
if (id._isServerTransaction && (StoreManager.getRecoveryStore().currentState(id._actionUid, ServerTransaction.typeName() + "/JCA") != StateStatus.OS_UNKNOWN)) {
tranType = tranType + "/JCA";
}
} catch (ObjectStoreException e) {
// Can't read store
}
com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer replayer = new com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer(id._actionUid, tranType);
// this will cause the activatation attempt
currentStatus = replayer.getStatus();
if ((replayer.getRecoveryStatus() != com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus.ACTIVATE_FAILED) && (res != null)) {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("GenericRecoveryCoordinator - swapping Resource for RC " + id._RCUid);
}
replayer.swapResource(id._RCUid, res);
}
if (replayer.getRecoveryStatus() != com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus.ACTIVATE_FAILED) {
replayer.replayPhase2();
} else {
replayer.tidyup();
/*
* The transaction didn't activate so we have a
* rollback situation but we can't rollback the
* resource that we have been given through the
* intentions list but we can issue rollback
* directly. This is configurable through the System
* properties.
*/
currentStatus = Status.StatusRolledBack;
}
}
if (currentStatus == Status.StatusRolledBack) {
if (_issueRecoveryRollback) {
ResourceCompletor resourceCompletor = new ResourceCompletor(res, ResourceCompletor.ROLLBACK);
resourceCompletor.start();
}
}
if (currentStatus == Status.StatusActive)
throw new NotPrepared();
return currentStatus;
}
Aggregations