use of org.omg.CosTransactions.NoTransaction in project narayana by jbosstm.
the class TransactionFactoryImple method getTransactionInfo.
/**
* @return information on a specific transaction.
* @since JTS 2.1.2.
*/
public TransactionInfo getTransactionInfo(Uid u) throws org.omg.CosTransactions.NoTransaction, SystemException {
if (!u.valid())
throw new BAD_PARAM(jtsLogger.i18NLogger.get_orbspecific_invaliduid() + " " + u);
else {
try {
synchronized (ControlImple.allControls) {
ControlImple ctx = (ControlImple) ControlImple.allControls.get(u);
if (ctx != null) {
TransactionInfo info = new TransactionInfo();
info.currentDepth = ctx.getImplHandle().getHierarchy().depth();
TransactionReaper reaper = TransactionReaper.transactionReaper();
info.timeout = reaper.getTimeout(ctx);
info.numberOfThreads = ctx.getImplHandle().activeThreads();
return info;
} else
throw new NoTransaction();
}
} catch (NoTransaction ex) {
throw ex;
} catch (Exception e) {
e.printStackTrace();
throw new UNKNOWN();
}
}
}
use of org.omg.CosTransactions.NoTransaction 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.NoTransaction in project narayana by jbosstm.
the class tx method tx_rollback.
/**
* This needs to implement checked transactions such that only the
* transaction initiator (thread) can terminate it.
*/
public static final synchronized int tx_rollback() {
int toReturn = tx.TX_OK;
CurrentImple current = OTSImpleManager.current();
try {
current.rollback();
} catch (NoTransaction e1) {
toReturn = tx.TX_NO_BEGIN;
} catch (Exception e2) {
toReturn = tx.TX_FAIL;
}
return toReturn;
}
use of org.omg.CosTransactions.NoTransaction in project narayana by jbosstm.
the class TransactionFactoryUnitTest method testBasic.
@Test
public void testBasic() throws Exception {
TransactionFactoryImple factory = new TransactionFactoryImple("test");
arjPropertyManager.getCoordinatorEnvironmentBean().setEnableStatistics(true);
try {
factory.numberOfTransactions(TransactionType.TransactionTypeActive);
// fail();
} catch (final Inactive ex) {
} catch (final NoTransaction ex) {
}
ControlImple tx = factory.createLocal(1000);
assertTrue(tx != null);
org.omg.CosTransactions.otid_t[] txId = null;
try {
txId = factory.numberOfTransactions(TransactionType.TransactionTypeActive);
} catch (final Throwable ex) {
fail();
}
try {
if (factory.getChildTransactions(txId[0]) != null)
fail();
} catch (final Throwable ex) {
fail();
}
org.omg.CosTransactions.Status status = factory.getCurrentStatus(txId[0]);
assertTrue(status == org.omg.CosTransactions.Status.StatusActive);
assertTrue(factory.getStatus(txId[0]) == org.omg.CosTransactions.Status.StatusActive);
Control proxy = factory.createProxy(tx.get_coordinator(), tx.get_terminator());
assertTrue(proxy != null);
Control propagated = factory.createPropagatedControl(tx.get_coordinator());
assertTrue(propagated != null);
assertTrue(Utility.getUid(proxy).equals(Utility.getUid(propagated)));
GlobalTransactionInfo info = factory.getGlobalInfo();
assertTrue(info != null);
assertEquals(info.totalNumberOfTransactions, 1);
assertEquals(info.numberOfHeuristics, 0);
factory.numberOfTransactions(TransactionType.TransactionTypeUnresolved);
try {
tx.getImplHandle().rollback();
} catch (final Throwable ex) {
}
}
use of org.omg.CosTransactions.NoTransaction in project narayana by jbosstm.
the class Test01 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
boolean correct = true;
Current current = OTS.get_current();
try {
current.commit(true);
correct = false;
} catch (NoTransaction noTransaction) {
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Test01.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Test01.main: " + exception);
exception.printStackTrace(System.err);
}
}
Aggregations