com.arjuna.ats.arjuna
Class CadaverRecord

java.lang.Object
  extended by com.arjuna.ats.arjuna.StateManager
      extended by com.arjuna.ats.arjuna.coordinator.AbstractRecord
          extended by com.arjuna.ats.arjuna.PersistenceRecord
              extended by com.arjuna.ats.arjuna.CadaverRecord
Direct Known Subclasses:
DisposeRecord

public class CadaverRecord
extends PersistenceRecord

Cadaver records are created whenever a persistent object is deleted while still in the scope of an atomic action. This ensures that if the action commits the state of the persistent objects gets properly reflected back in the object store. For objects that are only recoverable such work is unnecessary. Cadaver records replace PersistenceRecords in the record list of an atomic action so they must be merged with such records to enable both commits and aborts to occur.

Since:
JTS 1.0.
Version:
$Id: CadaverRecord.java 2342 2006-03-30 13:06:17Z $
Author:
Mark Little (mark@arjuna.com)

Field Summary
protected  StateManager objectAddr
           
protected  OutputObjectState state
           
 
Fields inherited from class com.arjuna.ats.arjuna.PersistenceRecord
classicPrepare, MAX_OBJECT_SIZE, shadowMade, topLevelState
 
Fields inherited from class com.arjuna.ats.arjuna.StateManager
modifyingActions, objectName, objectUid, smAttributes, usingActions
 
Constructor Summary
protected CadaverRecord()
          Create a new instance using default values.
  CadaverRecord(OutputObjectState os, ObjectStore objStore, StateManager sm)
          Create a new instance, passing in the object that is being managed.
 
Method Summary
 void alter(AbstractRecord a)
          Alter the current record with the one presented.
 ClassName className()
          The ClassName representation of this class.
static AbstractRecord create()
          Create a new instance of the CadaverRecord, using the default constructor.
 boolean doSave()
          Override the AbstractRecord.doSave.
 void finalize()
          Tidy-up the instance.
protected  void forgetAction(boolean commit)
           
 void merge(AbstractRecord mergewith)
          merge takes the information from the incoming PersistenceRecord and uses it to initialise the oldState information.
 int nestedAbort()
          The nested transaction has aborted.
 int nestedCommit()
          nestedCommit does nothing since the passing of the state up to the parent action is handled by the record list merging system.
 int nestedPrepare()
          The nested transaction is preparing.
 void print(java.io.PrintWriter strm)
          Override AbstractRecord.print to write specific information to the specified stream.
 boolean propagateOnAbort()
          Override default AbstractRecord method.
 void setValue(java.lang.Object newState)
           
 boolean shouldAdd(AbstractRecord a)
          Should we add the record presented to the intentions list?
 boolean shouldAlter(AbstractRecord a)
          Should we alter the current record with the one presented?
 boolean shouldMerge(AbstractRecord ar)
          Overrides AbstractRecord.shouldMerge
 boolean shouldReplace(AbstractRecord ar)
          Overrides AbstractRecord.shouldReplace
 int topLevelAbort()
          The nested transaction has aborted.
 int topLevelCommit()
          At topLevelCommit we commit the uncommitted version already saved into object store.
 int topLevelPrepare()
          At topLevelPrepare write uncommitted version into object store.
 java.lang.String type()
          The type of the class - may be used to save information in an hierarchical manner in the object store.
 int typeIs()
          The type of the record.
 java.lang.Object value()
          If this abstract record caused a heuristic then it should return an object which implements HeuristicInformation
 
Methods inherited from class com.arjuna.ats.arjuna.PersistenceRecord
restore_state, save_state, shadowForced, topLevelCleanup
 
Methods inherited from class com.arjuna.ats.arjuna.coordinator.AbstractRecord
create, equals, forgetHeuristic, getNext, getPrevious, getTypeOfObject, greaterThan, lessThan, nestedCleanup, nestedOnePhaseCommit, order, propagateOnCommit, replace, setNext, setPrevious, topLevelOnePhaseCommit
 
Methods inherited from class com.arjuna.ats.arjuna.StateManager
activate, activate, attributes, cleanup, deactivate, deactivate, deactivate, destroy, disable, forgetAction, get_uid, getMutex, getStore, getStoreRoot, loadObjectState, lockMutex, modified, ObjectType, packHeader, persist, rememberAction, setStatus, setupStore, setupStore, status, terminate, tryLockMutex, unlockMutex, unpackHeader
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectAddr

protected StateManager objectAddr

state

protected OutputObjectState state
Constructor Detail

CadaverRecord

public CadaverRecord(OutputObjectState os,
                     ObjectStore objStore,
                     StateManager sm)
Create a new instance, passing in the object that is being managed.

Parameters:
OutputObjectState - os the state of the object that is being removed.
StateManager - sm the object being removed.

CadaverRecord

protected CadaverRecord()
Create a new instance using default values. Typically used during failure recovery.

Method Detail

finalize

public void finalize()
Tidy-up the instance.

Overrides:
finalize in class PersistenceRecord

propagateOnAbort

public boolean propagateOnAbort()
Override default AbstractRecord method. CadaverRecords are propagated regardless of the termination condition.

