@InterfaceAudience.Private public class ChecksumUtil extends Object
| Modifier and Type | Field and Description | 
|---|---|
| static int | CHECKSUM_BUF_SIZE | 
| private static boolean | generateExceptionsThis is used by unit tests to make checksum failures throw an
 exception instead of returning null. | 
| static org.slf4j.Logger | LOG | 
| Constructor and Description | 
|---|
| ChecksumUtil() | 
| Modifier and Type | Method and Description | 
|---|---|
| (package private) static void | generateChecksums(byte[] indata,
                 int startOffset,
                 int endOffset,
                 byte[] outdata,
                 int outOffset,
                 ChecksumType checksumType,
                 int bytesPerChecksum)Generates a checksum for all the data in indata. | 
| static void | generateExceptionForChecksumFailureForTest(boolean value)Mechanism to throw an exception in case of hbase checksum
 failure. | 
| (package private) static long | numBytes(long datasize,
        int bytesPerChecksum)Returns the number of bytes needed to store the checksums for
 a specified data size | 
| (package private) static long | numChunks(long datasize,
         int bytesPerChecksum)Returns the number of checksum chunks needed to store the checksums for
 a specified data size | 
| (package private) static boolean | validateChecksum(ByteBuff buf,
                String pathName,
                long offset,
                int hdrSize)Validates that the data in the specified HFileBlock matches the checksum. | 
| private static boolean | verifyChunkedSums(org.apache.hadoop.util.DataChecksum dataChecksum,
                 ByteBuff data,
                 ByteBuff checksums,
                 String pathName)Like the hadoop's  DataChecksum.verifyChunkedSums(ByteBuffer, ByteBuffer, String, long),
 this method will also verify checksum of each chunk in data. | 
public static final org.slf4j.Logger LOG
public static final int CHECKSUM_BUF_SIZE
private static boolean generateExceptions
public ChecksumUtil()
static void generateChecksums(byte[] indata, int startOffset, int endOffset, byte[] outdata, int outOffset, ChecksumType checksumType, int bytesPerChecksum) throws IOException
indata - input data streamstartOffset - starting offset in the indata stream from where to
                    compute checkums fromendOffset - ending offset in the indata stream upto
                   which checksums needs to be computedoutdata - the output buffer where checksum values are writtenoutOffset - the starting offset in the outdata where the
                  checksum values are writtenchecksumType - type of checksumbytesPerChecksum - number of bytes per checksum valueIOExceptionprivate static boolean verifyChunkedSums(org.apache.hadoop.util.DataChecksum dataChecksum, ByteBuff data, ByteBuff checksums, String pathName)
DataChecksum.verifyChunkedSums(ByteBuffer, ByteBuffer, String, long),
 this method will also verify checksum of each chunk in data. the difference is: this method can
 accept ByteBuff as arguments, we can not add it in hadoop-common so defined here.dataChecksum - to calculate the checksum.data - as the inputchecksums - to comparepathName - indicate that the data is read from which file.DataChecksum.verifyChunkedSums(ByteBuffer, ByteBuffer, String,
      long)static boolean validateChecksum(ByteBuff buf, String pathName, long offset, int hdrSize)
buf - Contains the data in following order: HFileBlock header, data, checksums.pathName - Path of the HFile to which the data belongs. Only used for logging.offset - offset of the data being validated. Only used for logging.hdrSize - Size of the block header in data. Only used for logging.static long numBytes(long datasize, int bytesPerChecksum)
datasize - number of bytes of databytesPerChecksum - number of bytes in a checksum chunkstatic long numChunks(long datasize, int bytesPerChecksum)
datasize - number of bytes of databytesPerChecksum - number of bytes in a checksum chunkpublic static void generateExceptionForChecksumFailureForTest(boolean value)
value - Setting this to true will cause hbase checksum
              verification failures to generate exceptions.Copyright © 2007–2021 The Apache Software Foundation. All rights reserved.