Class ContainerBasicOperation
- java.lang.Object
-
- org.apache.derby.impl.store.raw.data.ContainerBasicOperation
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,Formatable
,TypedFormat
,Loggable
- Direct Known Subclasses:
ContainerOperation
,ContainerUndoOperation
public abstract class ContainerBasicOperation extends java.lang.Object implements Loggable
A Container Operation change the state of the container. A ContainerBasicOperation is the base class for all container operations.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected RawContainerHandle
containerHdl
protected ContainerKey
containerId
private long
containerVersion
private boolean
foundHere
-
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 Modifier Constructor Description ContainerBasicOperation()
protected
ContainerBasicOperation(RawContainerHandle hdl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RawContainerHandle
findContainer(Transaction tran)
Open the container with this segmentId and containerId.protected RawContainerHandle
findContainerForRedoRecovery(RawTransaction tran)
Subclass (e.g., ContainerOperation) that wishes to do something abou missing container in load tran should override this method to return the recreated containerByteArray
getPreparedLog()
the default for prepared log is always null for all the operations that don't have optionalData.int
group()
A space operation is a RAWSTORE log recordboolean
needsRedo(Transaction xact)
Determine if the operation should be reapplied in recovery redo.void
readExternal(java.io.ObjectInput in)
void
releaseResource(Transaction tran)
Release any resource that was acquired for doMe for rollback or recovery redo.java.lang.String
toString()
void
writeExternal(java.io.ObjectOutput out)
-
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.services.io.TypedFormat
getTypeFormatId
-
-
-
-
Field Detail
-
containerVersion
private long containerVersion
-
containerId
protected ContainerKey containerId
-
containerHdl
protected transient RawContainerHandle containerHdl
-
foundHere
private transient boolean foundHere
-
-
Constructor Detail
-
ContainerBasicOperation
protected ContainerBasicOperation(RawContainerHandle hdl) throws StandardException
- Throws:
StandardException
-
ContainerBasicOperation
public ContainerBasicOperation()
-
-
Method Detail
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
getPreparedLog
public ByteArray getPreparedLog()
the default for prepared log is always null for all the operations that don't have optionalData. If an operation has optional data, the operation need to prepare the optional data for this method. Space Operation has no optional data to write out- Specified by:
getPreparedLog
in interfaceLoggable
-
releaseResource
public void releaseResource(Transaction tran)
Description copied from interface:Loggable
Release any resource that was acquired for doMe for rollback or recovery redo. This resource is acquired in either generateUndo (if this is a compensation operation during run time rollback or recovery rollback) or in needsRedo (if this is during recovery redo). The run time transaction context should have all the resource already acquird for run time roll forward, so there is no need to releaseResource during run time roll forward. This method must be safe to be called multiple times.- Specified by:
releaseResource
in interfaceLoggable
-
group
public int group()
A space operation is a RAWSTORE log record
-
findContainer
protected RawContainerHandle findContainer(Transaction tran) throws StandardException
Open the container with this segmentId and containerId. This method should only be called if the container has already been created.- Throws:
StandardException
- the container cannot be found or cannot be opened.
-
findContainerForRedoRecovery
protected RawContainerHandle findContainerForRedoRecovery(RawTransaction tran) throws StandardException
Subclass (e.g., ContainerOperation) that wishes to do something abou missing container in load tran should override this method to return the recreated container- Throws:
StandardException
- Standard Derby error policy
-
needsRedo
public boolean needsRedo(Transaction xact) throws StandardException
Description copied from interface:Loggable
Determine if the operation should be reapplied in recovery redo. If redo is needed, acquire any resource that is necessary for the loggable's doMe method. These need to be released in the releaseResource method.The sequence of events in recovery redo of a Loggable operation is:
- Get the loggable operation. If loggable.needsRedo is false, then no need to redo this operation.
- If loggable.needsRedo is true, all the resources necessary for applying the doMe is acquired in needsRedo.
- If the loggable is actually a compensation operation, then the logging system will find the undoable operation that needs to be undone, call compensation.setUndoOp with the undoable operation.
- The recovery system then calls loggable.doMe, which re-applies the loggable operation, or re-applies the compensation operation
- The recovery system then calls loggable.releaseResource.
- Specified by:
needsRedo
in interfaceLoggable
- Parameters:
xact
- The transaction trying to redo this operation- Returns:
- true if operation needs redoing, false if not.
- Throws:
StandardException
- Standard Derby error policy- See Also:
Loggable.releaseResource(org.apache.derby.iapi.store.raw.Transaction)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-