use of org.omg.CosTransactions.Coordinator 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;
}
use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class SingleResourceRegistration method work.
public void work() throws PerfTestException {
try {
/**
* Retrieve ORB and OA references
*/
ORB orb = ORB.getInstance(PerformanceFramework.ORB_INSTANCE_NAME);
OA oa = OA.getRootOA(orb);
Control control = OTSManager.get_current().get_control();
Coordinator coordinator = control.get_coordinator();
DemoResource resource = new DemoResource();
oa.objectIsReady(resource);
Resource res = ResourceHelper.narrow(oa.corbaReference(resource));
coordinator.register_resource(res);
} catch (Exception e) {
e.printStackTrace(System.err);
throw new PerfTestException();
}
}
use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class CurrentImple method get_control.
public org.omg.CosTransactions.Control get_control() throws SystemException {
ControlWrapper theControl = _theManager.current();
if (theControl == null)
return null;
if (true) {
try {
return theControl.get_control();
} catch (Unavailable e) {
return null;
}
} else {
Coordinator coord = null;
try {
coord = theControl.get_coordinator();
} catch (Unavailable e) {
coord = null;
throw new UNKNOWN(ExceptionCodes.UNAVAILABLE_COORDINATOR, CompletionStatus.COMPLETED_NO);
} catch (SystemException sysEx) {
coord = null;
throw sysEx;
}
org.omg.CosTransactions.Control proxyControl = TransactionFactoryImple.createPropagatedControl(coord);
coord = null;
theControl = null;
return proxyControl;
}
}
use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class ArjunaTransactionImple method register_resource.
/**
* Resources are only registered with the current transaction, whereas
* subtransaction aware resources are registered with their parents when the
* current transaction ends.
*/
public RecoveryCoordinator register_resource(Resource r) throws SystemException, Inactive {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource ( " + r + " ) - called for " + get_uid());
}
if (r == null)
throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
currentStatus = determineStatus(this);
if (currentStatus != Status.StatusActive) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource - transaction not active: " + Utility.stringStatus(currentStatus));
}
if (currentStatus == Status.StatusMarkedRollback) {
throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.MARKED_ROLLEDBACK, CompletionStatus.COMPLETED_NO);
} else
throw new Inactive();
}
AbstractRecord corbaRec = null;
BasicAction registerIn = this;
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple " + get_uid() + " ::register_resource: ");
}
//
// Creation of recovery coordinator (DBI)
//
//
// Pack the params:
// [0] = Transaction* this
//
int index = 0;
Object[] params = new Object[10];
params[index++] = this;
RecoveryCoordinator recoveryCoordinator = null;
Uid recoveryCoordinatorUid = null;
try {
recoveryCoordinator = RecoveryCreator.createRecoveryCoordinator(r, params);
if (recoveryCoordinator == null)
throw new BAD_OPERATION("RecoveryCoordinator " + jtsLogger.i18NLogger.get_orbspecific_coordinator_rcnotcreated());
} catch (NO_IMPLEMENT ex) {
/*
* This is legal, and is meant to show that this ORB or
* configuration simply doesn't support crash recovery.
*/
recoveryCoordinator = null;
} catch (SystemException e) {
jtsLogger.i18NLogger.warn_orbspecific_coordinator_rccreate(get_uid(), e);
try {
rollback_only();
} catch (Inactive ex1) {
} catch (SystemException ex2) {
jtsLogger.i18NLogger.warn_orbspecific_coordinator_rbofail("ArjunaTransactionImple.register_resource", get_uid(), ex2);
throw ex2;
}
throw e;
}
if (recoveryCoordinator != null) {
//
// We got a RecoveryCoordinator, so unpack the other return values:
// [0] = RecoveryCoordinator Uid*
//
index = 0;
recoveryCoordinatorUid = (Uid) params[index++];
} else {
//
// We didn't get a RecoveryCoordinator, so we don't assume that
// the other return values have been populated.
//
recoveryCoordinatorUid = Uid.nullUid();
}
try {
SubtransactionAwareResource staResource = org.omg.CosTransactions.SubtransactionAwareResourceHelper.narrow(r);
if (staResource != null) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " - subtransaction aware resource: YES");
}
/*
* If here the narrow was ok so we have a subtran aware
* resource.
*/
Coordinator coord = null;
if (parentHandle != null) {
/*
* If we are a SubTranResource then we get registered with
* the current transaction and its parents upon completion.
* The first parameter to the record indicates whether we
* should be propagated (registered) with the parent
* transaction.
*/
coord = parentHandle.get_coordinator();
}
corbaRec = createOTSRecord(true, r, coord, recoveryCoordinatorUid);
coord = null;
staResource = null;
} else
throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
} catch (BAD_PARAM ex) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " - subtransaction aware resource: NO");
}
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple " + get_uid() + " ::register_resource: Simple resource - " + ex);
}
corbaRec = createOTSRecord(true, r, null, recoveryCoordinatorUid);
} catch (Unavailable e1) {
throw new Inactive();
} catch (SystemException e2) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : catch (SystemException) - " + e2);
}
throw e2;
} catch (Exception e3) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : catch (...) - " + e3);
}
throw new UNKNOWN(e3.toString(), ExceptionCodes.UNKNOWN_EXCEPTION, CompletionStatus.COMPLETED_NO);
}
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : try end");
}
if (registerIn.add(corbaRec) != AddOutcome.AR_ADDED) {
corbaRec = null;
throw new INVALID_TRANSACTION(ExceptionCodes.ADD_FAILED, CompletionStatus.COMPLETED_NO);
} else {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_resource for " + get_uid() + " : resource registered");
}
}
return recoveryCoordinator;
}
use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class ArjunaTransactionImple method register_subtran_aware.
/**
* Do not propagate the resource to the parent.
*/
public void register_subtran_aware(SubtransactionAwareResource r) throws Inactive, NotSubtransaction, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_subtran_aware called for " + get_uid());
}
if (r == null)
throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
currentStatus = determineStatus(this);
if (currentStatus != Status.StatusActive) {
if (currentStatus == Status.StatusMarkedRollback) {
throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.MARKED_ROLLEDBACK, CompletionStatus.COMPLETED_NO);
} else
throw new Inactive();
}
if (this == rootAction) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_subtran_aware called for " + get_uid() + " : not a subtransaction!");
}
throw new NotSubtransaction();
} else {
Coordinator coord = null;
AbstractRecord corbaRec = null;
try {
coord = parentHandle.get_coordinator();
corbaRec = createOTSRecord(false, r, coord);
} catch (Unavailable ex) {
throw new UNKNOWN(ExceptionCodes.INACTIVE_TRANSACTION, // what else to raise?
CompletionStatus.COMPLETED_NO);
}
coord = null;
if (add(corbaRec) != AddOutcome.AR_ADDED) {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_subtran_aware called for " + get_uid() + " : could not add.");
}
corbaRec = null;
// what else to raise??
throw new Inactive();
}
}
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ArjunaTransactionImple::register_subtran_aware called for " + get_uid() + " : subtran_aware_resource registered");
}
}
Aggregations