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(int id, String name, INodeDirectory dir);   Snapshot(int id, INodeDirectory dir, INodeDirectory parent); static String generateDefaultSnapshotName(); static String getSnapshotPath(String snapshottableDir,
      String snapshotRelativePath); static int getSnapshotId(Snapshot s); static int findLatestSnapshot(INode inode, final int anchor); int getId(); Root getRoot(); @Override int compareTo(byte[] bytes); @Override boolean equals(Object that); @Override int hashCode(); @Override String toString(); static final int CURRENT_STATE_ID; static final int NO_SNAPSHOT_ID; static final Comparator<Snapshot> ID_COMPARATOR; static final Comparator<Integer> ID_INTEGER_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()); }