hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [42/51] [partial] hbase-site git commit: Published site at df829ea7d1b4d2ef745e29d2b25b12966000eeb2.
Date Wed, 10 Feb 2016 16:27:52 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/40ef21e4/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/ChecksumUtil.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/ChecksumUtil.html b/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/ChecksumUtil.html
index a7a0401..ffe6426 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/ChecksumUtil.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/io/hfile/ChecksumUtil.html
@@ -46,11 +46,11 @@
 <span class="sourceLineNo">038</span>  /** This is used to reserve space in a
byte buffer */<a name="line.38"></a>
 <span class="sourceLineNo">039</span>  private static byte[] DUMMY_VALUE = new
byte[128 * HFileBlock.CHECKSUM_SIZE];<a name="line.39"></a>
 <span class="sourceLineNo">040</span><a name="line.40"></a>
-<span class="sourceLineNo">041</span>  /** <a name="line.41"></a>
-<span class="sourceLineNo">042</span>   * This is used by unit tests to make
checksum failures throw an <a name="line.42"></a>
-<span class="sourceLineNo">043</span>   * exception instead of returning null.
Returning a null value from <a name="line.43"></a>
-<span class="sourceLineNo">044</span>   * checksum validation will cause the
higher layer to retry that <a name="line.44"></a>
-<span class="sourceLineNo">045</span>   * read with hdfs-level checksums. Instead,
we would like checksum <a name="line.45"></a>
+<span class="sourceLineNo">041</span>  /**<a name="line.41"></a>
+<span class="sourceLineNo">042</span>   * This is used by unit tests to make
checksum failures throw an<a name="line.42"></a>
+<span class="sourceLineNo">043</span>   * exception instead of returning null.
Returning a null value from<a name="line.43"></a>
+<span class="sourceLineNo">044</span>   * checksum validation will cause the
higher layer to retry that<a name="line.44"></a>
+<span class="sourceLineNo">045</span>   * read with hdfs-level checksums. Instead,
we would like checksum<a name="line.45"></a>
 <span class="sourceLineNo">046</span>   * failures to cause the entire unit test
to fail.<a name="line.46"></a>
 <span class="sourceLineNo">047</span>   */<a name="line.47"></a>
 <span class="sourceLineNo">048</span>  private static boolean generateExceptions
= false;<a name="line.48"></a>
@@ -94,7 +94,7 @@
 <span class="sourceLineNo">086</span>   * The header is extracted from the specified
HFileBlock while the<a name="line.86"></a>
 <span class="sourceLineNo">087</span>   * data-to-be-verified is extracted from
'data'.<a name="line.87"></a>
 <span class="sourceLineNo">088</span>   */<a name="line.88"></a>
