Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.data

pack-priv abstract Class LogicalPageOperation

extends PageBasicOperation
implements LogicalUndoable
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.store.raw.LogicalUndoable, org.apache.derby.iapi.store.raw.Undoable, org.apache.derby.iapi.store.raw.Loggable, org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.services.io.TypedFormat, java.io.Externalizable, java.io.Serializable
Known Direct Subclasses
org.apache.derby.impl.store.raw.data.UpdateFieldOperation, org.apache.derby.impl.store.raw.data.DeleteOperation, org.apache.derby.impl.store.raw.data.InsertOperation
Imports
org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.store.access.conglomerate.LogicalUndo, org.apache.derby.iapi.store.raw.ContainerHandle, .Compensation, .LogicalUndoable, .LockingPolicy, .RecordHandle, .Transaction, .Undoable, org.apache.derby.iapi.store.raw.data.RawContainerHandle, org.apache.derby.iapi.store.raw.xact.RawTransaction, org.apache.derby.iapi.store.raw.log.LogInstant, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.io.CompressedNumber, .LimitObjectInput, java.io.ObjectOutput, .ObjectInput, .IOException

An abstract class that is used for logical log operation. A logical log operation is one where the undo of the operation may be applied to a different page than the original operation.

Field Summary

Modifier and TypeField and Description
protected int
protected LogicalUndo
Inherited from org.apache.derby.impl.store.raw.data.PageBasicOperation:
containerHdlfoundHerepage

Constructor Summary

AccessConstructor and Description
public
pack-priv
LogicalPageOperation(BasePage page, LogicalUndo undo, int recordId)

Method Summary

Modifier and TypeMethod and Description
private BasePage

Returns:

the compensation operation that will rollback this change
findLogicalPage
(Transaction
the transaction doing the compensating
xact
,
LogicalUndo undo, LimitObjectInput
optional input
in
)

Find the page that the rollback operation should be applied to.

public Compensation
generateUndo(Transaction
the transaction doing the rollback
xact
,
LimitObjectInput in)

Implements org.apache.derby.iapi.store.raw.Undoable.generateUndo.

Generate a Compensation (PageUndoOperation) that will rollback the changes of this page operation.

public ContainerHandle
getContainer()

Implements org.apache.derby.iapi.store.raw.LogicalUndoable.getContainer.

Return the container handle where the log operated on

public RecordHandle
getRecordHandle()

Implements org.apache.derby.iapi.store.raw.LogicalUndoable.getRecordHandle.

Return the record handle that correspond to the record that was changed during roll forward.

public void
readExternal(ObjectInput
the stream to read data from in order to restore the object
in
)

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.readExternal.

Implements java.io.Externalizable.readExternal.

Read this in

public void
reclaimPrepareLocks(Transaction t, LockingPolicy
The locking policy to use to claim the locks.
locking_policy
)

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.reclaimPrepareLocks.

Implements org.apache.derby.iapi.store.raw.RePreparable.reclaimPrepareLocks.

reclaim locks associated with the changes in this log record.

public void
resetRecordHandle(RecordHandle
the RecordHandle that represents the row's new location
rh
)

Implements org.apache.derby.iapi.store.raw.LogicalUndoable.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

public abstract void
undoMe(Transaction
the Transaction doing the rollback
xact
,
BasePage
the page to rollback changes on
undoPage
,
int
the recordId to rollback changes on
undoRecordId
,
LogInstant
the log instant of this (PageUndo) operation
CLRinstant
,
LimitObjectInput
optional data for the rollback operation
in
)

Undo the change indicated by this log operation and optional data.

public void
writeExternal(ObjectOutput
the stream to write the object to
out
)

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.writeExternal.

Implements java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Inherited from org.apache.derby.impl.store.raw.data.PageBasicOperation:
findpagegetPagegetPageForRedoRecoverygetPageIdgetPageVersiongetPreparedLoggroupneedsRedoreleaseResourceresetPageNumberrestoreMetoString

Field Detail

recordIdback to summary
protected int recordId
undoback to summary
protected LogicalUndo undo

Constructor Detail

LogicalPageOperationback to summary
public LogicalPageOperation()
LogicalPageOperationback to summary
pack-priv LogicalPageOperation(BasePage page, LogicalUndo undo, int recordId)

Method Detail

findLogicalPageback to summary
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:Transaction

the transaction doing the compensating

in:LimitObjectInput

optional input

Returns:BasePage

the compensation operation that will rollback this change

Exceptions
StandardException:
Standard Derby error policy
IOException:
Method may read from ObjectInput
See Also
PageBasicOperation, Undoable#generateUndo, org.apache.derby.iapi.store.raw.Loggable#releaseResource
generateUndoback to summary
public Compensation generateUndo(Transaction xact, LimitObjectInput in) throws StandardException, IOException

Implements org.apache.derby.iapi.store.raw.Undoable.generateUndo.

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.

Parameters
xact:Transaction

Doc from org.apache.derby.iapi.store.raw.Undoable.generateUndo.

the transaction doing the rollback

Returns:Compensation

Doc from org.apache.derby.iapi.store.raw.Undoable.generateUndo.

the compensation operation that will rollback this change, or null if nothing to undo.

Exceptions
StandardException:
Standard Derby policy.
IOException:
Method may read from ObjectInput
See Also
LogicalUndo
getContainerback to summary
public ContainerHandle getContainer()

Implements org.apache.derby.iapi.store.raw.LogicalUndoable.getContainer.

Return the container handle where the log operated on

getRecordHandleback to summary
public RecordHandle getRecordHandle()

Implements org.apache.derby.iapi.store.raw.LogicalUndoable.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.

readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.readExternal.

Implements java.io.Externalizable.readExternal.

Read this in

Parameters
in:ObjectInput

Doc from java.io.Externalizable.readExternal.

the stream to read data from in order to restore the object

Exceptions
IOException:
error reading from log stream
ClassNotFoundException:
log stream corrupted
reclaimPrepareLocksback to summary
public void reclaimPrepareLocks(Transaction t, LockingPolicy locking_policy) throws StandardException

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.reclaimPrepareLocks.

Implements org.apache.derby.iapi.store.raw.RePreparable.reclaimPrepareLocks.

reclaim locks associated with the changes in this log record.

Parameters
locking_policy:LockingPolicy

The locking policy to use to claim the locks.

Exceptions
StandardException:
Standard exception policy.
resetRecordHandleback to summary
public void resetRecordHandle(RecordHandle rh)

Implements org.apache.derby.iapi.store.raw.LogicalUndoable.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

Parameters
rh:RecordHandle

Doc from org.apache.derby.iapi.store.raw.LogicalUndoable.resetRecordHandle.

the RecordHandle that represents the row's new location

undoMeback to summary
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:Transaction

the Transaction doing the rollback

undoPage:BasePage

the page to rollback changes on

undoRecordId:int

the recordId to rollback changes on

CLRinstant:LogInstant

the log instant of this (PageUndo) operation

in:LimitObjectInput

optional data for the rollback operation

Exceptions
StandardException:
Standard Derby policy.
IOException:
Can be thrown by any of the methods of ObjectInput.
writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Overrides org.apache.derby.impl.store.raw.data.PageBasicOperation.writeExternal.

Implements java.io.Externalizable.writeExternal.

Doc from java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Parameters
out:ObjectOutput

the stream to write the object to

Exceptions
IOException:
Includes any I/O exceptions that may occur