|
@@ -39,6 +39,7 @@ import org.apache.hadoop.util.StringUtils;
|
|
public abstract class ChecksumFileSystem extends FilterFileSystem {
|
|
public abstract class ChecksumFileSystem extends FilterFileSystem {
|
|
private static final byte[] CHECKSUM_VERSION = new byte[] {'c', 'r', 'c', 0};
|
|
private static final byte[] CHECKSUM_VERSION = new byte[] {'c', 'r', 'c', 0};
|
|
private int bytesPerChecksum = 512;
|
|
private int bytesPerChecksum = 512;
|
|
|
|
+ private boolean verifyChecksum = true;
|
|
|
|
|
|
public static double getApproxChkSumLength(long size) {
|
|
public static double getApproxChkSumLength(long size) {
|
|
return ChecksumFSOutputSummer.CHKSUM_AS_FRACTION * size;
|
|
return ChecksumFSOutputSummer.CHKSUM_AS_FRACTION * size;
|
|
@@ -54,6 +55,13 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
|
|
bytesPerChecksum = conf.getInt("io.bytes.per.checksum", 512);
|
|
bytesPerChecksum = conf.getInt("io.bytes.per.checksum", 512);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set whether to verify checksum.
|
|
|
|
+ */
|
|
|
|
+ public void setVerifyChecksum(boolean verifyChecksum) {
|
|
|
|
+ this.verifyChecksum = verifyChecksum;
|
|
|
|
+ }
|
|
|
|
|
|
/** get the raw file system */
|
|
/** get the raw file system */
|
|
public FileSystem getRawFileSystem() {
|
|
public FileSystem getRawFileSystem() {
|
|
@@ -127,14 +135,14 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
|
|
if (!Arrays.equals(version, CHECKSUM_VERSION))
|
|
if (!Arrays.equals(version, CHECKSUM_VERSION))
|
|
throw new IOException("Not a checksum file: "+sumFile);
|
|
throw new IOException("Not a checksum file: "+sumFile);
|
|
this.bytesPerSum = sums.readInt();
|
|
this.bytesPerSum = sums.readInt();
|
|
- set(new CRC32(), bytesPerSum, 4);
|
|
|
|
|
|
+ set(fs.verifyChecksum, new CRC32(), bytesPerSum, 4);
|
|
} catch (FileNotFoundException e) { // quietly ignore
|
|
} catch (FileNotFoundException e) { // quietly ignore
|
|
- set(null, 1, 0);
|
|
|
|
|
|
+ set(fs.verifyChecksum, null, 1, 0);
|
|
} catch (IOException e) { // loudly ignore
|
|
} catch (IOException e) { // loudly ignore
|
|
LOG.warn("Problem opening checksum file: "+ file +
|
|
LOG.warn("Problem opening checksum file: "+ file +
|
|
". Ignoring exception: " +
|
|
". Ignoring exception: " +
|
|
StringUtils.stringifyException(e));
|
|
StringUtils.stringifyException(e));
|
|
- set(null, 1, 0);
|
|
|
|
|
|
+ set(fs.verifyChecksum, null, 1, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -175,7 +183,7 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
|
|
if( sums != null ) {
|
|
if( sums != null ) {
|
|
sums.close();
|
|
sums.close();
|
|
}
|
|
}
|
|
- set(null, 1, 0);
|
|
|
|
|
|
+ set(fs.verifyChecksum, null, 1, 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|