### Question:
Snapshot implements Comparable<byte[]> { @Override public String toString() { return getClass().getSimpleName() + "." + root.getLocalName() + "(id=" + id + ")"; } 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; }### Answer:
@Test public void testAllowAndDisallowSnapshot() throws Exception { final Path dir = new Path("/dir"); final Path file0 = new Path(dir, "file0"); final Path file1 = new Path(dir, "file1"); DFSTestUtil.createFile(hdfs, file0, BLOCKSIZE, REPLICATION, seed); DFSTestUtil.createFile(hdfs, file1, BLOCKSIZE, REPLICATION, seed); INodeDirectory dirNode = fsdir.getINode4Write(dir.toString()).asDirectory(); assertFalse(dirNode.isSnapshottable()); hdfs.allowSnapshot(dir); dirNode = fsdir.getINode4Write(dir.toString()).asDirectory(); assertTrue(dirNode.isSnapshottable()); hdfs.allowSnapshot(dir); dirNode = fsdir.getINode4Write(dir.toString()).asDirectory(); assertTrue(dirNode.isSnapshottable()); hdfs.disallowSnapshot(dir); dirNode = fsdir.getINode4Write(dir.toString()).asDirectory(); assertFalse(dirNode.isSnapshottable()); hdfs.disallowSnapshot(dir); dirNode = fsdir.getINode4Write(dir.toString()).asDirectory(); assertFalse(dirNode.isSnapshottable()); final Path root = new Path("/"); INodeDirectory rootNode = fsdir.getINode4Write(root.toString()) .asDirectory(); assertTrue(rootNode.isSnapshottable()); assertEquals(0, rootNode.getDirectorySnapshottableFeature() .getSnapshotQuota()); hdfs.allowSnapshot(root); rootNode = fsdir.getINode4Write(root.toString()).asDirectory(); assertTrue(rootNode.isSnapshottable()); assertEquals(DirectorySnapshottableFeature.SNAPSHOT_LIMIT, rootNode.getDirectorySnapshottableFeature().getSnapshotQuota()); hdfs.allowSnapshot(root); rootNode = fsdir.getINode4Write(root.toString()).asDirectory(); assertTrue(rootNode.isSnapshottable()); assertEquals(DirectorySnapshottableFeature.SNAPSHOT_LIMIT, rootNode.getDirectorySnapshottableFeature().getSnapshotQuota()); hdfs.disallowSnapshot(root); rootNode = fsdir.getINode4Write(root.toString()).asDirectory(); assertTrue(rootNode.isSnapshottable()); assertEquals(0, rootNode.getDirectorySnapshottableFeature().getSnapshotQuota()); hdfs.disallowSnapshot(root); rootNode = fsdir.getINode4Write(root.toString()).asDirectory(); assertTrue(rootNode.isSnapshottable()); assertEquals(0, rootNode.getDirectorySnapshottableFeature().getSnapshotQuota()); }