Snapshot implements Comparable<byte[]> { public static String getSnapshotPath(String snapshottableDir, String snapshotRelativePath) { final StringBuilder b = new StringBuilder(snapshottableDir); if (b.charAt(b.length() - 1) != Path.SEPARATOR_CHAR) { b.append(Path.SEPARATOR); } return b.append(HdfsConstants.DOT_SNAPSHOT_DIR) .append(Path.SEPARATOR) .append(snapshotRelativePath) .toString(); } Snapshot(long id, String name, INodeDirectorySnapshottable dir);   Snapshot(long id, INodeDirectory dir, INodeDirectorySnapshottable parent); static String generateDefaultSnapshotName(); static String getSnapshotPath(String snapshottableDir,
      String snapshotRelativePath); static long getSnapshotId(Snapshot s); static long findLatestSnapshot(INode inode, final long anchor); long getId(); Root getRoot(); @Override int compareTo(byte[] bytes); @Override boolean equals(Object that); @Override int hashCode(); @Override String toString(); static final long CURRENT_STATE_ID; static final long NO_SNAPSHOT_ID; static final Comparator<Snapshot> ID_COMPARATOR; static final Comparator<Integer> ID_INTEGER_COMPARATOR; static final Comparator<Long> ID_LONG_COMPARATOR; }
@Test (timeout=60000) public void testUpdateDirectory() throws Exception { Path dir = new Path("/dir"); Path sub = new Path(dir, "sub"); Path subFile = new Path(sub, "file"); DFSTestUtil.createFile(hdfs, subFile, BLOCKSIZE, REPLICATION, seed); FileStatus oldStatus = hdfs.getFileStatus(sub); hdfs.allowSnapshot(dir); hdfs.createSnapshot(dir, "s1"); hdfs.setTimes(sub, 100L, 100L); Path snapshotPath = SnapshotTestHelper.getSnapshotPath(dir, "s1", "sub"); FileStatus snapshotStatus = hdfs.getFileStatus(snapshotPath); assertEquals(oldStatus.getModificationTime(), snapshotStatus.getModificationTime()); assertEquals(oldStatus.getAccessTime(), snapshotStatus.getAccessTime()); }