Overrides:
propagateOnAbort in class AbstractRecord
Returns:
true

typeIs

public int typeIs()
The type of the record.

Overrides:
typeIs in class PersistenceRecord
Returns:
RecordType.PERSISTENT
See Also:
RecordType

className

public ClassName className()
The ClassName representation of this class.

Overrides:
className in class PersistenceRecord
Returns:
ClassName to identify this abstract record.

nestedAbort

public int nestedAbort()
The nested transaction has aborted. The record will invalidate any new state.

Returns:
TwoPhaseOutcome to indicate success/failure.
See Also:
TwoPhaseOutcome

nestedPrepare

public int nestedPrepare()
The nested transaction is preparing. If there is any new state for the object being removed, and that state is valid, then this record will call nestedPrepare on the object being removed. If we have no new state then we cannot commit and must force an abort. Do this by failing the prepare phase.

Returns:
TwoPhaseOutcome to indicate success/failure.
See Also:
TwoPhaseOutcome

topLevelAbort

public int topLevelAbort()
The nested transaction has aborted. Invalidate any new state.

Overrides:
topLevelAbort in class PersistenceRecord
Returns:
TwoPhaseOutcome to indicate success/failure.
See Also:
TwoPhaseOutcome

topLevelCommit

public int topLevelCommit()
At topLevelCommit we commit the uncommitted version already saved into object store. Cannot use inherited version since that assumes object is alive instead talk directly to the object store itself.

Overrides:
topLevelCommit in class PersistenceRecord
Returns:
TwoPhaseOutcome to indicate success/failure.
See Also:
TwoPhaseOutcome

topLevelPrepare

public int topLevelPrepare()
At topLevelPrepare write uncommitted version into object store. Cannot use inherited version since that assumes object is alive instead talk directly to the object store itself.

Overrides:
topLevelPrepare in class PersistenceRecord
Returns:
TwoPhaseOutcome to indicate success/failure.
See Also:
TwoPhaseOutcome

print

public void print(java.io.PrintWriter strm)
Override AbstractRecord.print to write specific information to the specified stream.

Overrides:
print in class PersistenceRecord
Parameters:
PrintWriter - strm the stream to use.

type

public java.lang.String type()
The type of the class - may be used to save information in an hierarchical manner in the object store.

Overrides:
type in class PersistenceRecord

doSave

public boolean doSave()
Override the AbstractRecord.doSave.

Overrides:
doSave in class PersistenceRecord
Returns:
true if the object being removed is a persistent object (RecordType.PERSISTENT). false otherwise.
See Also:
RecordType

create

public static AbstractRecord create()
Create a new instance of the CadaverRecord, using the default constructor. Have to return as a AbstractStore because of inheritence.

Returns:
a new CadaverRecord.

merge

public void merge(AbstractRecord mergewith)
merge takes the information from the incoming PersistenceRecord and uses it to initialise the oldState information. This is required for processing of action aborts since CadaverRecords maintain the final state of an object normally - which is required if the action commits.

Parameters:
AbstractRecord - mergewith The record to merge with.

shouldMerge

public boolean shouldMerge(AbstractRecord ar)
Overrides AbstractRecord.shouldMerge

Parameters:
AbstractRecord - ar the record to potentially merge with.
Returns:
true if this instance and the parameter have the same id (order()) and the parameter is either persistent or recoverable. false otherwise.
See Also:
RecordType

shouldReplace

public boolean shouldReplace(AbstractRecord ar)
Overrides AbstractRecord.shouldReplace

Parameters:
AbstractRecord - ar the record to potentially replace this instance.
Returns:
true if this instance and the parameter have the same id (order()) and the parameter is either persistent or recoverable. false otherwise.
See Also:
RecordType

value

public java.lang.Object value()
Description copied from class: AbstractRecord
If this abstract record caused a heuristic then it should return an object which implements HeuristicInformation

Specified by:
value in class AbstractRecord
Returns:
Object to be used to order.

setValue

public void setValue(java.lang.Object newState)
Specified by:
setValue in class AbstractRecord

nestedCommit

public int nestedCommit()
nestedCommit does nothing since the passing of the state up to the parent action is handled by the record list merging system. In fact since nestedPrepare returns PREPARE_READONLY this function should never actaully be called

Specified by:
nestedCommit in class AbstractRecord
Returns:
TwoPhaseOutcome to indicate success/failure.
See Also:
TwoPhaseOutcome

alter

public void alter(AbstractRecord a)
Description copied from class: AbstractRecord
Alter the current record with the one presented.

Specified by:
alter in class AbstractRecord

shouldAdd

public boolean shouldAdd(AbstractRecord a)
Description copied from class: AbstractRecord
Should we add the record presented to the intentions list?

Specified by:
shouldAdd in class AbstractRecord
Returns:
true if the record should be added, false otherwise.

shouldAlter

public boolean shouldAlter(AbstractRecord a)
Description copied from class: AbstractRecord
Should we alter the current record with the one presented?

Specified by:
shouldAlter in class AbstractRecord
Returns:
true if the record should be altered, false otherwise.

forgetAction

protected final void forgetAction(boolean commit)