Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.store.raw.data
Class ContainerBasicOperation  view ContainerBasicOperation download ContainerBasicOperation.java

java.lang.Object
  extended byorg.apache.derby.impl.store.raw.data.ContainerBasicOperation
All Implemented Interfaces:
java.io.Externalizable, org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.store.raw.Loggable, java.io.Serializable, org.apache.derby.iapi.services.io.TypedFormat
Direct Known Subclasses:
ContainerOperation, ContainerUndoOperation

public abstract class ContainerBasicOperation
extends java.lang.Object
implements org.apache.derby.iapi.store.raw.Loggable

A Container Operation change the state of the container. A ContainerBasicOperation is the base class for all container operations.


Field Summary
protected  org.apache.derby.iapi.store.raw.data.RawContainerHandle containerHdl
           
protected  org.apache.derby.iapi.store.raw.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
  ContainerBasicOperation()
           
protected ContainerBasicOperation(org.apache.derby.iapi.store.raw.data.RawContainerHandle hdl)
           
 
Method Summary
protected  org.apache.derby.iapi.store.raw.data.RawContainerHandle findContainer(org.apache.derby.iapi.store.raw.Transaction tran)
          Open the container with this segmentId and containerId.
protected  org.apache.derby.iapi.store.raw.data.RawContainerHandle findContainerForLoadTran(org.apache.derby.iapi.store.raw.xact.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 container
 org.apache.derby.iapi.util.ByteArray 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 record
 boolean needsRedo(org.apache.derby.iapi.store.raw.Transaction xact)
          Determine if the operation should be reapplied in recovery redo.
 void readExternal(java.io.ObjectInput in)
          This method restores an object's state by reading in the instance data for the object from the passed in stream.
 void releaseResource(org.apache.derby.iapi.store.raw.Transaction tran)
          Release any resource that was acquired for doMe for rollback or recovery redo.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void writeExternal(java.io.ObjectOutput out)
          This method is responsible for writing the instance data of an object to the passed in stream.
 
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
 
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
 

Field Detail

containerVersion

private long containerVersion

containerId

protected org.apache.derby.iapi.store.raw.ContainerKey containerId

containerHdl

protected transient org.apache.derby.iapi.store.raw.data.RawContainerHandle containerHdl

foundHere

private transient boolean foundHere
Constructor Detail

ContainerBasicOperation

protected ContainerBasicOperation(org.apache.derby.iapi.store.raw.data.RawContainerHandle hdl)
                           throws org.apache.derby.iapi.error.StandardException

ContainerBasicOperation

public ContainerBasicOperation()
Method Detail

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Description copied from interface: java.io.Externalizable
This method is responsible for writing the instance data of an object to the passed in stream. Note that this stream is not a subclass of OutputStream, but rather is a class that implements the ObjectOutput interface. That interface provides a number of methods for writing Java data values to a stream.

Not that the implementation of this method must be coordinated with the implementation of readExternal.

Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Description copied from interface: java.io.Externalizable
This method restores an object's state by reading in the instance data for the object from the passed in stream. Note that this stream is not a subclass of InputStream, but rather is a class that implements the ObjectInput interface. That interface provides a mechanism for reading in Java data types from a stream.

Note that this method must be compatible with writeExternal. It must read back the exact same types that were written by that method in the exact order they were written.

If this method needs to read back an object instance, then the class for that object must be found and loaded. If that operation fails, then this method throws a ClassNotFoundException

Specified by:
readExternal in interface java.io.Externalizable

getPreparedLog

public org.apache.derby.iapi.util.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 interface org.apache.derby.iapi.store.raw.Loggable

releaseResource

public void releaseResource(org.apache.derby.iapi.store.raw.Transaction tran)
Description copied from interface: org.apache.derby.iapi.store.raw.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 interface org.apache.derby.iapi.store.raw.Loggable

group

public int group()
A space operation is a RAWSTORE log record

Specified by:
group in interface org.apache.derby.iapi.store.raw.Loggable

findContainer

protected org.apache.derby.iapi.store.raw.data.RawContainerHandle findContainer(org.apache.derby.iapi.store.raw.Transaction tran)
                                                                         throws org.apache.derby.iapi.error.StandardException
Open the container with this segmentId and containerId. This method should only be called if the container has already been created.


findContainerForLoadTran

protected org.apache.derby.iapi.store.raw.data.RawContainerHandle findContainerForLoadTran(org.apache.derby.iapi.store.raw.xact.RawTransaction tran)
                                                                                    throws org.apache.derby.iapi.error.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


needsRedo

public boolean needsRedo(org.apache.derby.iapi.store.raw.Transaction xact)
                  throws org.apache.derby.iapi.error.StandardException
Description copied from interface: org.apache.derby.iapi.store.raw.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 interface org.apache.derby.iapi.store.raw.Loggable

  • toString

    public java.lang.String toString()
    Description copied from class: java.lang.Object
    Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

    It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

    This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

    The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).