|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.store.raw.data.ContainerBasicOperation
org.apache.derby.impl.store.raw.data.ContainerOperation
public class ContainerOperation
Log operation to create, drop or remove a container. Both the doMe or the undoMe of a create actually caused the container header to be modified and flushed before the log record is flushed. This is necessary for 2 reasons, one is that of ensuring enough disk space, and the other is because unlike any other operation, the log record create container is in the log stream before the container is in the container cache. What this mean is that if a checkpoint started after the container operation but before the container is kept or is dirtied in the container cache, then checkpoint will not know to wait for the container to be kept or cleaned. The checkpoint will erroneous assume that the operation does not need to be redone since its log instant is before the checkpoint but in fact the change has not been flushed to disk. A drop or remove container does not have this problem. The container exist and is in kept state when the operation is logged so the checkpoint will not overlook it and it doesn't need to flush the container header. In the case of remove, the stub is flushed for a different reason - that of ensuring disk space.
Field Summary | |
---|---|
protected static byte |
CREATE
|
protected ByteArray |
createByteArray
|
protected static byte |
DROP
|
protected boolean |
hasCreateByteArray
|
protected byte |
operation
|
protected static byte |
REMOVE
|
Fields inherited from class org.apache.derby.impl.store.raw.data.ContainerBasicOperation |
---|
containerHdl, containerId |
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 | |
---|---|
|
ContainerOperation()
|
protected |
ContainerOperation(RawContainerHandle hdl,
byte operation)
|
Method Summary | |
---|---|
void |
doMe(Transaction tran,
LogInstant instant,
LimitObjectInput in)
Apply the change indicated by this operation and optional data. |
protected RawContainerHandle |
findContainerForRedoRecovery(RawTransaction xact)
Find container for load tran. |
Compensation |
generateUndo(Transaction tran,
LimitObjectInput in)
Generate a loggable which will undo this change, using the optional input if necessary. |
int |
getTypeFormatId()
Return my format identifier. |
void |
readExternal(java.io.ObjectInput in)
|
java.lang.String |
toString()
debug |
void |
undoMe(Transaction tran,
RawContainerHandle hdl,
LogInstant CLRInstant,
LimitObjectInput in)
Undo of create, drop or remove |
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class org.apache.derby.impl.store.raw.data.ContainerBasicOperation |
---|
findContainer, getPreparedLog, group, needsRedo, releaseResource |
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 |
---|
getPreparedLog, group, needsRedo, releaseResource |
Field Detail |
---|
protected byte operation
protected transient boolean hasCreateByteArray
protected ByteArray createByteArray
protected static final byte CREATE
protected static final byte DROP
protected static final byte REMOVE
Constructor Detail |
---|
protected ContainerOperation(RawContainerHandle hdl, byte operation) throws StandardException
StandardException
public ContainerOperation()
Method Detail |
---|
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
writeExternal
in class ContainerBasicOperation
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
readExternal
in class ContainerBasicOperation
java.io.IOException
- cannot read log record from log stream
java.lang.ClassNotFoundException
- cannot read ByteArray objectpublic int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
protected RawContainerHandle findContainerForRedoRecovery(RawTransaction xact) throws StandardException
If we are in load tran, and the operation is a create, the container may not (should not?) exist yet. We need to recreate it.
findContainerForRedoRecovery
in class ContainerBasicOperation
StandardException
- Standard Derby error policy.public final void doMe(Transaction tran, LogInstant instant, LimitObjectInput in) throws StandardException
Loggable
The available() method of in indicates how much data can be read, i.e. how much was originally written.
doMe
in interface Loggable
tran
- the Transactioninstant
- the log instant of this operationin
- optional data
StandardException
- Standard Derby error policypublic void undoMe(Transaction tran, RawContainerHandle hdl, LogInstant CLRInstant, LimitObjectInput in) throws StandardException
tran
- the transaction that is undoing this operationhdl
- the container handle. This is found here during runtime
undo - in which case we made the CLR and passed in the containerHdl
found in generateUndo and it is passed back to this; or it is found in
the CLR's needsRedo and is passed in and this operation never found the
container. Either case, release resource at the end is safeCLRInstant
- the log instant of the CLRin
- optional data
StandardException
- Standard Derby error policypublic Compensation generateUndo(Transaction tran, LimitObjectInput in) throws StandardException
Undoable
NOTE
Any logical undo logic must be hidden behind generateUndo.
During recovery redo, it should not depend on any logical undo logic.
There are 3 ways to implement a redo-only log record:
Any resource (e.g., latched page) that is needed for the
undoable.undoMe() must be acquired in undoable.generateUndo().
Moreover, that resource must be identified in the compensation
operation, and reacquired in the compensation.needsRedo() method during
recovery redo.
If you do write your own generateUndo or needsRedo, any
resource you latch or acquire, you must release them in
Compensation.doMe() or in Compensation.releaseResource().
To write a generateUndo operation, find the object that needs to be rolled back. Assuming that it is a page, latch it, put together a Compensation operation with the undoOp set to this operation, and save the page number in the compensation operation, then return the Compensation operation to the logging system.
The sequence of events in a rollback of a undoable operation is
The available() method of in indicates how much data can be read, i.e. how much was originally written.
generateUndo
in interface Undoable
tran
- the transaction doing the rollback
StandardException
- Standard Derby error policyUndoable
public java.lang.String toString()
toString
in class ContainerBasicOperation
|
Built on Thu 2011-03-10 11:54:14+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |