Search in sources :

Example 26 with FileChecksum

use of org.apache.hadoop.fs.FileChecksum in project hadoop by apache.

the class TestFileChecksum method testStripedAndReplicatedFileChecksum.

@Test(timeout = 90000)
public void testStripedAndReplicatedFileChecksum() throws Exception {
    prepareTestFiles(fileSize, new String[] { stripedFile1, replicatedFile });
    FileChecksum stripedFileChecksum1 = getFileChecksum(stripedFile1, 10, false);
    FileChecksum replicatedFileChecksum = getFileChecksum(replicatedFile, 10, false);
    Assert.assertFalse(stripedFileChecksum1.equals(replicatedFileChecksum));
}
Also used : FileChecksum(org.apache.hadoop.fs.FileChecksum) Test(org.junit.Test)

Example 27 with FileChecksum

use of org.apache.hadoop.fs.FileChecksum in project hive by apache.

the class Hive method addInsertNonDirectoryInformation.

private static void addInsertNonDirectoryInformation(Path p, FileSystem fileSystem, InsertEventRequestData insertData) throws IOException {
    insertData.addToFilesAdded(p.toString());
    FileChecksum cksum = fileSystem.getFileChecksum(p);
    // File checksum is not implemented for local filesystem (RawLocalFileSystem)
    if (cksum != null) {
        String checksumString = StringUtils.byteToHexString(cksum.getBytes(), 0, cksum.getLength());
        insertData.addToFilesAddedChecksum(checksumString);
    } else {
        // Add an empty checksum string for filesystems that don't generate one
        insertData.addToFilesAddedChecksum("");
    }
}
Also used : FileChecksum(org.apache.hadoop.fs.FileChecksum)

Example 28 with FileChecksum

use of org.apache.hadoop.fs.FileChecksum in project hive by apache.

the class ReplChangeManager method checksumFor.

// Get checksum of a file
public static String checksumFor(Path path, FileSystem fs) throws IOException {
    // TODO: fs checksum only available on hdfs, need to
    // find a solution for other fs (eg, local fs, s3, etc)
    String checksumString = null;
    FileChecksum checksum = fs.getFileChecksum(path);
    if (checksum != null) {
        checksumString = StringUtils.byteToHexString(checksum.getBytes(), 0, checksum.getLength());
    }
    return checksumString;
}
Also used : FileChecksum(org.apache.hadoop.fs.FileChecksum)

Aggregations

FileChecksum (org.apache.hadoop.fs.FileChecksum)28 Path (org.apache.hadoop.fs.Path)13 Test (org.junit.Test)11 FileSystem (org.apache.hadoop.fs.FileSystem)8 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)2 Configuration (org.apache.hadoop.conf.Configuration)2 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)2 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)2 DataInput (java.io.DataInput)1 DataOutput (java.io.DataOutput)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 SocketTimeoutException (java.net.SocketTimeoutException)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1