use of org.omg.CosTransactions.Status in project narayana by jbosstm.
the class TransactionCache method get_status.
/**
* Get the status of a transaction
*/
public static Status get_status(Uid actionUid, String theType) throws SystemException {
Status theStatus = Status.StatusUnknown;
TransactionCacheItem cacheItem = get(actionUid, theType);
if (cacheItem != null) {
synchronized (cacheItem) {
RecoveringTransaction theTransaction = cacheItem.freshTransaction();
if (theTransaction != null) {
theStatus = theTransaction.get_status();
// remember the status in the cacheitem
cacheItem.setStatus(theStatus);
}
}
}
return theStatus;
}
use of org.omg.CosTransactions.Status in project narayana by jbosstm.
the class RecoveredServerTransaction method getStatusFromParent.
private Status getStatusFromParent() {
org.omg.CosTransactions.Status theStatus = org.omg.CosTransactions.Status.StatusUnknown;
// This variable is applied with Orbix
int not_exist_count;
if ((super._recoveryCoordinator != null) && (get_status() == org.omg.CosTransactions.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 = org.omg.CosTransactions.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 RecoveredTransaction method replayPhase2.
/**
* Causes phase 2 of the commit protocol to be replayed.
*/
public void replayPhase2() {
_recoveryStatus = RecoveryStatus.REPLAYING;
Status theStatus = get_status();
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("RecoveredTransaction.replayPhase2 (" + get_uid() + ") - status = " + Utility.stringStatus(theStatus));
}
if ((theStatus == Status.StatusPrepared) || (theStatus == Status.StatusCommitting) || (theStatus == Status.StatusCommitted)) {
phase2Commit(_reportHeuristics);
_recoveryStatus = RecoveryStatus.REPLAYED;
_txStatus = Status.StatusCommitted;
} else if ((theStatus == Status.StatusRolledBack) || (theStatus == Status.StatusRollingBack) || (theStatus == Status.StatusMarkedRollback)) {
phase2Abort(_reportHeuristics);
_recoveryStatus = RecoveryStatus.REPLAYED;
_txStatus = Status.StatusRolledBack;
} else {
jtsLogger.i18NLogger.warn_recovery_transactions_RecoveredTransaction_6(Utility.stringStatus(theStatus));
_recoveryStatus = RecoveryStatus.REPLAY_FAILED;
}
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("RecoveredTransaction.replayPhase2 (" + get_uid() + ") - status = " + Utility.stringStatus(theStatus));
}
}
use of org.omg.CosTransactions.Status in project narayana by jbosstm.
the class ServerTransactionRecoveryModule method recoverTransaction.
protected void recoverTransaction(Uid tranUid) {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("ServerTransactionRecoveryModule.recoverTransaction()" + tranUid + ")");
}
Status currentStatus = Status.StatusUnknown;
CachedRecoveredTransaction cachedRecoveredTransaction = new CachedRecoveredTransaction(tranUid, _transactionType);
currentStatus = cachedRecoveredTransaction.get_status();
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("Activated transaction " + tranUid + " status = " + Utility.stringStatus(currentStatus));
}
// but first check that the original transaction isn't in mid-flight
if (cachedRecoveredTransaction.originalBusy() && (currentStatus != Status.StatusPrepared)) {
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("Transaction " + tranUid + " still busy");
}
return;
}
cachedRecoveredTransaction.replayPhase2();
cachedRecoveredTransaction = null;
}
use of org.omg.CosTransactions.Status in project narayana by jbosstm.
the class SynchTest method test.
@Test
public void test() {
org.omg.CosTransactions.Status status = Status.StatusUnknown;
tranobject_i localObject = null;
demosync sync = null;
ORB myORB = null;
RootOA myOA = null;
try {
ServerORB orb = new ServerORB();
myORB = orb.getORB();
myOA = orb.getOA();
Control myControl = null;
org.omg.CosTransactions.Current current = OTSManager.get_current();
Coordinator coord = null;
sync = new demosync();
localObject = new tranobject_i();
current.begin();
myControl = current.get_control();
coord = myControl.get_coordinator();
coord.register_resource(localObject.getReference());
coord.register_synchronization(sync.getReference());
try {
current.commit(true);
} catch (TRANSACTION_ROLLEDBACK e1) {
System.out.println("Transaction rolledback");
}
try {
status = coord.get_status();
} catch (SystemException ex) {
// assume reference no longer valid!
status = Status.StatusUnknown;
}
} catch (UserException e1) {
fail("Caught UserException: " + e1);
e1.printStackTrace();
} catch (SystemException e2) {
fail("Caught SystemException: " + e2);
e2.printStackTrace();
}
System.out.print("Final action status: " + com.arjuna.ats.jts.utils.Utility.stringStatus(status));
System.out.println("\nTest completed successfully.");
myOA.shutdownObject(sync);
myOA.shutdownObject(localObject);
myOA.destroy();
myORB.shutdown();
}
Aggregations