java.io.Externalizable
, java.io.Serializable
, Formatable
, TypedFormat
, Loggable
, Undoable
public class ContainerOperation extends ContainerBasicOperation implements Undoable
Modifier and Type | Field | Description |
---|---|---|
protected static byte |
CREATE |
|
protected ByteArray |
createByteArray |
|
protected static byte |
DROP |
|
protected boolean |
hasCreateByteArray |
|
protected byte |
operation |
|
protected static byte |
REMOVE |
containerHdl, containerId
ABORT, BI_LOG, CHECKSUM, COMMIT, COMPENSATION, FILE_RESOURCE, FIRST, LAST, PREPARE, RAWSTORE, XA_NEEDLOCK
Modifier | Constructor | Description |
---|---|---|
|
ContainerOperation() |
|
protected |
ContainerOperation(RawContainerHandle hdl,
byte operation) |
Modifier and Type | Method | Description |
---|---|---|
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) |
findContainer, getPreparedLog, group, needsRedo, releaseResource
getPreparedLog, group, needsRedo, releaseResource
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
protected ContainerOperation(RawContainerHandle hdl, byte operation) throws StandardException
StandardException
public ContainerOperation()
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 streamjava.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 dataStandardException
- 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 dataStandardException
- 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 rollbackStandardException
- Standard Derby error policyUndoable
public java.lang.String toString()
toString
in class ContainerBasicOperation
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.