use of com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord in project narayana by jbosstm.
the class StateManager method destroy.
/**
* Destroy the object (e.g., remove its state from the persistent store.)
* Calls to destroy for volatile objects (ones not maintained within the
* volatile object store) are ignored, and FALSE is returned.
*
* @return <code>true</code> on success, <code>false</code> otherwise.
*/
public synchronized boolean destroy() {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("StateManager::destroy for object-id " + objectUid);
}
boolean result = false;
if (participantStore != null) {
BasicAction action = BasicAction.Current();
if (// add will fail if the status is wrong!
action != null) {
DisposeRecord dr = new DisposeRecord(participantStore, this);
if (action.add(dr) != AddOutcome.AR_ADDED) {
dr = null;
tsLogger.i18NLogger.warn_StateManager_6(action.get_uid());
} else
result = true;
} else {
try {
result = participantStore.remove_committed(get_uid(), type());
if (result)
destroyed();
} catch (Exception e) {
tsLogger.i18NLogger.warn_StateManager_7(e);
result = false;
}
}
} else {
/*
* Not a persistent object!
*/
tsLogger.i18NLogger.warn_StateManager_8();
}
return result;
}
use of com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord in project narayana by jbosstm.
the class RecordListUnitTest method test.
@Test
public void test() throws Exception {
RecordList rl = new RecordList();
DisposeRecord dr = new DisposeRecord();
rl.insert(dr);
assertEquals(rl.getFront(), dr);
rl.insert(dr);
assertEquals(rl.getRear(), dr);
RecordList copy = new RecordList(rl);
ActivationRecord ar = new ActivationRecord();
rl.insert(ar);
rl.print(new PrintWriter(new ByteArrayOutputStream()));
assertTrue(rl.toString() != null);
assertEquals(rl.getNext(dr), null);
assertTrue(rl.peekFront() != null);
assertTrue(rl.peekRear() != null);
assertEquals(rl.peekNext(dr), null);
assertTrue(rl.remove(dr));
}
use of com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord in project narayana by jbosstm.
the class CadaverRecordUnitTest method test.
@Test
public void test() {
ParticipantStore store = StoreManager.setupStore(null, StateType.OS_UNSHARED);
CadaverRecord cr = new CadaverRecord(new OutputObjectState(), store, new ExtendedObject());
assertTrue(cr.propagateOnAbort());
assertTrue(cr.propagateOnCommit());
assertEquals(cr.typeIs(), RecordType.PERSISTENCE);
assertTrue(cr.type() != null);
assertEquals(cr.doSave(), false);
cr.merge(new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject()));
assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
cr = new CadaverRecord(new OutputObjectState(), store, new ExtendedObject());
cr.merge(new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject()));
assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
cr = new CadaverRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject());
cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject()));
assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
cr = new CadaverRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject());
cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject()));
cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), store, new ExtendedObject()));
assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
cr = new CadaverRecord();
cr.print(new PrintWriter(new ByteArrayOutputStream()));
assertFalse(cr.shouldMerge(new DisposeRecord()));
assertFalse(cr.shouldReplace(new DisposeRecord()));
}
use of com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord in project narayana by jbosstm.
the class DisposeRecordUnitTest method test.
@Test
public void test() {
ParticipantStore store = StoreManager.setupStore(null, StateType.OS_UNSHARED);
DisposeRecord cr = new DisposeRecord(store, new ExtendedObject());
assertFalse(cr.propagateOnAbort());
assertTrue(cr.propagateOnCommit());
assertEquals(cr.typeIs(), RecordType.DISPOSE);
assertTrue(cr.type() != null);
assertEquals(cr.doSave(), true);
assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
cr = new DisposeRecord(store, new ExtendedObject());
assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
cr = new DisposeRecord(store, new ExtendedObject());
assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
cr = new DisposeRecord(store, new ExtendedObject());
assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
cr = new DisposeRecord();
assertFalse(cr.shouldAdd(new PersistenceRecord()));
assertFalse(cr.shouldAlter(new PersistenceRecord()));
assertFalse(cr.shouldMerge(new PersistenceRecord()));
assertFalse(cr.shouldReplace(new PersistenceRecord()));
assertFalse(cr.save_state(new OutputObjectState(), ObjectType.ANDPERSISTENT));
assertFalse(cr.restore_state(new InputObjectState(), ObjectType.ANDPERSISTENT));
}
Aggregations