Class LogicalPageOperation
- All Implemented Interfaces:
Externalizable
,Serializable
,Formatable
,TypedFormat
,Loggable
,LogicalUndoable
,RePreparable
,Undoable
- Direct Known Subclasses:
DeleteOperation
,InsertOperation
,UpdateFieldOperation
-
Field Summary
FieldsFields inherited from class org.apache.derby.impl.store.raw.data.PageBasicOperation
containerHdl, foundHere, page
Fields inherited from interface org.apache.derby.iapi.store.raw.Loggable
ABORT, BI_LOG, CHECKSUM, COMMIT, COMPENSATION, FILE_RESOURCE, FIRST, LAST, PREPARE, RAWSTORE, XA_NEEDLOCK
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate BasePage
findLogicalPage
(Transaction xact, LogicalUndo undo, LimitObjectInput in) Find the page that the rollback operation should be applied to.generateUndo
(Transaction xact, LimitObjectInput in) Generate a Compensation (PageUndoOperation) that will rollback the changes of this page operation.Return the container handle where the log operated onReturn the record handle that correspond to the record that was changed during roll forward.void
Read this invoid
reclaimPrepareLocks
(Transaction t, LockingPolicy locking_policy) reclaim locks associated with the changes in this log record.void
After the logical undo logic figures out where the real record that needs roll back is, reset this log operation to refer to that recordabstract void
undoMe
(Transaction xact, BasePage undoPage, int undoRecordId, LogInstant CLRinstant, LimitObjectInput in) Undo the change indicated by this log operation and optional data.void
Methods inherited from class org.apache.derby.impl.store.raw.data.PageBasicOperation
findpage, getPage, getPageForRedoRecovery, getPageId, getPageVersion, getPreparedLog, group, needsRedo, releaseResource, resetPageNumber, restoreMe, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.derby.iapi.store.raw.Loggable
doMe, getPreparedLog, group, needsRedo, releaseResource
Methods inherited from interface org.apache.derby.iapi.store.raw.LogicalUndoable
restoreLoggedRow
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
-
Field Details
-
undo
-
recordId
protected int recordId
-
-
Constructor Details
-
LogicalPageOperation
public LogicalPageOperation() -
LogicalPageOperation
LogicalPageOperation(BasePage page, LogicalUndo undo, int recordId)
-
-
Method Details
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classPageBasicOperation
- Throws:
IOException
-
readExternal
Read this in- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classPageBasicOperation
- Throws:
IOException
- error reading from log streamClassNotFoundException
- log stream corrupted
-
generateUndo
public Compensation generateUndo(Transaction xact, LimitObjectInput in) throws StandardException, IOException Generate a Compensation (PageUndoOperation) that will rollback the changes of this page operation. If this Page operation cannot or need not be rolled back (redo only), overwrite this function to return null.- Specified by:
generateUndo
in interfaceUndoable
- Parameters:
xact
- the transaction doing the rollback- Returns:
- the compensation operation that will rollback this change, or null if nothing to undo.
- Throws:
StandardException
- Standard Derby policy.IOException
- Method may read from ObjectInput- See Also:
-
getContainer
Return the container handle where the log operated on- Specified by:
getContainer
in interfaceLogicalUndoable
-
resetRecordHandle
After the logical undo logic figures out where the real record that needs roll back is, reset this log operation to refer to that record- Specified by:
resetRecordHandle
in interfaceLogicalUndoable
- Parameters:
rh
- the RecordHandle that represents the row's new location
-
getRecordHandle
Return the record handle that correspond to the record that was changed during roll forward. This is used as a hint by logical undo as a good place to look for the record to apply the roll back.- Specified by:
getRecordHandle
in interfaceLogicalUndoable
-
reclaimPrepareLocks
public void reclaimPrepareLocks(Transaction t, LockingPolicy locking_policy) throws StandardException reclaim locks associated with the changes in this log record.- Specified by:
reclaimPrepareLocks
in interfaceRePreparable
- Overrides:
reclaimPrepareLocks
in classPageBasicOperation
- Parameters:
locking_policy
- The locking policy to use to claim the locks.- Throws:
StandardException
- Standard exception policy.
-
findLogicalPage
private BasePage findLogicalPage(Transaction xact, LogicalUndo undo, LimitObjectInput in) throws StandardException, IOException Find the page that the rollback operation should be applied to.The actual logical log operation is expected to implement Undoable.generateUndo. This utility function findLogicalPage is provided for the common case scenario of using a LogicalUndo interface to find the undo page. The subclass that implements Undoable.generateUndo can use this function to find the logical page with its LogicalUndo callback function. This method can be used with the default releaseResource().
During recovery redo, the logging system is page oriented and will use the pageID stored in the PageUndoOperation to find the page. The page will be latched and released using the default findpage and releaseResource - this.releaseResource() will still be called so it has to know not to release any resource it did not acquire.
- Parameters:
xact
- the transaction doing the compensatingin
- optional input- Returns:
- the compensation operation that will rollback this change
- Throws:
StandardException
- Standard Derby error policyIOException
- Method may read from ObjectInput- See Also:
-
undoMe
public abstract void undoMe(Transaction xact, BasePage undoPage, int undoRecordId, LogInstant CLRinstant, LimitObjectInput in) throws StandardException, IOException Undo the change indicated by this log operation and optional data. The undoPage and undoRecordId is the page, record the undo should apply to. The undoRecorId differs from the roll forward recordId if the undoPage differs from the page the roll forward operation was applied to, in other words, the record moved to another page and the recordId changed.
A logical operation can at most deal with 1 record.The available() method of in indicates how much data can be read, i.e. how much was originally written.
In this RawStore implementation, should only only be called via CompOp.doMe.- Parameters:
xact
- the Transaction doing the rollbackundoPage
- the page to rollback changes onundoRecordId
- the recordId to rollback changes onCLRinstant
- the log instant of this (PageUndo) operationin
- optional data for the rollback operation- Throws:
IOException
- Can be thrown by any of the methods of ObjectInput.StandardException
- Standard Derby policy.
-