org.apache.derby.impl.store.raw.log
Class ChecksumOperation

java.lang.Object
  extended by org.apache.derby.impl.store.raw.log.ChecksumOperation
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, Formatable, TypedFormat, Loggable

public class ChecksumOperation
extends java.lang.Object
implements Loggable

A Log Operation that represents a checksum for a group of log records that are written to the tranaction log file.

See Also:
Loggable, Serialized Form
Format IDLOGOP_CHECKSUM the formatId is written by FormatIdOutputStream when this object is written out by writeObject
Purposechecksum one or more log records while writing to disk
Upgrade
Disk LayoutchecksumAlgo(byte) the checksum algorithm checksumValue(long) the checksum value dataLength(int) number of bytes that the checksum is calculated

Field Summary
private  java.util.zip.Checksum checksum
           
private  byte checksumAlgo
           
private  long checksumValue
           
static byte CRC32_ALGORITHM
           
private  int dataLength
           
private static int formatLength
           
 
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
ChecksumOperation()
           
 
Method Summary
 void doMe(Transaction xact, LogInstant instant, LimitObjectInput in)
          Nothing to do for the checksum log record because it does need to be applied during redo.
protected  int getDataLength()
          Access attributes of the checksum log record
 ByteArray getPreparedLog()
          the default for prepared log is always null for all the operations that don't have optionalData.
 int getStoredSize()
           
 int getTypeFormatId()
          Return my format identifier.
 int group()
          Checksum is a raw store operation
 void init()
           
private  void initializeChecksumAlgo()
           
protected  boolean isChecksumValid(byte[] data, int off, int length)
           
 boolean needsRedo(Transaction xact)
          Checksum does not need to be redone, it is used to just verify that log records are written completely.
 void readExternal(java.io.ObjectInput in)
           
 void releaseResource(Transaction xact)
          Checksum has no resources to release
protected  void reset()
           
 java.lang.String toString()
          DEBUG: Print self.
protected  void update(byte[] buf, int off, int len)
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

checksumAlgo

private byte checksumAlgo

checksumValue

private long checksumValue

dataLength

private int dataLength

checksum

private java.util.zip.Checksum checksum

CRC32_ALGORITHM

public static final byte CRC32_ALGORITHM
See Also:
Constant Field Values

formatLength

private static final int formatLength
Constructor Detail

ChecksumOperation

public ChecksumOperation()
Method Detail

init

public void init()

update

protected void update(byte[] buf,
                      int off,
                      int len)

reset

protected void reset()

initializeChecksumAlgo

private void initializeChecksumAlgo()

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.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 interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getStoredSize

public int getStoredSize()

getTypeFormatId

public int getTypeFormatId()
Return my format identifier.

Specified by:
getTypeFormatId in interface TypedFormat
Returns:
The identifier. (A UUID stuffed in an array of 16 bytes).

doMe

public void doMe(Transaction xact,
                 LogInstant instant,
                 LimitObjectInput in)
          throws StandardException
Nothing to do for the checksum log record because it does need to be applied during redo.

Specified by:
doMe in interface Loggable
Parameters:
xact - the Transaction
instant - the log instant of this operation
in - optional data
Throws:
StandardException - Standard Derby policy.

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. Checksum has no optional data to write out

Specified by:
getPreparedLog in interface Loggable

needsRedo

public boolean needsRedo(Transaction xact)
Checksum does not need to be redone, it is used to just verify that log records are written completely.

Specified by:
needsRedo in interface Loggable
Parameters:
xact - The transaction trying to redo this operation
Returns:
true if operation needs redoing, false if not.
See Also:
Loggable.releaseResource(org.apache.derby.iapi.store.raw.Transaction)

releaseResource

public void releaseResource(Transaction xact)
Checksum has no resources to release

Specified by:
releaseResource in interface Loggable

group

public int group()
Checksum is a raw store operation

Specified by:
group in interface Loggable

getDataLength

protected int getDataLength()
Access attributes of the checksum log record


isChecksumValid

protected boolean isChecksumValid(byte[] data,
                                  int off,
                                  int length)

toString

public java.lang.String toString()
DEBUG: Print self.

Overrides:
toString in class java.lang.Object

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.