org.apache.hadoop.hdfs.util
Class MD5FileUtils

java.lang.Object
  extended by org.apache.hadoop.hdfs.util.MD5FileUtils

public abstract class MD5FileUtils
extends Object

Static functions for dealing with files of the same format that the Unix "md5sum" utility writes.


Field Summary
static String MD5_SUFFIX
           
 
Constructor Summary
MD5FileUtils()
           
 
Method Summary
static org.apache.hadoop.io.MD5Hash computeMd5ForFile(File dataFile)
          Read dataFile and compute its MD5 checksum.
static File getDigestFileForFile(File file)
           
static org.apache.hadoop.io.MD5Hash readStoredMd5ForFile(File dataFile)
          Read the md5 checksum stored alongside the given file, or null if no md5 is stored.
static void saveMD5File(File dataFile, org.apache.hadoop.io.MD5Hash digest)
          Save the ".md5" file that lists the md5sum of another file.
static void verifySavedMD5(File dataFile, org.apache.hadoop.io.MD5Hash expectedMD5)
          Verify that the previously saved md5 for the given file matches expectedMd5.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MD5_SUFFIX

public static final String MD5_SUFFIX
See Also:
Constant Field Values
Constructor Detail

MD5FileUtils

public MD5FileUtils()
Method Detail

verifySavedMD5

public static void verifySavedMD5(File dataFile,
                                  org.apache.hadoop.io.MD5Hash expectedMD5)
                           throws IOException
Verify that the previously saved md5 for the given file matches expectedMd5.

Throws:
IOException

readStoredMd5ForFile

public static org.apache.hadoop.io.MD5Hash readStoredMd5ForFile(File dataFile)
                                                         throws IOException
Read the md5 checksum stored alongside the given file, or null if no md5 is stored.

Parameters:
dataFile - the file containing data
Returns:
the checksum stored in dataFile.md5
Throws:
IOException

computeMd5ForFile

public static org.apache.hadoop.io.MD5Hash computeMd5ForFile(File dataFile)
                                                      throws IOException
Read dataFile and compute its MD5 checksum.

Throws:
IOException

saveMD5File

public static void saveMD5File(File dataFile,
                               org.apache.hadoop.io.MD5Hash digest)
                        throws IOException
Save the ".md5" file that lists the md5sum of another file.

Parameters:
dataFile - the original file whose md5 was computed
digest - the computed digest
Throws:
IOException

getDigestFileForFile

public static File getDigestFileForFile(File file)
Returns:
a reference to the file with .md5 suffix that will contain the md5 checksum for the given data file.


Copyright © 2013 Apache Software Foundation. All Rights Reserved.