use of org.omg.CosTransactions.Status in project narayana by jbosstm.
the class RecoveredServerTransaction method getStatusFromParent.
private Status getStatusFromParent() {
Status theStatus = Status.StatusUnknown;
// This variable is applied with Orbix
int not_exist_count;
if ((super._recoveryCoordinator != null) && (get_status() == Status.StatusPrepared)) {
ServerControl sc = new ServerControl((ServerTransaction) this);
ServerRecoveryTopLevelAction tla = new ServerRecoveryTopLevelAction(sc);
if (tla.valid()) {
try {
theStatus = super._recoveryCoordinator.replay_completion(tla.getReference());
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("RecoveredServerTransaction.getStatusFromParent - replay_completion status = " + Utility.stringStatus(theStatus));
}
} catch (TRANSIENT ex_trans) {
/*
* A failure that might not occur again if the request is retried. Not definite.
*/
jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_10(get_uid());
theStatus = Status.StatusUnknown;
}// What here what should be done for Orbix2000
catch (OBJECT_NOT_EXIST ex) {
// i believe this state should be notran - ots explicitly
// objnotexist is
// rollback
theStatus = Status.StatusRolledBack;
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("RecoveredServerTransaction.getStatusFromParent -" + " replay_completion got object_not_exist = " + Utility.stringStatus(theStatus));
}
} catch (NotPrepared ex1) {
jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_12();
theStatus = Status.StatusActive;
} catch (Exception e) {
// Unknown error, so better to do nothing at this stage.
jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_13(e);
}
} else {
jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredServerTransaction_14(get_uid());
}
// Make sure we "delete" these objects when we are finished
// with them or there will be a memory leak. If they are deleted
// "early", and the root coordinator needs them then it will find
// them unavailable, and will have to retry recovery later.
sc = null;
tla = null;
} else {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("RecoveredServerTransaction:getStatusFromParent - " + "no recovcoord or status not prepared");
}
}
return theStatus;
}
use of org.omg.CosTransactions.Status 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;
}
use of org.omg.CosTransactions.Status in project narayana by jbosstm.
the class GenericRecoveryCoordinator method get_status.
private static Status get_status(Uid actionUid, Uid processUid) throws Inactive {
Status status = Status.StatusUnknown;
boolean transactionActive = true;
try {
status = StatusChecker.get_current_status(actionUid, processUid);
} catch (Inactive e) {
// original process is dead.
transactionActive = false;
}
boolean hasBeenRecovering = false;
for (; ; ) {
if (transactionActive) {
Object o = com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer.isPresent(actionUid);
if (o != null) {
hasBeenRecovering = true;
synchronized (o) {
try {
o.wait();
} catch (Exception e) {
}
}
} else {
if (hasBeenRecovering)
throw new Inactive();
else
break;
}
} else
throw new Inactive();
}
return status;
}
use of org.omg.CosTransactions.Status in project narayana by jbosstm.
the class StatusChecker method getStatus.
/**
* try to get the status from a factory and convert to our way.
* factory must not be null
* itemUid is the store id as in _itemFromUid
*/
private Status getStatus(Uid transactionUid, FactoryContactItem item, boolean checkTheObjectStore) throws Inactive {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ", " + item + ", " + checkTheObjectStore + ")");
}
ArjunaFactory factory = item.getFactory();
if (factory != null) {
Status otsStatus = Status.StatusUnknown;
boolean originalDead = false;
try {
otid_t otid = Utility.uidToOtid(transactionUid);
otsStatus = factory.getCurrentStatus(otid);
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - current status = " + Utility.stringStatus(otsStatus));
}
if (otsStatus == Status.StatusNoTransaction) {
otsStatus = factory.getStatus(otid);
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - stored status = " + Utility.stringStatus(otsStatus));
}
switch(otsStatus.value()) {
case Status._StatusNoTransaction:
// return Status.StatusRolledBack;
return otsStatus;
case Status._StatusUnknown:
return otsStatus;
default:
{
/*
* We got an answer! This probably means that the
* factory has just finished with the transaction, but
* the state hasn't been removed by the file system yet
* - we don't sync the removal to improve performance.
*/
jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_3(transactionUid);
otsStatus = Status.StatusUnknown;
}
break;
}
}
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - Status = " + Utility.stringStatus(otsStatus));
}
item.markAsAlive();
} catch (NO_IMPLEMENT ex_noimp) {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - NO_IMPLEMENT = dead");
}
originalDead = true;
// orbix seems to count unreachable as transient. Over infinite time, all
// addresses are valid
} catch (TRANSIENT ex_trans) {
if (ORBInfo.getOrbEnumValue() == ORBType.JACORB) {
// the original application has (probably) died
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - TRANSIENT = dead");
}
originalDead = true;
}
} catch (COMM_FAILURE ex_comm) {
if (ORBInfo.getOrbEnumValue() == ORBType.JAVAIDL) {
// the original application has (probably) died
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - COMM_FAILURE = dead");
}
originalDead = true;
} else /*
* Probably the original application has died, but only just - do
* not mark either way.
*/
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - COMM_FAILURE = live");
}
} catch (OBJECT_NOT_EXIST ex_noobj) {
// the original process must have gone away, and another one
// come up in the same place
// (or, just possibly, the original closed the ots)
originalDead = true;
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - OBJECT_NOT_EXIST = dead");
}
} catch (BAD_PARAM ex_badparam) {
jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_9();
// the transactionUid is invalid !
} catch (NoTransaction ex_notran) {
jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_10();
// the transactionUid is invalid !
// no transaction
} catch (SystemException ex_corba) {
// why did this happen ?
if (ORBInfo.getOrbEnumValue() == ORBType.JAVAIDL) {
// the original application has (probably) died
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - COMM_FAILURE = dead");
}
originalDead = true;
}
jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_11(ex_corba);
} catch (Exception ex_other) {
// this really shouldn't happen
jtsLogger.i18NLogger.warn_recovery_contact_StatusChecker_12(ex_other);
}
if (originalDead) {
item.markAsDead();
throw new Inactive();
} else {
return otsStatus;
}
} else {
// factory in item is null - process already dead
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("StatusChecker.getStatus(" + transactionUid + ") - no factory, process previously dead");
}
if (checkTheObjectStore) {
try {
Status s = OTSManager.factory().getStatus(transactionUid);
if (s == Status.StatusCommitting)
return Status.StatusCommitted;
else {
if (s == Status.StatusRollingBack)
return Status.StatusRolledBack;
}
return s;
} catch (NoTransaction e1) {
return Status.StatusNoTransaction;
} catch (SystemException e2) {
return Status.StatusUnknown;
}
} else {
throw new Inactive();
}
}
}
use of org.omg.CosTransactions.Status in project narayana by jbosstm.
the class ServerSynchronization method after_completion.
public void after_completion(org.omg.CosTransactions.Status status) throws SystemException {
if (_theTransaction == null) {
destroy();
throw new BAD_OPERATION(ExceptionCodes.NO_TRANSACTION, CompletionStatus.COMPLETED_NO);
} else {
/*
* Check that the given status is the same as our status. It should
* be!
*/
org.omg.CosTransactions.Status myStatus = org.omg.CosTransactions.Status.StatusUnknown;
try {
myStatus = _theTransaction.get_status();
} catch (Exception e) {
myStatus = org.omg.CosTransactions.Status.StatusUnknown;
}
if (myStatus != status) {
jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_stateerror("ServerSynchronization.after_completion", Utility.stringStatus(myStatus), Utility.stringStatus(status));
if (myStatus == Status.StatusActive) {
try {
_theTransaction.rollback();
} catch (Exception e) {
}
try {
status = _theTransaction.get_status();
} catch (Exception e) {
status = Status.StatusUnknown;
}
}
}
_theTransaction.doAfterCompletion(status);
}
/*
* Now dispose of self.
*/
destroy();
}
Aggregations