Explorar o código

HDFS-4726. Fix test failures after merging the INodeId-INode mapping from trunk. Contributed by Jing Zhao

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2802@1470735 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze %!s(int64=12) %!d(string=hai) anos
pai
achega
43bdc22e92

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-2802.txt

@@ -260,3 +260,6 @@ Branch-2802 Snapshot (Unreleased)
   HdfsAdmin from String to Path.  (szetszwo)
 
   HDFS-4708. Add snapshot user documentation.  (szetszwo)
+
+  HDFS-4726. Fix test failures after merging the INodeId-INode mapping 
+  from trunk.  (Jing Zhao via szetszwo)

+ 2 - 4
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java

@@ -474,10 +474,7 @@ public class INodeDirectory extends INodeWithAdditionalFields {
 
   /** Set the children list to null. */
   public void clearChildren() {
-    if (children != null) {
-      this.children.clear();
-      this.children = null;
-    }
+    this.children = null;
   }
 
   @Override
@@ -514,6 +511,7 @@ public class INodeDirectory extends INodeWithAdditionalFields {
     for (INode child : getChildrenList(null)) {
       child.destroyAndCollectBlocks(collectedBlocks);
     }
+    // TODO: Need to update the cleanSubtree/destroy methods to clean inode map
     clear();
   }
   

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/INodeDirectoryWithSnapshot.java

@@ -185,7 +185,7 @@ public class INodeDirectoryWithSnapshot extends INodeDirectoryWithQuota {
       for (; c < created.size() && d < deleted.size(); ) {
         INode cnode = created.get(c);
         INode dnode = deleted.get(d);
-        if (cnode.equals(dnode)) {
+        if (cnode.compareTo(dnode.getLocalNameBytes()) == 0) {
           fullPath[fullPath.length - 1] = cnode.getLocalNameBytes();
           if (cnode.isSymlink() && dnode.isSymlink()) {
             dList.add(new DiffReportEntry(DiffType.MODIFY, fullPath));

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/util/Diff.java

@@ -261,7 +261,7 @@ public class Diff<K, E extends Diff.Element<K>> {
   public UndoInfo<E> modify(final E oldElement, final E newElement) {
     Preconditions.checkArgument(oldElement != newElement,
         "They are the same object: oldElement == newElement = %s", newElement);
-    Preconditions.checkArgument(oldElement.equals(newElement),
+    Preconditions.checkArgument(oldElement.compareTo(newElement.getKey()) == 0,
         "The names do not match: oldElement=%s, newElement=%s",
         oldElement, newElement);
     final int c = search(created, newElement.getKey());

+ 6 - 2
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java

@@ -200,10 +200,14 @@ public class TestINodeFile {
       // Check the full path name of the INode associating with the file
       INode fnode = fsdir.getINode(file.toString());
       assertEquals(file.toString(), fnode.getFullPathName());
-
+      
       // Call FSDirectory#unprotectedSetQuota which calls
       // INodeDirectory#replaceChild
       dfs.setQuota(dir, Long.MAX_VALUE - 1, replication * fileLen * 10);
+      INode dirNode = fsdir.getINode(dir.toString());
+      assertEquals(dir.toString(), dirNode.getFullPathName());
+      assertTrue(dirNode instanceof INodeDirectoryWithQuota);
+      
       final Path newDir = new Path("/newdir");
       final Path newFile = new Path(newDir, "file");
       // Also rename dir
@@ -771,7 +775,7 @@ public class TestINodeFile {
     PermissionStatus permstatus = PermissionStatus.createImmutable("", "", perm);
     
     long id = 0;
-    INodeDirectory prev = new INodeDirectory(++id, null, permstatus, 0);
+    INodeDirectory prev = new INodeDirectory(++id, new byte[0], permstatus, 0);
     INodeDirectory dir = null;
     for (byte[] component : components) {
       if (component.length == 0) {

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java

@@ -192,7 +192,7 @@ public class TestRenameWithSnapshots {
    * Rename a file under a snapshottable directory, file exists
    * in a snapshot.
    */
-  @Test (timeout=60000)
+  @Test
   public void testRenameFileInSnapshot() throws Exception {
     hdfs.mkdirs(sub1);
     hdfs.allowSnapshot(sub1);