Author: omalley
Date: Mon Oct 22 16:21:35 2007
New Revision: 587283
URL: http://svn.apache.org/viewvc?rev=587283&view=rev
Log:
Merge -r 587280:587281 from trunk on to branch 0.15. Fixes HADOOP-2080.
Added:
lucene/hadoop/branches/branch-0.15/src/test/org/apache/hadoop/fs/TestChecksumFileSystem.java
- copied unchanged from r587281,
lucene/hadoop/trunk/src/test/org/apache/hadoop/fs/TestChecksumFileSystem.java
Modified:
lucene/hadoop/branches/branch-0.15/CHANGES.txt
lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/ChecksumFileSystem.java
Modified: lucene/hadoop/branches/branch-0.15/CHANGES.txt
URL:
http://svn.apache.org/viewvc/lucene/hadoop/branches/branch-0.15/CHANGES.txt?rev=587283&r1=587282&r2=587283&view=diff
==============================================================================
--- lucene/hadoop/branches/branch-0.15/CHANGES.txt (original)
+++ lucene/hadoop/branches/branch-0.15/CHANGES.txt Mon Oct 22 16:21:35 2007
@@ -319,6 +319,9 @@
that before waiting for the application to finish to ensure all buffered
data is flushed. (Owen O'Malley via acmurthy)
+ HADOOP-2080. Fixed calculation of the checksum file size when the values
+ are large. (omalley)
+
IMPROVEMENTS
HADOOP-1908. Restructure data node code so that block sending and
Modified:
lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/ChecksumFileSystem.java
URL:
http://svn.apache.org/viewvc/lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/ChecksumFileSystem.java?rev=587283&r1=587282&r2=587283&view=diff
==============================================================================
---
lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/ChecksumFileSystem.java
(original)
+++
lucene/hadoop/branches/branch-0.15/src/java/org/apache/hadoop/fs/ChecksumFileSystem.java
Mon Oct 22 16:21:35 2007
@@ -37,6 +37,7 @@
*****************************************************************/
public abstract class ChecksumFileSystem extends FilterFileSystem {
private static final byte[] CHECKSUM_VERSION = new byte[] {'c', 'r', 'c', 0};
+ private final int bytesPerChecksum;
public static double getApproxChkSumLength(long size) {
return ChecksumFSOutputSummer.CHKSUM_AS_FRACTION * size;
@@ -44,6 +45,7 @@
public ChecksumFileSystem(FileSystem fs) {
super(fs);
+ bytesPerChecksum = getConf().getInt("io.bytes.per.checksum", 512);
}
/** get the raw file system */
@@ -66,12 +68,12 @@
* actual file.
**/
public long getChecksumFileLength(Path file, long fileSize) {
- return ChecksumFSOutputSummer.getChecksumLength(fileSize,
getBytesPerSum());
+ return getChecksumLength(fileSize, getBytesPerSum());
}
/** Return the bytes Per Checksum */
public int getBytesPerSum() {
- return getConf().getInt("io.bytes.per.checksum", 512);
+ return bytesPerChecksum;
}
private int getSumBufferSize(int bytesPerSum, int bufferSize) {
@@ -267,6 +269,19 @@
new ChecksumFSInputChecker(this, f, bufferSize) );
}
+ /**
+ * Calculated the length of the checksum file in bytes.
+ * @param size the length of the data file in bytes
+ * @param bytesPerSum the number of bytes in a checksum block
+ * @return the number of bytes in the checksum file
+ */
+ public static long getChecksumLength(long size, int bytesPerSum) {
+ //the checksum length is equal to size passed divided by bytesPerSum +
+ //bytes written in the beginning of the checksum file.
+ return ((size + bytesPerSum - 1) / bytesPerSum) * 4 +
+ CHECKSUM_VERSION.length + 4;
+ }
+
/** This class provides an output stream for a checksummed file.
* It generates checksums for data. */
private static class ChecksumFSOutputSummer extends FSOutputSummer {
@@ -312,13 +327,6 @@
datas.close();
}
- public static long getChecksumLength(long size, int bytesPerSum) {
- //the checksum length is equal to size passed divided by bytesPerSum +
- //bytes written in the beginning of the checksum file.
- return ((long)(Math.ceil((float)size/bytesPerSum)) + 1) * 4 +
- CHECKSUM_VERSION.length;
- }
-
@Override
protected void writeChunk(byte[] b, int offset, int len, byte[] checksum)
throws IOException {