ChecksumFileSystem extends FilterFileSystem { public static long getChecksumLength(long size, int bytesPerSum) { return ((size + bytesPerSum - 1) / bytesPerSum) * 4 + CHECKSUM_VERSION.length + 4; } ChecksumFileSystem(FileSystem fs); static double getApproxChkSumLength(long size); @Override void setConf(Configuration conf); @Override void setVerifyChecksum(boolean verifyChecksum); @Override void setWriteChecksum(boolean writeChecksum); @Override FileSystem getRawFileSystem(); Path getChecksumFile(Path file); static boolean isChecksumFile(Path file); long getChecksumFileLength(Path file, long fileSize); int getBytesPerSum(); @Override FSDataInputStream open(Path f, int bufferSize); @Override FSDataOutputStream append(Path f, int bufferSize,
      Progressable progress); @Override boolean truncate(Path f, long newLength); static long getChecksumLength(long size, int bytesPerSum); @Override FSDataOutputStream create(Path f, FsPermission permission,
      boolean overwrite, int bufferSize, short replication, long blockSize,
      Progressable progress); @Override FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
      boolean overwrite, int bufferSize, short replication, long blockSize,
      Progressable progress); @Override boolean setReplication(Path src, short replication); @Override boolean rename(Path src, Path dst); @Override boolean delete(Path f, boolean recursive); @Override FileStatus[] listStatus(Path f); @Override RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f); @Override boolean mkdirs(Path f); @Override void copyFromLocalFile(boolean delSrc, Path src, Path dst); @Override void copyToLocalFile(boolean delSrc, Path src, Path dst); void copyToLocalFile(Path src, Path dst, boolean copyCrc); @Override Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile); @Override void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile); boolean reportChecksumFailure(Path f, FSDataInputStream in,
                                       long inPos, FSDataInputStream sums, long sumsPos);  }
@Test public void testgetChecksumLength() throws Exception { assertEquals(8, ChecksumFileSystem.getChecksumLength(0L, 512)); assertEquals(12, ChecksumFileSystem.getChecksumLength(1L, 512)); assertEquals(12, ChecksumFileSystem.getChecksumLength(512L, 512)); assertEquals(16, ChecksumFileSystem.getChecksumLength(513L, 512)); assertEquals(16, ChecksumFileSystem.getChecksumLength(1023L, 512)); assertEquals(16, ChecksumFileSystem.getChecksumLength(1024L, 512)); assertEquals(408, ChecksumFileSystem.getChecksumLength(100L, 1)); assertEquals(4000000000008L, ChecksumFileSystem.getChecksumLength(10000000000000L, 10)); }