You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by li...@apache.org on 2020/04/22 23:30:53 UTC
[hadoop] branch branch-2.10 updated: HDFS-15276. Concat on
INodeRefernce fails with illegal state exception. Contributed by
hemanthboyina
This is an automated email from the ASF dual-hosted git repository.
liuml07 pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-2.10 by this push:
new 4ebe784 HDFS-15276. Concat on INodeRefernce fails with illegal state exception. Contributed by hemanthboyina
4ebe784 is described below
commit 4ebe78496f8f28dc40fb232eb5c55ca68e9a178a
Author: Mingliang Liu <li...@apache.org>
AuthorDate: Wed Apr 22 13:31:02 2020 -0700
HDFS-15276. Concat on INodeRefernce fails with illegal state exception. Contributed by hemanthboyina
---
.../hdfs/server/namenode/INodeDirectory.java | 2 +-
.../hdfs/server/namenode/TestFileTruncate.java | 34 ++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java
index a42cd44..b987423 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java
@@ -510,7 +510,7 @@ public class INodeDirectory extends INodeWithAdditionalFields
}
final INode removed = children.remove(i);
- Preconditions.checkState(removed == child);
+ Preconditions.checkState(removed.equals(child));
return true;
}
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java
index 9e963cf..136607b 100755
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java
@@ -1281,4 +1281,38 @@ public class TestFileTruncate {
cluster.waitActive();
}
}
+
+ /**
+ * Test concat on file which is a reference.
+ */
+ @Test
+ public void testConcatOnInodeRefernce() throws IOException {
+ String dir = "/testConcat";
+ Path trgDir = new Path(dir);
+ fs.mkdirs(new Path(dir), FsPermission.getDirDefault());
+
+ // Create a target file
+ Path trg = new Path(dir, "file");
+ DFSTestUtil.createFile(fs, trg, 512, (short) 2, 0);
+
+ String dir2 = "/dir2";
+ Path srcDir = new Path(dir2);
+ // create a source file
+ fs.mkdirs(srcDir);
+ fs.allowSnapshot(srcDir);
+ Path src = new Path(srcDir, "file1");
+ DFSTestUtil.createFile(fs, src, 512, (short) 2, 0);
+
+ // make the file as an Inode reference and delete the reference
+ fs.createSnapshot(srcDir, "s1");
+ fs.rename(src, trgDir);
+ fs.deleteSnapshot(srcDir, "s1");
+ Path[] srcs = new Path[1];
+ srcs[0] = new Path(dir, "file1");
+ assertEquals(2, fs.getContentSummary(new Path(dir)).getFileCount());
+
+ // perform concat
+ fs.concat(trg, srcs);
+ assertEquals(1, fs.getContentSummary(new Path(dir)).getFileCount());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org