List of usage examples for org.apache.hadoop.hdfs.protocol SnapshottableDirectoryStatus getFullPath
public Path getFullPath()
From source file:backup.namenode.NameNodeBackupBlockCheckProcessor.java
License:Apache License
private ExternalExtendedBlockSort<Addresses> fetchBlocksFromNameNode(BackupReportWriter writer) throws Exception { writer.startBlockMetaDataFetchFromNameNode(); Path sortDir = getLocalSort(NAMENODE_SORT); ExternalExtendedBlockSort<Addresses> nameNodeBlocks = new ExternalExtendedBlockSort<Addresses>(conf, sortDir, Addresses.class); Set<Path> pathSetToIgnore = getPathSetToIgnore(); Path path = new Path("/"); // Add normal files addExtendedBlocksFromNameNode(writer, nameNodeBlocks, path, pathSetToIgnore); // Add snapshot dirs SnapshottableDirectoryStatus[] snapshottableDirListing = fileSystem.getSnapshottableDirListing(); if (snapshottableDirListing != null) { for (SnapshottableDirectoryStatus status : snapshottableDirListing) { addExtendedBlocksFromNameNode(writer, nameNodeBlocks, new Path(status.getFullPath(), SNAPSHOT), pathSetToIgnore);//ww w . ja v a 2 s. com } } writer.completeBlockMetaDataFetchFromNameNode(); return nameNodeBlocks; }
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 a 2 s. c o 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); } }