Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java Tue Jan 7 20:52:48 2014 @@ -34,6 +34,7 @@ import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.DFSTestUtil; +import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.client.HdfsDataOutputStream; @@ -43,6 +44,7 @@ import org.apache.hadoop.hdfs.protocol.S import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeFile; import org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature.DirectoryDiff; import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectorySnapshottable; +import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot; import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper; import org.apache.hadoop.hdfs.util.Canceler; import org.apache.log4j.Level; @@ -195,11 +197,12 @@ public class TestFSImageWithSnapshot { INodeDirectorySnapshottable rootNode = (INodeDirectorySnapshottable) fsn.dir.getINode4Write(root.toString()); assertTrue("The children list of root should be empty", - rootNode.getChildrenList(null).isEmpty()); + rootNode.getChildrenList(Snapshot.CURRENT_STATE_ID).isEmpty()); // one snapshot on root: s1 List<DirectoryDiff> diffList = rootNode.getDiffs().asList(); assertEquals(1, diffList.size()); - assertEquals("s1", diffList.get(0).getSnapshot().getRoot().getLocalName()); + Snapshot s1 = rootNode.getSnapshot(DFSUtil.string2Bytes("s1")); + assertEquals(s1.getId(), diffList.get(0).getSnapshotId()); // check SnapshotManager's snapshottable directory list assertEquals(1, fsn.getSnapshotManager().getNumSnapshottableDirs());
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java Tue Jan 7 20:52:48 2014 @@ -60,6 +60,7 @@ import org.apache.hadoop.hdfs.protocol.L import org.apache.hadoop.hdfs.protocol.LocatedBlocks; import org.apache.hadoop.hdfs.protocol.QuotaExceededException; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo; +import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot; import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.util.Time; @@ -781,7 +782,7 @@ public class TestINodeFile { } System.out.println("Adding component " + DFSUtil.bytes2String(component)); dir = new INodeDirectory(++id, component, permstatus, 0); - prev.addChild(dir, false, null); + prev.addChild(dir, false, Snapshot.CURRENT_STATE_ID); prev = dir; } return dir; // Last Inode in the chain Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSnapshotPathINodes.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSnapshotPathINodes.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSnapshotPathINodes.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSnapshotPathINodes.java Tue Jan 7 20:52:48 2014 @@ -123,8 +123,12 @@ public class TestSnapshotPathINodes { final Snapshot snapshot, int index) { assertEquals(isSnapshot, inodesInPath.isSnapshot()); assertEquals(index, inodesInPath.getSnapshotRootIndex()); - assertEquals(isSnapshot? snapshot: null, inodesInPath.getPathSnapshot()); - assertEquals(isSnapshot? null: snapshot, inodesInPath.getLatestSnapshot()); + assertEquals(Snapshot.getSnapshotId(isSnapshot ? snapshot : null), + inodesInPath.getPathSnapshotId()); + if (!isSnapshot) { + assertEquals(Snapshot.getSnapshotId(snapshot), + inodesInPath.getLatestSnapshotId()); + } if (isSnapshot && index >= 0) { assertEquals(Snapshot.Root.class, inodesInPath.getINodes()[index].getClass()); } @@ -424,7 +428,7 @@ public class TestSnapshotPathINodes { // The modification time of the snapshot INode should be the same with the // original INode before modification assertEquals(modTime, - snapshotFileNode.getModificationTime(ssNodesInPath.getPathSnapshot())); + snapshotFileNode.getModificationTime(ssNodesInPath.getPathSnapshotId())); // Check the INode for /TestSnapshot/sub1/file1 again names = INode.getPathNames(file1.toString()); Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotTestHelper.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotTestHelper.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotTestHelper.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotTestHelper.java Tue Jan 7 20:52:48 2014 @@ -270,7 +270,8 @@ public class SnapshotTestHelper { public static void dumpTree2File(FSDirectory fsdir, File f) throws IOException{ final PrintWriter out = new PrintWriter(new FileWriter(f, false), true); - fsdir.getINode("/").dumpTreeRecursively(out, new StringBuilder(), null); + fsdir.getINode("/").dumpTreeRecursively(out, new StringBuilder(), + Snapshot.CURRENT_STATE_ID); out.close(); } Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestINodeFileUnderConstructionWithSnapshot.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestINodeFileUnderConstructionWithSnapshot.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestINodeFileUnderConstructionWithSnapshot.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestINodeFileUnderConstructionWithSnapshot.java Tue Jan 7 20:52:48 2014 @@ -156,7 +156,6 @@ public class TestINodeFileUnderConstruct INodeDirectorySnapshottable dirNode = (INodeDirectorySnapshottable) fsdir .getINode(dir.toString()); DirectoryDiff last = dirNode.getDiffs().getLast(); - Snapshot s0 = last.snapshot; // 2. append without closing stream out = appendFileWithoutClosing(file, BLOCKSIZE); @@ -164,7 +163,7 @@ public class TestINodeFileUnderConstruct // re-check nodeInDeleted_S0 dirNode = (INodeDirectorySnapshottable) fsdir.getINode(dir.toString()); - assertEquals(BLOCKSIZE * 2, fileNode.computeFileSize(s0)); + assertEquals(BLOCKSIZE * 2, fileNode.computeFileSize(last.getSnapshotId())); // 3. take snapshot --> close stream hdfs.createSnapshot(dir, "s1"); @@ -175,9 +174,8 @@ public class TestINodeFileUnderConstruct fileNode = (INodeFile) fsdir.getINode(file.toString()); dirNode = (INodeDirectorySnapshottable) fsdir.getINode(dir.toString()); last = dirNode.getDiffs().getLast(); - Snapshot s1 = last.snapshot; assertTrue(fileNode.isWithSnapshot()); - assertEquals(BLOCKSIZE * 3, fileNode.computeFileSize(s1)); + assertEquals(BLOCKSIZE * 3, fileNode.computeFileSize(last.getSnapshotId())); // 4. modify file --> append without closing stream --> take snapshot --> // close stream @@ -187,7 +185,7 @@ public class TestINodeFileUnderConstruct out.close(); // re-check the size of nodeInDeleted_S1 - assertEquals(BLOCKSIZE * 3, fileNode.computeFileSize(s1)); + assertEquals(BLOCKSIZE * 3, fileNode.computeFileSize(last.getSnapshotId())); } /** Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java Tue Jan 7 20:52:48 2014 @@ -44,6 +44,7 @@ import org.apache.hadoop.fs.permission.F import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.DFSOutputStream; import org.apache.hadoop.hdfs.DFSTestUtil; +import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag; @@ -72,6 +73,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +; /** Testing rename with snapshots. */ public class TestRenameWithSnapshots { @@ -402,9 +404,11 @@ public class TestRenameWithSnapshots { final Path foo_s3 = SnapshotTestHelper.getSnapshotPath(sdir1, "s3", "foo"); assertFalse(hdfs.exists(foo_s3)); + INodeDirectorySnapshottable sdir2Node = + (INodeDirectorySnapshottable) fsdir.getINode(sdir2.toString()); + Snapshot s2 = sdir2Node.getSnapshot(DFSUtil.string2Bytes("s2")); INodeFile sfoo = fsdir.getINode(newfoo.toString()).asFile(); - assertEquals("s2", sfoo.getDiffs().getLastSnapshot().getRoot() - .getLocalName()); + assertEquals(s2.getId(), sfoo.getDiffs().getLastSnapshotId()); } /** @@ -604,8 +608,10 @@ public class TestRenameWithSnapshots { INodeFile snode = fsdir.getINode(newfoo.toString()).asFile(); assertEquals(1, snode.getDiffs().asList().size()); - assertEquals("s2", snode.getDiffs().getLastSnapshot().getRoot() - .getLocalName()); + INodeDirectorySnapshottable sdir2Node = + (INodeDirectorySnapshottable) fsdir.getINode(sdir2.toString()); + Snapshot s2 = sdir2Node.getSnapshot(DFSUtil.string2Bytes("s2")); + assertEquals(s2.getId(), snode.getDiffs().getLastSnapshotId()); // restart cluster restartClusterAndCheckImage(true); @@ -758,12 +764,14 @@ public class TestRenameWithSnapshots { assertEquals(2, fooWithCount.getReferenceCount()); INodeDirectory foo = fooWithCount.asDirectory(); assertEquals(1, foo.getDiffs().asList().size()); - assertEquals("s1", foo.getDirectoryWithSnapshotFeature().getLastSnapshot() - .getRoot().getLocalName()); + INodeDirectorySnapshottable sdir1Node = + (INodeDirectorySnapshottable) fsdir.getINode(sdir1.toString()); + Snapshot s1 = sdir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); + assertEquals(s1.getId(), foo.getDirectoryWithSnapshotFeature() + .getLastSnapshotId()); INodeFile bar1 = fsdir.getINode4Write(bar1_dir1.toString()).asFile(); assertEquals(1, bar1.getDiffs().asList().size()); - assertEquals("s1", bar1.getDiffs().getLastSnapshot().getRoot() - .getLocalName()); + assertEquals(s1.getId(), bar1.getDiffs().getLastSnapshotId()); INodeReference barRef = fsdir.getINode4Write(bar2_dir1.toString()) .asReference(); @@ -772,8 +780,7 @@ public class TestRenameWithSnapshots { assertEquals(2, barWithCount.getReferenceCount()); INodeFile bar = barWithCount.asFile(); assertEquals(1, bar.getDiffs().asList().size()); - assertEquals("s1", bar.getDiffs().getLastSnapshot().getRoot() - .getLocalName()); + assertEquals(s1.getId(), bar.getDiffs().getLastSnapshotId()); // restart the cluster and check fsimage restartClusterAndCheckImage(true); @@ -967,6 +974,13 @@ public class TestRenameWithSnapshots { hdfs.rename(bar_dir2, bar_dir1); // check the internal details + INodeDirectorySnapshottable sdir1Node = + (INodeDirectorySnapshottable) fsdir.getINode(sdir1.toString()); + INodeDirectorySnapshottable sdir2Node = + (INodeDirectorySnapshottable) fsdir.getINode(sdir2.toString()); + INodeDirectorySnapshottable sdir3Node = + (INodeDirectorySnapshottable) fsdir.getINode(sdir3.toString()); + INodeReference fooRef = fsdir.getINode4Write(foo_dir1.toString()) .asReference(); INodeReference.WithCount fooWithCount = (WithCount) fooRef.getReferredINode(); @@ -975,16 +989,22 @@ public class TestRenameWithSnapshots { INodeDirectory foo = fooWithCount.asDirectory(); List<DirectoryDiff> fooDiffs = foo.getDiffs().asList(); assertEquals(4, fooDiffs.size()); - assertEquals("s2222", fooDiffs.get(3).snapshot.getRoot().getLocalName()); - assertEquals("s333", fooDiffs.get(2).snapshot.getRoot().getLocalName()); - assertEquals("s22", fooDiffs.get(1).snapshot.getRoot().getLocalName()); - assertEquals("s1", fooDiffs.get(0).snapshot.getRoot().getLocalName()); + + Snapshot s2222 = sdir2Node.getSnapshot(DFSUtil.string2Bytes("s2222")); + Snapshot s333 = sdir3Node.getSnapshot(DFSUtil.string2Bytes("s333")); + Snapshot s22 = sdir2Node.getSnapshot(DFSUtil.string2Bytes("s22")); + Snapshot s1 = sdir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); + + assertEquals(s2222.getId(), fooDiffs.get(3).getSnapshotId()); + assertEquals(s333.getId(), fooDiffs.get(2).getSnapshotId()); + assertEquals(s22.getId(), fooDiffs.get(1).getSnapshotId()); + assertEquals(s1.getId(), fooDiffs.get(0).getSnapshotId()); INodeFile bar1 = fsdir.getINode4Write(bar1_dir1.toString()).asFile(); List<FileDiff> bar1Diffs = bar1.getDiffs().asList(); assertEquals(3, bar1Diffs.size()); - assertEquals("s333", bar1Diffs.get(2).snapshot.getRoot().getLocalName()); - assertEquals("s22", bar1Diffs.get(1).snapshot.getRoot().getLocalName()); - assertEquals("s1", bar1Diffs.get(0).snapshot.getRoot().getLocalName()); + assertEquals(s333.getId(), bar1Diffs.get(2).getSnapshotId()); + assertEquals(s22.getId(), bar1Diffs.get(1).getSnapshotId()); + assertEquals(s1.getId(), bar1Diffs.get(0).getSnapshotId()); INodeReference barRef = fsdir.getINode4Write(bar_dir1.toString()) .asReference(); @@ -994,10 +1014,10 @@ public class TestRenameWithSnapshots { INodeFile bar = barWithCount.asFile(); List<FileDiff> barDiffs = bar.getDiffs().asList(); assertEquals(4, barDiffs.size()); - assertEquals("s2222", barDiffs.get(3).snapshot.getRoot().getLocalName()); - assertEquals("s333", barDiffs.get(2).snapshot.getRoot().getLocalName()); - assertEquals("s22", barDiffs.get(1).snapshot.getRoot().getLocalName()); - assertEquals("s1", barDiffs.get(0).snapshot.getRoot().getLocalName()); + assertEquals(s2222.getId(), barDiffs.get(3).getSnapshotId()); + assertEquals(s333.getId(), barDiffs.get(2).getSnapshotId()); + assertEquals(s22.getId(), barDiffs.get(1).getSnapshotId()); + assertEquals(s1.getId(), barDiffs.get(0).getSnapshotId()); // restart the cluster and check fsimage restartClusterAndCheckImage(true); @@ -1033,10 +1053,10 @@ public class TestRenameWithSnapshots { foo = fooWithCount.asDirectory(); fooDiffs = foo.getDiffs().asList(); assertEquals(4, fooDiffs.size()); - assertEquals("s2222", fooDiffs.get(3).snapshot.getRoot().getLocalName()); + assertEquals(s2222.getId(), fooDiffs.get(3).getSnapshotId()); bar1Diffs = bar1.getDiffs().asList(); assertEquals(3, bar1Diffs.size()); - assertEquals("s333", bar1Diffs.get(2).snapshot.getRoot().getLocalName()); + assertEquals(s333.getId(), bar1Diffs.get(2).getSnapshotId()); barRef = fsdir.getINode(bar_s2222.toString()).asReference(); barWithCount = (WithCount) barRef.getReferredINode(); @@ -1044,7 +1064,7 @@ public class TestRenameWithSnapshots { bar = barWithCount.asFile(); barDiffs = bar.getDiffs().asList(); assertEquals(4, barDiffs.size()); - assertEquals("s2222", barDiffs.get(3).snapshot.getRoot().getLocalName()); + assertEquals(s2222.getId(), barDiffs.get(3).getSnapshotId()); } /** @@ -1164,6 +1184,9 @@ public class TestRenameWithSnapshots { assertTrue(hdfs.exists(bar_s2)); // check internal details + INodeDirectorySnapshottable sdir2Node = + (INodeDirectorySnapshottable) fsdir.getINode(sdir2.toString()); + Snapshot s2 = sdir2Node.getSnapshot(DFSUtil.string2Bytes("s2")); final Path foo_s2 = SnapshotTestHelper.getSnapshotPath(sdir2, "s2", "foo"); INodeReference fooRef = fsdir.getINode(foo_s2.toString()).asReference(); assertTrue(fooRef instanceof INodeReference.WithName); @@ -1172,7 +1195,7 @@ public class TestRenameWithSnapshots { INodeDirectory fooDir = fooWC.getReferredINode().asDirectory(); List<DirectoryDiff> diffs = fooDir.getDiffs().asList(); assertEquals(1, diffs.size()); - assertEquals("s2", diffs.get(0).snapshot.getRoot().getLocalName()); + assertEquals(s2.getId(), diffs.get(0).getSnapshotId()); // restart the cluster and check fsimage restartClusterAndCheckImage(true); @@ -1260,7 +1283,7 @@ public class TestRenameWithSnapshots { INodeDirectory dir2 = fsdir.getINode4Write(sdir2.toString()).asDirectory(); INodeDirectory mockDir2 = spy(dir2); doReturn(false).when(mockDir2).addChild((INode) anyObject(), anyBoolean(), - (Snapshot) anyObject()); + Mockito.anyInt()); INodeDirectory root = fsdir.getINode4Write("/").asDirectory(); root.replaceChild(dir2, mockDir2, fsdir.getINodeMap()); @@ -1271,12 +1294,14 @@ public class TestRenameWithSnapshots { // check the current internal details INodeDirectorySnapshottable dir1Node = (INodeDirectorySnapshottable) fsdir .getINode4Write(sdir1.toString()); - ReadOnlyList<INode> dir1Children = dir1Node.getChildrenList(null); + Snapshot s1 = dir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); + ReadOnlyList<INode> dir1Children = dir1Node + .getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(1, dir1Children.size()); assertEquals(foo.getName(), dir1Children.get(0).getLocalName()); List<DirectoryDiff> dir1Diffs = dir1Node.getDiffs().asList(); assertEquals(1, dir1Diffs.size()); - assertEquals("s1", dir1Diffs.get(0).snapshot.getRoot().getLocalName()); + assertEquals(s1.getId(), dir1Diffs.get(0).getSnapshotId()); // after the undo of rename, both the created and deleted list of sdir1 // should be empty @@ -1288,7 +1313,7 @@ public class TestRenameWithSnapshots { assertTrue(fooNode.isDirectory() && fooNode.asDirectory().isWithSnapshot()); List<DirectoryDiff> fooDiffs = fooNode.asDirectory().getDiffs().asList(); assertEquals(1, fooDiffs.size()); - assertEquals("s1", fooDiffs.get(0).snapshot.getRoot().getLocalName()); + assertEquals(s1.getId(), fooDiffs.get(0).getSnapshotId()); final Path foo_s1 = SnapshotTestHelper.getSnapshotPath(sdir1, "s1", "foo"); INode fooNode_s1 = fsdir.getINode(foo_s1.toString()); @@ -1299,7 +1324,8 @@ public class TestRenameWithSnapshots { INodeDirectory dir2Node = fsdir.getINode4Write(sdir2.toString()) .asDirectory(); assertFalse(dir2Node.isWithSnapshot()); - ReadOnlyList<INode> dir2Children = dir2Node.getChildrenList(null); + ReadOnlyList<INode> dir2Children = dir2Node + .getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(1, dir2Children.size()); assertEquals(dir2file.getName(), dir2Children.get(0).getLocalName()); } @@ -1327,7 +1353,7 @@ public class TestRenameWithSnapshots { INodeDirectory dir2 = fsdir.getINode4Write(sdir2.toString()).asDirectory(); INodeDirectory mockDir2 = spy(dir2); doReturn(false).when(mockDir2).addChild((INode) anyObject(), anyBoolean(), - (Snapshot) anyObject()); + Mockito.anyInt()); INodeDirectory root = fsdir.getINode4Write("/").asDirectory(); root.replaceChild(dir2, mockDir2, fsdir.getINodeMap()); @@ -1338,12 +1364,14 @@ public class TestRenameWithSnapshots { // check the current internal details INodeDirectorySnapshottable dir1Node = (INodeDirectorySnapshottable) fsdir .getINode4Write(sdir1.toString()); - ReadOnlyList<INode> dir1Children = dir1Node.getChildrenList(null); + Snapshot s1 = dir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); + ReadOnlyList<INode> dir1Children = dir1Node + .getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(1, dir1Children.size()); assertEquals(foo.getName(), dir1Children.get(0).getLocalName()); List<DirectoryDiff> dir1Diffs = dir1Node.getDiffs().asList(); assertEquals(1, dir1Diffs.size()); - assertEquals("s1", dir1Diffs.get(0).snapshot.getRoot().getLocalName()); + assertEquals(s1.getId(), dir1Diffs.get(0).getSnapshotId()); // after the undo of rename, the created list of sdir1 should contain // 1 element @@ -1363,7 +1391,8 @@ public class TestRenameWithSnapshots { INodeDirectory dir2Node = fsdir.getINode4Write(sdir2.toString()) .asDirectory(); assertFalse(dir2Node.isWithSnapshot()); - ReadOnlyList<INode> dir2Children = dir2Node.getChildrenList(null); + ReadOnlyList<INode> dir2Children = dir2Node + .getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(1, dir2Children.size()); assertEquals(dir2file.getName(), dir2Children.get(0).getLocalName()); } @@ -1389,7 +1418,7 @@ public class TestRenameWithSnapshots { INodeDirectory dir3 = fsdir.getINode4Write(sdir3.toString()).asDirectory(); INodeDirectory mockDir3 = spy(dir3); doReturn(false).when(mockDir3).addChild((INode) anyObject(), anyBoolean(), - (Snapshot) anyObject()); + Mockito.anyInt()); INodeDirectory root = fsdir.getINode4Write("/").asDirectory(); root.replaceChild(dir3, mockDir3, fsdir.getINodeMap()); @@ -1400,13 +1429,18 @@ public class TestRenameWithSnapshots { assertFalse(result); // check the current internal details + INodeDirectorySnapshottable dir1Node = (INodeDirectorySnapshottable) fsdir + .getINode4Write(sdir1.toString()); + Snapshot s1 = dir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); INodeDirectorySnapshottable dir2Node = (INodeDirectorySnapshottable) fsdir .getINode4Write(sdir2.toString()); - ReadOnlyList<INode> dir2Children = dir2Node.getChildrenList(null); + Snapshot s2 = dir2Node.getSnapshot(DFSUtil.string2Bytes("s2")); + ReadOnlyList<INode> dir2Children = dir2Node + .getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(1, dir2Children.size()); List<DirectoryDiff> dir2Diffs = dir2Node.getDiffs().asList(); assertEquals(1, dir2Diffs.size()); - assertEquals("s2", Snapshot.getSnapshotName(dir2Diffs.get(0).snapshot)); + assertEquals(s2.getId(), dir2Diffs.get(0).getSnapshotId()); ChildrenDiff childrenDiff = dir2Diffs.get(0).getChildrenDiff(); assertEquals(0, childrenDiff.getList(ListType.DELETED).size()); assertEquals(1, childrenDiff.getList(ListType.CREATED).size()); @@ -1418,7 +1452,7 @@ public class TestRenameWithSnapshots { assertTrue(fooNode instanceof INodeReference.DstReference); List<DirectoryDiff> fooDiffs = fooNode.asDirectory().getDiffs().asList(); assertEquals(1, fooDiffs.size()); - assertEquals("s1", fooDiffs.get(0).snapshot.getRoot().getLocalName()); + assertEquals(s1.getId(), fooDiffs.get(0).getSnapshotId()); // create snapshot on sdir2 and rename again hdfs.createSnapshot(sdir2, "s3"); @@ -1428,13 +1462,14 @@ public class TestRenameWithSnapshots { // check internal details again dir2Node = (INodeDirectorySnapshottable) fsdir.getINode4Write(sdir2 .toString()); + Snapshot s3 = dir2Node.getSnapshot(DFSUtil.string2Bytes("s3")); fooNode = fsdir.getINode4Write(foo_dir2.toString()); - dir2Children = dir2Node.getChildrenList(null); + dir2Children = dir2Node.getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(1, dir2Children.size()); dir2Diffs = dir2Node.getDiffs().asList(); assertEquals(2, dir2Diffs.size()); - assertEquals("s2", Snapshot.getSnapshotName(dir2Diffs.get(0).snapshot)); - assertEquals("s3", Snapshot.getSnapshotName(dir2Diffs.get(1).snapshot)); + assertEquals(s2.getId(), dir2Diffs.get(0).getSnapshotId()); + assertEquals(s3.getId(), dir2Diffs.get(1).getSnapshotId()); childrenDiff = dir2Diffs.get(0).getChildrenDiff(); assertEquals(0, childrenDiff.getList(ListType.DELETED).size()); @@ -1452,8 +1487,8 @@ public class TestRenameWithSnapshots { assertTrue(fooNode instanceof INodeReference.DstReference); fooDiffs = fooNode.asDirectory().getDiffs().asList(); assertEquals(2, fooDiffs.size()); - assertEquals("s1", fooDiffs.get(0).snapshot.getRoot().getLocalName()); - assertEquals("s3", fooDiffs.get(1).snapshot.getRoot().getLocalName()); + assertEquals(s1.getId(), fooDiffs.get(0).getSnapshotId()); + assertEquals(s3.getId(), fooDiffs.get(1).getSnapshotId()); } /** @@ -1489,9 +1524,9 @@ public class TestRenameWithSnapshots { INodeDirectory mockDir3 = spy(dir3); // fail the rename but succeed in undo doReturn(false).when(mockDir3).addChild((INode) Mockito.isNull(), - anyBoolean(), (Snapshot) anyObject()); + anyBoolean(), Mockito.anyInt()); Mockito.when(mockDir3.addChild((INode) Mockito.isNotNull(), anyBoolean(), - (Snapshot) anyObject())).thenReturn(false).thenCallRealMethod(); + Mockito.anyInt())).thenReturn(false).thenCallRealMethod(); INodeDirectory root = fsdir.getINode4Write("/").asDirectory(); root.replaceChild(dir3, mockDir3, fsdir.getINodeMap()); foo3Node.setParent(mockDir3); @@ -1551,7 +1586,7 @@ public class TestRenameWithSnapshots { INodeDirectory dir1Node = fsdir.getINode4Write(dir1.toString()) .asDirectory(); List<INode> childrenList = ReadOnlyList.Util.asList(dir1Node - .getChildrenList(null)); + .getChildrenList(Snapshot.CURRENT_STATE_ID)); assertEquals(1, childrenList.size()); INode fooNode = childrenList.get(0); assertTrue(fooNode.asDirectory().isWithSnapshot()); @@ -1572,7 +1607,7 @@ public class TestRenameWithSnapshots { assertEquals(3, counts.get(Quota.NAMESPACE)); assertEquals(0, counts.get(Quota.DISKSPACE)); childrenList = ReadOnlyList.Util.asList(dir2Node.asDirectory() - .getChildrenList(null)); + .getChildrenList(Snapshot.CURRENT_STATE_ID)); assertEquals(1, childrenList.size()); INode subdir2Node = childrenList.get(0); assertSame(dir2Node, subdir2Node.getParent()); @@ -1627,7 +1662,7 @@ public class TestRenameWithSnapshots { INodeDirectory dir1Node = fsdir.getINode4Write(dir1.toString()) .asDirectory(); List<INode> childrenList = ReadOnlyList.Util.asList(dir1Node - .getChildrenList(null)); + .getChildrenList(Snapshot.CURRENT_STATE_ID)); assertEquals(1, childrenList.size()); INode fooNode = childrenList.get(0); assertTrue(fooNode.asDirectory().isWithSnapshot()); @@ -1646,7 +1681,7 @@ public class TestRenameWithSnapshots { assertEquals(4, counts.get(Quota.NAMESPACE)); assertEquals(0, counts.get(Quota.DISKSPACE)); childrenList = ReadOnlyList.Util.asList(dir2Node.asDirectory() - .getChildrenList(null)); + .getChildrenList(Snapshot.CURRENT_STATE_ID)); assertEquals(1, childrenList.size()); INode subdir2Node = childrenList.get(0); assertTrue(subdir2Node.asDirectory().isWithSnapshot()); @@ -1690,14 +1725,18 @@ public class TestRenameWithSnapshots { } // check + INodeDirectorySnapshottable rootNode = (INodeDirectorySnapshottable) fsdir + .getINode4Write(root.toString()); INodeDirectory fooNode = fsdir.getINode4Write(foo.toString()).asDirectory(); - ReadOnlyList<INode> children = fooNode.getChildrenList(null); + ReadOnlyList<INode> children = fooNode + .getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(1, children.size()); List<DirectoryDiff> diffList = fooNode.getDiffs().asList(); assertEquals(1, diffList.size()); DirectoryDiff diff = diffList.get(0); // this diff is generated while renaming - assertEquals(snap1, Snapshot.getSnapshotName(diff.snapshot)); + Snapshot s1 = rootNode.getSnapshot(DFSUtil.string2Bytes(snap1)); + assertEquals(s1.getId(), diff.getSnapshotId()); // after undo, the diff should be empty assertTrue(diff.getChildrenDiff().getList(ListType.DELETED).isEmpty()); assertTrue(diff.getChildrenDiff().getList(ListType.CREATED).isEmpty()); @@ -1709,7 +1748,7 @@ public class TestRenameWithSnapshots { List<FileDiff> barDiffList = barNode.getDiffs().asList(); assertEquals(1, barDiffList.size()); FileDiff barDiff = barDiffList.get(0); - assertEquals(snap1, Snapshot.getSnapshotName(barDiff.snapshot)); + assertEquals(s1.getId(), barDiff.getSnapshotId()); // restart cluster multiple times to make sure the fsimage and edits log are // correct. Note that when loading fsimage, foo and bar will be converted @@ -1941,12 +1980,14 @@ public class TestRenameWithSnapshots { (WithCount) fooRef.asReference().getReferredINode(); assertEquals(1, wc.getReferenceCount()); INodeDirectory fooNode = wc.getReferredINode().asDirectory(); - ReadOnlyList<INode> children = fooNode.getChildrenList(null); + ReadOnlyList<INode> children = fooNode + .getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(1, children.size()); assertEquals(bar.getName(), children.get(0).getLocalName()); List<DirectoryDiff> diffList = fooNode.getDiffs().asList(); assertEquals(1, diffList.size()); - assertEquals("s1", Snapshot.getSnapshotName(diffList.get(0).snapshot)); + Snapshot s1 = dir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); + assertEquals(s1.getId(), diffList.get(0).getSnapshotId()); ChildrenDiff diff = diffList.get(0).getChildrenDiff(); assertEquals(0, diff.getList(ListType.CREATED).size()); assertEquals(0, diff.getList(ListType.DELETED).size()); @@ -2009,14 +2050,16 @@ public class TestRenameWithSnapshots { (WithCount) fooRef.asReference().getReferredINode(); assertEquals(2, wc.getReferenceCount()); INodeDirectory fooNode = wc.getReferredINode().asDirectory(); - ReadOnlyList<INode> children = fooNode.getChildrenList(null); + ReadOnlyList<INode> children = fooNode + .getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(3, children.size()); assertEquals(bar.getName(), children.get(0).getLocalName()); assertEquals(bar2.getName(), children.get(1).getLocalName()); assertEquals(bar3.getName(), children.get(2).getLocalName()); List<DirectoryDiff> diffList = fooNode.getDiffs().asList(); assertEquals(1, diffList.size()); - assertEquals("s1", Snapshot.getSnapshotName(diffList.get(0).snapshot)); + Snapshot s1 = dir1Node.getSnapshot(DFSUtil.string2Bytes("s1")); + assertEquals(s1.getId(), diffList.get(0).getSnapshotId()); ChildrenDiff diff = diffList.get(0).getChildrenDiff(); // bar2 and bar3 in the created list assertEquals(2, diff.getList(ListType.CREATED).size()); @@ -2134,11 +2177,12 @@ public class TestRenameWithSnapshots { // recordModification before the rename assertTrue(fooNode.isWithSnapshot()); assertTrue(fooNode.getDiffs().asList().isEmpty()); - INodeDirectory barNode = fooNode.getChildrenList(null).get(0).asDirectory(); + INodeDirectory barNode = fooNode.getChildrenList(Snapshot.CURRENT_STATE_ID) + .get(0).asDirectory(); // bar should also be INodeDirectory (With Snapshot), and both of its diff // list and children list are empty assertTrue(barNode.getDiffs().asList().isEmpty()); - assertTrue(barNode.getChildrenList(null).isEmpty()); + assertTrue(barNode.getChildrenList(Snapshot.CURRENT_STATE_ID).isEmpty()); restartClusterAndCheckImage(true); } @@ -2210,7 +2254,10 @@ public class TestRenameWithSnapshots { List<DirectoryDiff> barDiffList = barNode.getDiffs().asList(); assertEquals(1, barDiffList.size()); DirectoryDiff diff = barDiffList.get(0); - assertEquals("s0", Snapshot.getSnapshotName(diff.snapshot)); + INodeDirectorySnapshottable testNode = + (INodeDirectorySnapshottable) fsdir.getINode4Write(test.toString()); + Snapshot s0 = testNode.getSnapshot(DFSUtil.string2Bytes("s0")); + assertEquals(s0.getId(), diff.getSnapshotId()); // and file should be stored in the deleted list of this snapshot diff assertEquals("file", diff.getChildrenDiff().getList(ListType.DELETED) .get(0).getLocalName()); @@ -2276,7 +2323,7 @@ public class TestRenameWithSnapshots { final Path barInS0 = SnapshotTestHelper.getSnapshotPath(test, "s0", "foo/bar"); INodeDirectory barNode = fsdir.getINode(barInS0.toString()).asDirectory(); - assertEquals(0, barNode.getChildrenList(null).size()); + assertEquals(0, barNode.getChildrenList(Snapshot.CURRENT_STATE_ID).size()); List<DirectoryDiff> diffList = barNode.getDiffs().asList(); assertEquals(1, diffList.size()); DirectoryDiff diff = diffList.get(0); Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSetQuotaWithSnapshot.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSetQuotaWithSnapshot.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSetQuotaWithSnapshot.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSetQuotaWithSnapshot.java Tue Jan 7 20:52:48 2014 @@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configurat import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.DFSTestUtil; +import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.protocol.HdfsConstants; @@ -153,7 +154,9 @@ public class TestSetQuotaWithSnapshot { assertTrue(subNode.asDirectory().isWithSnapshot()); List<DirectoryDiff> diffList = subNode.asDirectory().getDiffs().asList(); assertEquals(1, diffList.size()); - assertEquals("s2", Snapshot.getSnapshotName(diffList.get(0).snapshot)); + Snapshot s2 = ((INodeDirectorySnapshottable) dirNode).getSnapshot(DFSUtil + .string2Bytes("s2")); + assertEquals(s2.getId(), diffList.get(0).getSnapshotId()); List<INode> createdList = diffList.get(0).getChildrenDiff().getList(ListType.CREATED); assertEquals(1, createdList.size()); assertSame(fsdir.getINode4Write(file.toString()), createdList.get(0)); Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDeletion.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDeletion.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDeletion.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDeletion.java Tue Jan 7 20:52:48 2014 @@ -268,7 +268,8 @@ public class TestSnapshotDeletion { (INodeDirectory) fsdir.getINode(snapshotNoChangeDir.toString()); // should still be an INodeDirectory assertEquals(INodeDirectory.class, snapshotNode.getClass()); - ReadOnlyList<INode> children = snapshotNode.getChildrenList(null); + ReadOnlyList<INode> children = snapshotNode + .getChildrenList(Snapshot.CURRENT_STATE_ID); // check 2 children: noChangeFile and metaChangeFile2 assertEquals(2, children.size()); INode noChangeFileSCopy = children.get(1); @@ -286,11 +287,11 @@ public class TestSnapshotDeletion { // check the replication factor of metaChangeFile2SCopy assertEquals(REPLICATION_1, - metaChangeFile2SCopy.getFileReplication(null)); + metaChangeFile2SCopy.getFileReplication(Snapshot.CURRENT_STATE_ID)); assertEquals(REPLICATION_1, - metaChangeFile2SCopy.getFileReplication(snapshot1)); + metaChangeFile2SCopy.getFileReplication(snapshot1.getId())); assertEquals(REPLICATION, - metaChangeFile2SCopy.getFileReplication(snapshot0)); + metaChangeFile2SCopy.getFileReplication(snapshot0.getId())); // Case 4: delete directory sub // before deleting sub, we first create a new file under sub @@ -316,23 +317,25 @@ public class TestSnapshotDeletion { assertTrue(snapshotNode4Sub.isWithSnapshot()); // the snapshot copy of sub has only one child subsub. // newFile should have been destroyed - assertEquals(1, snapshotNode4Sub.getChildrenList(null).size()); + assertEquals(1, snapshotNode4Sub.getChildrenList(Snapshot.CURRENT_STATE_ID) + .size()); // but should have two children, subsub and noChangeDir, when s1 was taken - assertEquals(2, snapshotNode4Sub.getChildrenList(snapshot1).size()); + assertEquals(2, snapshotNode4Sub.getChildrenList(snapshot1.getId()).size()); // check the snapshot copy of subsub, which is contained in the subtree of // sub's snapshot copy - INode snapshotNode4Subsub = snapshotNode4Sub.getChildrenList(null).get(0); + INode snapshotNode4Subsub = snapshotNode4Sub.getChildrenList( + Snapshot.CURRENT_STATE_ID).get(0); assertTrue(snapshotNode4Subsub.asDirectory().isWithSnapshot()); assertTrue(snapshotNode4Sub == snapshotNode4Subsub.getParent()); // check the children of subsub INodeDirectory snapshotSubsubDir = (INodeDirectory) snapshotNode4Subsub; - children = snapshotSubsubDir.getChildrenList(null); + children = snapshotSubsubDir.getChildrenList(Snapshot.CURRENT_STATE_ID); assertEquals(2, children.size()); assertEquals(children.get(0).getLocalName(), metaChangeFile1.getName()); assertEquals(children.get(1).getLocalName(), newFileAfterS0.getName()); // only one child before snapshot s0 - children = snapshotSubsubDir.getChildrenList(snapshot0); + children = snapshotSubsubDir.getChildrenList(snapshot0.getId()); assertEquals(1, children.size()); INode child = children.get(0); assertEquals(child.getLocalName(), metaChangeFile1.getName()); @@ -341,11 +344,11 @@ public class TestSnapshotDeletion { assertTrue(metaChangeFile1SCopy.isWithSnapshot()); assertFalse(metaChangeFile1SCopy.isUnderConstruction()); assertEquals(REPLICATION_1, - metaChangeFile1SCopy.getFileReplication(null)); + metaChangeFile1SCopy.getFileReplication(Snapshot.CURRENT_STATE_ID)); assertEquals(REPLICATION_1, - metaChangeFile1SCopy.getFileReplication(snapshot1)); + metaChangeFile1SCopy.getFileReplication(snapshot1.getId())); assertEquals(REPLICATION, - metaChangeFile1SCopy.getFileReplication(snapshot0)); + metaChangeFile1SCopy.getFileReplication(snapshot0.getId())); } /** @@ -474,9 +477,10 @@ public class TestSnapshotDeletion { (INodeDirectorySnapshottable) fsdir.getINode(dir.toString()); Snapshot snapshot0 = dirNode.getSnapshot(DFSUtil.string2Bytes("s0")); assertNull(snapshot0); + Snapshot snapshot1 = dirNode.getSnapshot(DFSUtil.string2Bytes("s1")); DirectoryDiffList diffList = dirNode.getDiffs(); assertEquals(1, diffList.asList().size()); - assertEquals("s1", diffList.getLast().snapshot.getRoot().getLocalName()); + assertEquals(snapshot1.getId(), diffList.getLast().getSnapshotId()); diffList = fsdir.getINode(metaChangeDir.toString()).asDirectory() .getDiffs(); assertEquals(0, diffList.asList().size()); Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotRename.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotRename.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotRename.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotRename.java Tue Jan 7 20:52:48 2014 @@ -101,7 +101,8 @@ public class TestSnapshotRename { List<DirectoryDiff> listByTime = srcRoot.getDiffs().asList(); assertEquals(names.length, listByTime.size()); for (int i = 0; i < listByTime.size(); i++) { - assertEquals(names[i], listByTime.get(i).getSnapshot().getRoot().getLocalName()); + Snapshot s = srcRoot.getSnapshotById(listByTime.get(i).getSnapshotId()); + assertEquals(names[i], s.getRoot().getLocalName()); } } Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotReplication.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotReplication.java?rev=1556353&r1=1556352&r2=1556353&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotReplication.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotReplication.java Tue Jan 7 20:52:48 2014 @@ -150,7 +150,7 @@ public class TestSnapshotReplication { assertEquals(expectedBlockRep, ssInode.getBlockReplication()); // Also check the number derived from INodeFile#getFileReplication assertEquals(snapshotRepMap.get(ss).shortValue(), - ssInode.getFileReplication(iip.getPathSnapshot())); + ssInode.getFileReplication(iip.getPathSnapshotId())); } }