Example usage for org.apache.hadoop.hdfs DistributedFileSystem getSnapshottableDirListing

List of usage examples for org.apache.hadoop.hdfs DistributedFileSystem getSnapshottableDirListing

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DistributedFileSystem getSnapshottableDirListing.

Prototype

public SnapshottableDirectoryStatus[] getSnapshottableDirListing() throws IOException 

Source Link

Usage

From source file:org.apache.falcon.extensions.mirroring.hdfsSnapshot.HdfsSnapshotMirroringExtension.java

License:Apache License

private static boolean isDirSnapshotable(DistributedFileSystem hdfs, Path path) throws FalconException {
    try {//  w  w w  .  j  a  v a2 s. co  m
        LOG.debug("HDFS Snapshot extension validating if dir {} is snapshotable.", path.toString());
        SnapshottableDirectoryStatus[] snapshotableDirs = hdfs.getSnapshottableDirListing();
        if (snapshotableDirs != null && snapshotableDirs.length > 0) {
            for (SnapshottableDirectoryStatus dir : snapshotableDirs) {
                if (dir.getFullPath().toString().equals(path.toString())) {
                    return true;
                }
            }
        }
        return false;
    } catch (IOException e) {
        LOG.error("Unable to verify if dir {} is snapshot-able. {}", path.toString(), e.getMessage());
        throw new FalconException("Unable to verify if dir " + path.toString() + " is snapshot-able", e);
    }
}