-<span class="sourceLineNo">089</span>  static boolean validateBlockChecksum(String
pathName, HFileBlock block,<a name="line.89"></a>
+<span class="sourceLineNo">089</span>  static boolean validateBlockChecksum(String
pathName, long offset, HFileBlock block,<a name="line.89"></a>
 <span class="sourceLineNo">090</span>    byte[] data, int hdrSize) throws IOException
{<a name="line.90"></a>
 <span class="sourceLineNo">091</span><a name="line.91"></a>
 <span class="sourceLineNo">092</span>    // If this is an older version of the
block that does not have<a name="line.92"></a>
@@ -108,7 +108,7 @@
 <span class="sourceLineNo">100</span>    }<a name="line.100"></a>
 <span class="sourceLineNo">101</span><a name="line.101"></a>
 <span class="sourceLineNo">102</span>    // Get a checksum object based on the
type of checksum that is<a name="line.102"></a>
-<span class="sourceLineNo">103</span>    // set in the HFileBlock header. A ChecksumType.NULL
indicates that <a name="line.103"></a>
+<span class="sourceLineNo">103</span>    // set in the HFileBlock header. A ChecksumType.NULL
indicates that<a name="line.103"></a>
 <span class="sourceLineNo">104</span>    // the caller is not interested in validating
checksums, so we<a name="line.104"></a>
 <span class="sourceLineNo">105</span>    // always return true.<a name="line.105"></a>
 <span class="sourceLineNo">106</span>    ChecksumType cktype = ChecksumType.codeToType(block.getChecksumType());<a
name="line.106"></a>
@@ -124,79 +124,80 @@
 <span class="sourceLineNo">116</span>    assert dataChecksum != null;<a name="line.116"></a>
 <span class="sourceLineNo">117</span>    int sizeWithHeader =  block.getOnDiskDataSizeWithHeader();<a
name="line.117"></a>
 <span class="sourceLineNo">118</span>    if (LOG.isTraceEnabled()) {<a name="line.118"></a>
-<span class="sourceLineNo">119</span>      LOG.info("length of data = " + data.length<a
name="line.119"></a>
-<span class="sourceLineNo">120</span>          + " OnDiskDataSizeWithHeader =
" + sizeWithHeader<a name="line.120"></a>
-<span class="sourceLineNo">121</span>          + " checksum type = " + cktype.getName()<a
name="line.121"></a>
-<span class="sourceLineNo">122</span>          + " file =" + pathName<a name="line.122"></a>
-<span class="sourceLineNo">123</span>          + " header size = " + hdrSize<a
name="line.123"></a>
-<span class="sourceLineNo">124</span>          + " bytesPerChecksum = " + bytesPerChecksum);<a
name="line.124"></a>
-<span class="sourceLineNo">125</span>    }<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    try {<a name="line.126"></a>
-<span class="sourceLineNo">127</span>      dataChecksum.verifyChunkedSums(ByteBuffer.wrap(data,
0, sizeWithHeader),<a name="line.127"></a>
-<span class="sourceLineNo">128</span>          ByteBuffer.wrap(data, sizeWithHeader,
data.length - sizeWithHeader), pathName, 0);<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    } catch (ChecksumException e) {<a
name="line.129"></a>
-<span class="sourceLineNo">130</span>      return false;<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    }<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    return true;  // checksum is valid<a
name="line.132"></a>
-<span class="sourceLineNo">133</span>  }<a name="line.133"></a>
-<span class="sourceLineNo">134</span><a name="line.134"></a>
-<span class="sourceLineNo">135</span>  /**<a name="line.135"></a>
-<span class="sourceLineNo">136</span>   * Returns the number of bytes needed
to store the checksums for<a name="line.136"></a>
-<span class="sourceLineNo">137</span>   * a specified data size<a name="line.137"></a>
-<span class="sourceLineNo">138</span>   * @param datasize number of bytes of
data<a name="line.138"></a>
-<span class="sourceLineNo">139</span>   * @param bytesPerChecksum number of bytes
in a checksum chunk<a name="line.139"></a>
-<span class="sourceLineNo">140</span>   * @return The number of bytes needed
to store the checksum values<a name="line.140"></a>
-<span class="sourceLineNo">141</span>   */<a name="line.141"></a>
-<span class="sourceLineNo">142</span>  static long numBytes(long datasize, int
bytesPerChecksum) {<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    return numChunks(datasize, bytesPerChecksum)
* <a name="line.143"></a>
-<span class="sourceLineNo">144</span>                     HFileBlock.CHECKSUM_SIZE;<a
name="line.144"></a>
-<span class="sourceLineNo">145</span>  }<a name="line.145"></a>
-<span class="sourceLineNo">146</span><a name="line.146"></a>
-<span class="sourceLineNo">147</span>  /**<a name="line.147"></a>
-<span class="sourceLineNo">148</span>   * Returns the number of checksum chunks
needed to store the checksums for<a name="line.148"></a>
-<span class="sourceLineNo">149</span>   * a specified data size<a name="line.149"></a>
-<span class="sourceLineNo">150</span>   * @param datasize number of bytes of
data<a name="line.150"></a>
-<span class="sourceLineNo">151</span>   * @param bytesPerChecksum number of bytes
in a checksum chunk<a name="line.151"></a>
-<span class="sourceLineNo">152</span>   * @return The number of checksum chunks<a
name="line.152"></a>
-<span class="sourceLineNo">153</span>   */<a name="line.153"></a>
-<span class="sourceLineNo">154</span>  static long numChunks(long datasize, int
bytesPerChecksum) {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    long numChunks = datasize/bytesPerChecksum;<a
name="line.155"></a>
-<span class="sourceLineNo">156</span>    if (datasize % bytesPerChecksum != 0)
{<a name="line.156"></a>
-<span class="sourceLineNo">157</span>      numChunks++;<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    }<a name="line.158"></a>
-<span class="sourceLineNo">159</span>    return numChunks;<a name="line.159"></a>
-<span class="sourceLineNo">160</span>  }<a name="line.160"></a>
-<span class="sourceLineNo">161</span><a name="line.161"></a>
-<span class="sourceLineNo">162</span>  /**<a name="line.162"></a>
-<span class="sourceLineNo">163</span>   * Write dummy checksums to the end of
the specified bytes array<a name="line.163"></a>
-<span class="sourceLineNo">164</span>   * to reserve space for writing checksums
later<a name="line.164"></a>
-<span class="sourceLineNo">165</span>   * @param baos OutputStream to write dummy
checkum values<a name="line.165"></a>
-<span class="sourceLineNo">166</span>   * @param numBytes Number of bytes of
data for which dummy checksums<a name="line.166"></a>
-<span class="sourceLineNo">167</span>   *                 need to be generated<a
name="line.167"></a>
-<span class="sourceLineNo">168</span>   * @param bytesPerChecksum Number of bytes
per checksum value<a name="line.168"></a>
-<span class="sourceLineNo">169</span>   */<a name="line.169"></a>
-<span class="sourceLineNo">170</span>  static void reserveSpaceForChecksums(ByteArrayOutputStream
baos,<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    int numBytes, int bytesPerChecksum)
throws IOException {<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    long numChunks = numChunks(numBytes,
bytesPerChecksum);<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    long bytesLeft = numChunks * HFileBlock.CHECKSUM_SIZE;<a
name="line.173"></a>
-<span class="sourceLineNo">174</span>    while (bytesLeft &gt; 0) {<a
name="line.174"></a>
-<span class="sourceLineNo">175</span>      long count = Math.min(bytesLeft, DUMMY_VALUE.length);<a
name="line.175"></a>
-<span class="sourceLineNo">176</span>      baos.write(DUMMY_VALUE, 0, (int)count);<a
name="line.176"></a>
-<span class="sourceLineNo">177</span>      bytesLeft -= count;<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    }<a name="line.178"></a>
-<span class="sourceLineNo">179</span>  }<a name="line.179"></a>
-<span class="sourceLineNo">180</span><a name="line.180"></a>
-<span class="sourceLineNo">181</span>  /**<a name="line.181"></a>
-<span class="sourceLineNo">182</span>   * Mechanism to throw an exception in
case of hbase checksum<a name="line.182"></a>
-<span class="sourceLineNo">183</span>   * failure. This is used by unit tests
only.<a name="line.183"></a>
-<span class="sourceLineNo">184</span>   * @param value Setting this to true will
cause hbase checksum<a name="line.184"></a>
-<span class="sourceLineNo">185</span>   *              verification failures
to generate exceptions.<a name="line.185"></a>
-<span class="sourceLineNo">186</span>   */<a name="line.186"></a>
-<span class="sourceLineNo">187</span>  public static void generateExceptionForChecksumFailureForTest(boolean
value) {<a name="line.187"></a>
-<span class="sourceLineNo">188</span>    generateExceptions = value;<a name="line.188"></a>
-<span class="sourceLineNo">189</span>  }<a name="line.189"></a>
-<span class="sourceLineNo">190</span>}<a name="line.190"></a>
-<span class="sourceLineNo">191</span><a name="line.191"></a>
+<span class="sourceLineNo">119</span>      LOG.info("dataLength=" + data.length<a
name="line.119"></a>
+<span class="sourceLineNo">120</span>          + ", sizeWithHeader=" + sizeWithHeader<a
name="line.120"></a>
+<span class="sourceLineNo">121</span>          + ", checksumType=" + cktype.getName()<a
name="line.121"></a>
+<span class="sourceLineNo">122</span>          + ", file=" + pathName<a name="line.122"></a>
+<span class="sourceLineNo">123</span>          + ", offset=" + offset<a name="line.123"></a>
+<span class="sourceLineNo">124</span>          + ", headerSize=" + hdrSize<a
name="line.124"></a>
+<span class="sourceLineNo">125</span>          + ", bytesPerChecksum=" + bytesPerChecksum);<a
name="line.125"></a>
+<span class="sourceLineNo">126</span>    }<a name="line.126"></a>
+<span class="sourceLineNo">127</span>    try {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>      dataChecksum.verifyChunkedSums(ByteBuffer.wrap(data,
0, sizeWithHeader),<a name="line.128"></a>
+<span class="sourceLineNo">129</span>          ByteBuffer.wrap(data, sizeWithHeader,
data.length - sizeWithHeader), pathName, 0);<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    } catch (ChecksumException e) {<a
name="line.130"></a>
+<span class="sourceLineNo">131</span>      return false;<a name="line.131"></a>
+<span class="sourceLineNo">132</span>    }<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    return true;  // checksum is valid<a
name="line.133"></a>
+<span class="sourceLineNo">134</span>  }<a name="line.134"></a>
+<span class="sourceLineNo">135</span><a name="line.135"></a>
+<span class="sourceLineNo">136</span>  /**<a name="line.136"></a>
+<span class="sourceLineNo">137</span>   * Returns the number of bytes needed
to store the checksums for<a name="line.137"></a>
+<span class="sourceLineNo">138</span>   * a specified data size<a name="line.138"></a>
+<span class="sourceLineNo">139</span>   * @param datasize number of bytes of
data<a name="line.139"></a>
+<span class="sourceLineNo">140</span>   * @param bytesPerChecksum number of bytes
in a checksum chunk<a name="line.140"></a>
+<span class="sourceLineNo">141</span>   * @return The number of bytes needed
to store the checksum values<a name="line.141"></a>
+<span class="sourceLineNo">142</span>   */<a name="line.142"></a>
+<span class="sourceLineNo">143</span>  static long numBytes(long datasize, int
bytesPerChecksum) {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>    return numChunks(datasize, bytesPerChecksum)
*<a name="line.144"></a>
+<span class="sourceLineNo">145</span>                     HFileBlock.CHECKSUM_SIZE;<a
name="line.145"></a>
+<span class="sourceLineNo">146</span>  }<a name="line.146"></a>
+<span class="sourceLineNo">147</span><a name="line.147"></a>
+<span class="sourceLineNo">148</span>  /**<a name="line.148"></a>
+<span class="sourceLineNo">149</span>   * Returns the number of checksum chunks
needed to store the checksums for<a name="line.149"></a>
+<span class="sourceLineNo">150</span>   * a specified data size<a name="line.150"></a>
+<span class="sourceLineNo">151</span>   * @param datasize number of bytes of
data<a name="line.151"></a>
+<span class="sourceLineNo">152</span>   * @param bytesPerChecksum number of bytes
in a checksum chunk<a name="line.152"></a>
+<span class="sourceLineNo">153</span>   * @return The number of checksum chunks<a
name="line.153"></a>
+<span class="sourceLineNo">154</span>   */<a name="line.154"></a>
+<span class="sourceLineNo">155</span>  static long numChunks(long datasize, int
bytesPerChecksum) {<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    long numChunks = datasize/bytesPerChecksum;<a
name="line.156"></a>
+<span class="sourceLineNo">157</span>    if (datasize % bytesPerChecksum != 0)
{<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      numChunks++;<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    }<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    return numChunks;<a name="line.160"></a>
+<span class="sourceLineNo">161</span>  }<a name="line.161"></a>
+<span class="sourceLineNo">162</span><a name="line.162"></a>
+<span class="sourceLineNo">163</span>  /**<a name="line.163"></a>
+<span class="sourceLineNo">164</span>   * Write dummy checksums to the end of
the specified bytes array<a name="line.164"></a>
+<span class="sourceLineNo">165</span>   * to reserve space for writing checksums
later<a name="line.165"></a>
+<span class="sourceLineNo">166</span>   * @param baos OutputStream to write dummy
checkum values<a name="line.166"></a>
+<span class="sourceLineNo">167</span>   * @param numBytes Number of bytes of
data for which dummy checksums<a name="line.167"></a>
+<span class="sourceLineNo">168</span>   *                 need to be generated<a
name="line.168"></a>
+<span class="sourceLineNo">169</span>   * @param bytesPerChecksum Number of bytes
per checksum value<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   */<a name="line.170"></a>
+<span class="sourceLineNo">171</span>  static void reserveSpaceForChecksums(ByteArrayOutputStream
baos,<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    int numBytes, int bytesPerChecksum)
throws IOException {<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    long numChunks = numChunks(numBytes,
bytesPerChecksum);<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    long bytesLeft = numChunks * HFileBlock.CHECKSUM_SIZE;<a
name="line.174"></a>
+<span class="sourceLineNo">175</span>    while (bytesLeft &gt; 0) {<a
name="line.175"></a>
+<span class="sourceLineNo">176</span>      long count = Math.min(bytesLeft, DUMMY_VALUE.length);<a
name="line.176"></a>
+<span class="sourceLineNo">177</span>      baos.write(DUMMY_VALUE, 0, (int)count);<a
name="line.177"></a>
+<span class="sourceLineNo">178</span>      bytesLeft -= count;<a name="line.178"></a>
+<span class="sourceLineNo">179</span>    }<a name="line.179"></a>
+<span class="sourceLineNo">180</span>  }<a name="line.180"></a>
+<span class="sourceLineNo">181</span><a name="line.181"></a>
+<span class="sourceLineNo">182</span>  /**<a name="line.182"></a>
+<span class="sourceLineNo">183</span>   * Mechanism to throw an exception in
case of hbase checksum<a name="line.183"></a>
+<span class="sourceLineNo">184</span>   * failure. This is used by unit tests
only.<a name="line.184"></a>
+<span class="sourceLineNo">185</span>   * @param value Setting this to true will
cause hbase checksum<a name="line.185"></a>
+<span class="sourceLineNo">186</span>   *              verification failures
to generate exceptions.<a name="line.186"></a>
+<span class="sourceLineNo">187</span>   */<a name="line.187"></a>
+<span class="sourceLineNo">188</span>  public static void generateExceptionForChecksumFailureForTest(boolean
value) {<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    generateExceptions = value;<a name="line.189"></a>
+<span class="sourceLineNo">190</span>  }<a name="line.190"></a>
+<span class="sourceLineNo">191</span>}<a name="line.191"></a>
+<span class="sourceLineNo">192</span><a name="line.192"></a>
 
 
 


Mime
View raw message