Class PersistenceRecord

Direct Known Subclasses:
CadaverRecord

public class PersistenceRecord extends RecoveryRecord
A PersistenceRecord is created whenever a persistent object is created/read/modified within the scope of a transaction. It is responsible for ensuring that state changes are committed or rolled back on behalf of the object depending upon the outcome of the transaction.
Since:
JTS 1.0.
Version:
$Id: PersistenceRecord.java 2342 2006-03-30 13:06:17Z $
Author:
Mark Little (mark@arjuna.com)
  • Field Details

    • MAX_OBJECT_SIZE

      public static final int MAX_OBJECT_SIZE
      See Also:
    • shadowMade

      protected boolean shadowMade
    • targetParticipantStore

      protected ParticipantStore targetParticipantStore
    • topLevelState

      protected OutputObjectState topLevelState
    • classicPrepare

      protected static final boolean classicPrepare
  • Constructor Details

    • PersistenceRecord

      public PersistenceRecord(OutputObjectState os, ParticipantStore participantStore, StateManager sm)
      This constructor is used to create a new instance of PersistenceRecord.
    • PersistenceRecord

      public PersistenceRecord()
      Creates a 'blank' persistence record. This is used during crash recovery when recreating the prepared list of a server atomic action.
  • Method Details

    • typeIs

      public int typeIs()
      Redefintions of abstract functions inherited from RecoveryRecord.
      Overrides:
      typeIs in class RecoveryRecord
      Returns:
      RecordType value.
    • topLevelAbort

      public int topLevelAbort()
      topLevelAbort may have to remove the persistent state that was written into the object store during the processing of topLevelPrepare. It then does the standard abort processing.
      Overrides:
      topLevelAbort in class RecoveryRecord
      Returns:
      TwoPhaseOutcome to indicate success/failure.
      See Also:
    • topLevelCommit

      public int topLevelCommit()
      commit the state saved during the prepare phase.
      Overrides:
      topLevelCommit in class RecoveryRecord
      Returns:
      TwoPhaseOutcome to indicate success/failure.
      See Also:
    • topLevelPrepare

      public int topLevelPrepare()
      topLevelPrepare attempts to save the object. It will either do this in the action intention list or directly in the object store by using the 'deactivate' function of the object depending upon the size of the state. To ensure that objects are correctly hidden while they are in an uncommitted state if we use the abbreviated protocol then we write an EMPTY object state as the shadow state - THIS MUST NOT BE COMMITTED. Instead we write_committed the one saved in the intention list. If the store cannot cope with being given an empty state we revert to the old protocol.
      Overrides:
      topLevelPrepare in class RecoveryRecord
      Returns:
      TwoPhaseOutcome to indicate success/failure.
      See Also:
    • topLevelCleanup

      public int topLevelCleanup()
      topLevelCleanup must leave the persistent state that was written in the object store during the processing of topLevelPrepare intact. Crash recovery will take care of its resolution
      Overrides:
      topLevelCleanup in class AbstractRecord
      Returns:
      TwoPhaseOutcome as default is the same as topLevelAbort.
    • doSave

      public boolean doSave()
      Description copied from class: AbstractRecord
      Should this record be saved in the intentions list? If the record is saved, then it may be recovered later in the event of a failure. Note, however, that the size of the intentions list on disk is critical to the performance of the system (disk I/O is a bottleneck).
      Overrides:
      doSave in class RecoveryRecord
      Returns:
      true
    • restore_state

      public boolean restore_state(InputObjectState os, int ot)
      Description copied from class: AbstractRecord
      During recovery, the transaction log is given to the recovery system and it will recreate a transaction instance to perform necessary recovery actions. This transaction will recreate the intentions list and give each recreated AbstractRecord the state that that was saved during transaction persistence. The base class will restore information that it needs from the log. Data items must be unpacked in the same order that they were packed.
      Overrides:
      restore_state in class RecoveryRecord
      Returns:
      true if successful, false otherwise.
    • save_state

      public boolean save_state(OutputObjectState os, int ot)
      Description copied from class: AbstractRecord
      When the transaction is required to make the intentions list persistent, it scans the list and asks each record whether or not it requires state to be saved (by calling doSave). If the answer is yes, then save_state is called and the record instance must save enough information to enable it to be restored from that state later. The basic AbstractRecord save_state will save common data that is required by the base class during recovery. If a derived class calls super.save_state then it must be called before packing any other data item.
      Overrides:
      save_state in class RecoveryRecord
      Returns:
      true if successful, false otherwise.
    • print

      public void print(PrintWriter strm)
      Description copied from class: AbstractRecord
      Write information about this specific instance to the specified stream.
      Overrides:
      print in class RecoveryRecord
      Parameters:
      strm - the stream on which to output.
    • type

      public String type()
      Description copied from class: AbstractRecord
      Re-implementation of abstract methods inherited from base class.
      Overrides:
      type in class RecoveryRecord
    • shadowForced

      protected boolean shadowForced()
      Cadaver records force write shadows. This operation supresses to abbreviated commit This should never return false