Example usage for org.apache.hadoop.hdfs.client HdfsAdmin getEncryptionZoneForPath

List of usage examples for org.apache.hadoop.hdfs.client HdfsAdmin getEncryptionZoneForPath

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.client HdfsAdmin getEncryptionZoneForPath.

Prototype

public EncryptionZone getEncryptionZoneForPath(Path path) throws IOException, AccessControlException 

Source Link

Document

Get the path of the encryption zone for a given file or directory.

Usage

From source file:org.apache.impala.common.FileSystemUtil.java

License:Apache License

/**
 * Returns true if path p1 and path p2 are in the same encryption zone in HDFS.
 * Returns false if they are in different encryption zones or if either of the paths
 * are not on HDFS./* w w w . ja v  a2 s. co m*/
 */
private static boolean arePathsInSameHdfsEncryptionZone(FileSystem fs, Path p1, Path p2) throws IOException {
    // Only distributed file systems have encryption zones.
    if (!isDistributedFileSystem(p1) || !isDistributedFileSystem(p2))
        return false;
    HdfsAdmin hdfsAdmin = new HdfsAdmin(fs.getUri(), CONF);
    EncryptionZone z1 = hdfsAdmin.getEncryptionZoneForPath(p1);
    EncryptionZone z2 = hdfsAdmin.getEncryptionZoneForPath(p2);
    if (z1 == null && z2 == null)
        return true;
    if (z1 == null || z2 == null)
        return false;
    return z1.equals(z2);
}