use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class LogWriteStateManager method modified.
protected synchronized boolean modified() {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("StateManager::modified() for object-id " + get_uid());
}
if ((super.objectType() == ObjectType.RECOVERABLE) && (super.objectModel == ObjectModel.SINGLE))
return super.modified();
BasicAction action = BasicAction.Current();
if ((super.objectType() == ObjectType.NEITHER) || (super.status() == ObjectStatus.DESTROYED)) /* NEITHER => no recovery info */
{
return true;
}
if (super.status() == ObjectStatus.PASSIVE) {
tsLogger.i18NLogger.warn_StateManager_10();
activate();
}
if (status() == ObjectStatus.PASSIVE_NEW)
setStatus(ObjectStatus.ACTIVE_NEW);
if (action != null) {
/*
* Check if this is the first call to modified in this action.
* BasicList insert returns FALSE if the entry is already
* present.
*/
createLists();
synchronized (modifyingActions) {
if ((modifyingActions.size() > 0) && (modifyingActions.get(action.get_uid()) != null)) {
return true;
} else
modifyingActions.put(action.get_uid(), action);
}
/* If here then its a new action */
OutputObjectState state = new OutputObjectState(objectUid, type());
int rStatus = AddOutcome.AR_ADDED;
if (save_state(state, ObjectType.RECOVERABLE)) {
TxLogWritePersistenceRecord record = new TxLogWritePersistenceRecord(state, super.getStore(), this);
if ((rStatus = action.add(record)) != AddOutcome.AR_ADDED) {
synchronized (modifyingActions) {
// remember to unregister with action
modifyingActions.remove(action.get_uid());
}
record = null;
return false;
}
} else
return false;
}
return true;
}
use of com.arjuna.ats.arjuna.coordinator.BasicAction 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 com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class GenericRecoveryCreator method create.
/**
* Create a new RecoveryCoordinator for Resource res. The params
* array is used to pass additional data. Currently params[0] is
* the ArjunaTransactionImple ref. When create returns additional data is
* passed back using params. Currently returned params[0] is the
* RecoveryCoordinator Uid.
*/
public RecoveryCoordinator create(Resource res, Object[] params) throws SystemException {
RecoveryCoordinator recoveryCoordinator = null;
if (jtsLogger.logger.isDebugEnabled()) {
jtsLogger.logger.debug("GenericRecoveryCreator.create()");
}
// we dont use the res parameter in this version
if ((params != null) && (params[0] != null)) {
int index = 0;
ArjunaTransactionImple otsTransaction = (ArjunaTransactionImple) params[index++];
// Get the Uid of the top-level transaction. This will be
// the top-level interposed transaction in the case of
// interposition.
BasicAction rootAction = otsTransaction;
while ((rootAction.parent()) != null) rootAction = rootAction.parent();
Uid rootActionUid = rootAction.getSavingUid();
// Uid processUid = Utility.getProcessUid();
Uid processUid = com.arjuna.ats.arjuna.utils.Utility.getProcessUid();
// Create a Uid for the new RecoveryCoordinator
Uid RCUid = new Uid();
// Is this transaction a ServerTransaction?
boolean isServerTransaction = (otsTransaction instanceof ServerTransaction);
// Now ask the orb-specific bit to make the RecoveryCoordinator IOR
// (it may or may not actually make the RC itself)
recoveryCoordinator = _orbSpecificManager.makeRC(RCUid, rootActionUid, processUid, isServerTransaction);
// Tidy up
otsTransaction = null;
rootAction = null;
// Pass the RecoveryCoordinator Uid back
params[0] = RCUid;
} else {
jtsLogger.i18NLogger.warn_recovery_recoverycoordinators_GenericRecoveryCreator_1();
}
return recoveryCoordinator;
}
use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class ThreadActionData method purgeActions.
public static void purgeActions(Thread t, boolean unregister) {
Deque<BasicAction> txs = _threadList.get();
_threadList.set(null);
if (txs != null) {
if (unregister) {
while (!txs.isEmpty()) {
BasicAction act = txs.pop();
if (act != null) {
act.removeChildThread(ThreadUtil.getThreadId(t));
}
}
}
}
}
use of com.arjuna.ats.arjuna.coordinator.BasicAction in project narayana by jbosstm.
the class ThreadActionData method restoreActions.
/**
* Put back the entire hierarchy, removing whatever is already there.
*/
public static void restoreActions(BasicAction act) {
purgeActions();
if (act != null) {
/*
* First get the hierarchy from the bottom up.
*/
Deque<BasicAction> s = new ArrayDeque<BasicAction>();
BasicAction nextLevel = act.parent();
s.push(act);
while (nextLevel != null) {
s.push(nextLevel);
nextLevel = nextLevel.parent();
}
try {
while (!s.isEmpty()) {
pushAction(s.pop());
}
} catch (Exception ex) {
}
}
}
Aggregations