Class 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
    Purpose
    checksum 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 Detail

      • checksumAlgo

        private byte checksumAlgo
      • checksumValue

        private long checksumValue
      • dataLength

        private int dataLength
      • checksum

        private java.util.zip.Checksum checksum
      • 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).
      • 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
      • 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