|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.replicator.thl.log.LogRecord
public class LogRecord
Encapsulates a log record from the Tungsten disk log.
| Field Summary | |
|---|---|
static byte |
CRC_TYPE_32
Record uses conventional CRC-32 computed by Java CRC32 class. |
static byte |
CRC_TYPE_NONE
Record does not have a CRC computed. |
static byte |
EVENT_REPL
Denotes record header information. |
static byte |
EVENT_ROTATE
Denotes a replication event |
static int |
NON_DATA_BYTES
Number of bytes in length field plus CRC. |
| Constructor Summary | |
|---|---|
LogRecord(java.io.File file,
long offset,
boolean truncated)
Creates an empty record, which is optionally truncated. |
|
LogRecord(java.io.File file,
long offset,
byte[] bytes,
byte crcType,
long crc)
Creates a readable record with indicated content. |
|
| Method Summary | |
|---|---|
boolean |
checkCrc()
Computes the CRC value and compares to the CRC stored in the record, returning true only if the CRC values match. |
long |
computeCrc()
Compute and return CRC on data. |
static long |
computeCrc32(byte[] bytes)
Static routine to compute CRC 32. |
void |
done()
Deallocate resources and in the case of a writable log record write data. |
boolean |
equals(java.lang.Object o)
Return true if two records are equal, which means that offset, byte array, and CRC all match. |
long |
getCrc()
Returns the CRC value. |
byte |
getCrcType()
Returns the CRC type. |
byte[] |
getData()
Returns the underlying byte buffer. |
long |
getOffset()
Returns the offset into the source file of this record. |
long |
getRecordLength()
Returns the computed length of this record in the file, including length field, data, and CRC. |
boolean |
isEmpty()
Returns true if the record is empty. |
boolean |
isTruncated()
Returns true if the record is truncated. |
java.io.InputStream |
read()
Returns a stream to read record contents. |
void |
storeCrc(byte crcType)
Compute and store CRC. |
java.lang.String |
toString()
Print log record as string. |
void |
verifyChecksum()
Verifies the CRC value. |
java.io.OutputStream |
write()
Returns a stream to write record contents. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int NON_DATA_BYTES
public static final byte EVENT_REPL
public static final byte EVENT_ROTATE
public static final byte CRC_TYPE_NONE
public static final byte CRC_TYPE_32
| Constructor Detail |
|---|
public LogRecord(java.io.File file,
long offset,
boolean truncated)
file - File to which this record belongsoffset - Offset of this record in the filetruncated - If true this record is truncated rather than merely
empty
public LogRecord(java.io.File file,
long offset,
byte[] bytes,
byte crcType,
long crc)
offset - File offset at which this record was readbytes - Data in recordcrcType - Type of CRC check to usecrc - CRC value| Method Detail |
|---|
public long getRecordLength()
public long getOffset()
public byte[] getData()
public byte getCrcType()
public long getCrc()
public boolean isTruncated()
public boolean isEmpty()
public long computeCrc()
throws java.io.IOException
java.io.IOException
public void storeCrc(byte crcType)
throws java.io.IOException
java.io.IOException
public boolean checkCrc()
throws java.io.IOException
java.io.IOException
public void verifyChecksum()
throws LogConsistencyException
LogConsistencyException - Thrown if checksum verification fails
public static long computeCrc32(byte[] bytes)
throws java.io.IOException
java.io.IOExceptionpublic java.io.InputStream read()
public java.io.OutputStream write()
public void done()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||