use of com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord in project narayana by jbosstm.
the class StateManager method cleanup.
/**
* Object cleanup. Attempt sane cleanup when object is deleted. Handle
* perverse cases where multiple actions are still active as object dies.
*
* @param fromTerminate
* indicates whether this method is being called from the
* <code>terminate</code> method, or from elsewhere.
* @see StateManager#terminate
*/
protected final synchronized void cleanup(boolean fromTerminate) {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("StateManager::cleanup() for object-id " + get_uid());
}
if (myType == ObjectType.NEITHER)
return;
BasicAction action = null;
synchronized (mutex) {
createLists();
if (usingActions.size() > 0) {
Enumeration e = usingActions.keys();
while (e.hasMoreElements()) {
action = (BasicAction) usingActions.remove(e.nextElement());
if (action != null) {
/*
* Pop actions off using list. Don't check if action is
* running below so that cadavers can be created in
* commit protocol too.
*/
AbstractRecord record = null;
int rStatus = AddOutcome.AR_ADDED;
if ((currentStatus == ObjectStatus.ACTIVE_NEW) || (currentStatus == ObjectStatus.ACTIVE)) {
OutputObjectState state = null;
tsLogger.i18NLogger.warn_StateManager_11(objectUid, type());
if (fromTerminate) {
state = new OutputObjectState(objectUid, type());
if (!save_state(state, myType)) {
tsLogger.i18NLogger.warn_StateManager_12();
/* force action abort */
action.preventCommit();
}
} else {
/* otherwise force action abort */
action.preventCommit();
}
/*
* This should be unnecessary - but just in case.
*/
setupStore(storeRoot);
record = new CadaverRecord(state, participantStore, this);
if ((rStatus = action.add(record)) != AddOutcome.AR_ADDED)
record = null;
}
if (currentlyActivated && (currentStatus != ObjectStatus.DESTROYED)) {
record = new CadaverActivationRecord(this);
if ((rStatus = action.add(record)) == AddOutcome.AR_ADDED) {
currentStatus = ObjectStatus.PASSIVE;
} else {
tsLogger.i18NLogger.warn_StateManager_6(action.get_uid());
record = null;
}
}
}
}
}
}
if (currentStatus == ObjectStatus.ACTIVE_NEW) {
if ((myType == ObjectType.RECOVERABLE) && (objectModel == ObjectModel.SINGLE)) {
currentStatus = ObjectStatus.ACTIVE;
} else {
currentStatus = ObjectStatus.PASSIVE;
}
}
currentlyActivated = false;
}
use of com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord in project narayana by jbosstm.
the class CadaverActivationUnitTest method test.
@Test
public void test() {
ParticipantStore store = StoreManager.setupStore(null, StateType.OS_UNSHARED);
CadaverActivationRecord cr = new CadaverActivationRecord(new ExtendedObject());
assertTrue(cr.propagateOnAbort());
assertTrue(cr.propagateOnCommit());
assertEquals(cr.typeIs(), RecordType.ACTIVATION);
assertTrue(cr.type() != null);
assertEquals(cr.doSave(), false);
assertFalse(cr.shouldReplace(new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject())));
assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
cr = new CadaverActivationRecord(new ExtendedObject());
assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
cr = new CadaverActivationRecord(new ExtendedObject());
assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
cr = new CadaverActivationRecord(new ExtendedObject());
assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
}
Aggregations