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 we...@apache.org on 2019/10/04 15:53:06 UTC
[hadoop] branch branch-3.2 updated: HDFS-13693. Remove unnecessary
search in INodeDirectory.addChild during image loading. Contributed by
Lisheng Sun.
This is an automated email from the ASF dual-hosted git repository.
weichiu pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.2 by this push:
new 7025724 HDFS-13693. Remove unnecessary search in INodeDirectory.addChild during image loading. Contributed by Lisheng Sun.
7025724 is described below
commit 702572434c92aa34d70837f8757b8974e04c9da9
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Tue Jul 23 08:37:55 2019 +0530
HDFS-13693. Remove unnecessary search in INodeDirectory.addChild during image loading. Contributed by Lisheng Sun.
(cherry picked from commit 377f95bbe8d2d171b5d7b0bfa7559e67ca4aae46)
---
.../hdfs/server/namenode/FSImageFormatPBINode.java | 4 +++-
.../hadoop/hdfs/server/namenode/INodeDirectory.java | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java
index bc455e0..6825a5c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java
@@ -269,7 +269,7 @@ public final class FSImageFormatPBINode {
+ "name before upgrading to this release.");
}
// NOTE: This does not update space counts for parents
- if (!parent.addChild(child)) {
+ if (!parent.addChildAtLoading(child)) {
return;
}
dir.cacheName(child);
@@ -551,6 +551,8 @@ public final class FSImageFormatPBINode {
++numImageErrors;
}
if (!inode.isReference()) {
+ // Serialization must ensure that children are in order, related
+ // to HDFS-13693
b.addChildren(inode.getId());
} else {
refList.add(inode.asReference());
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 8fa9bcf..e71cb0a 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
@@ -573,6 +573,22 @@ public class INodeDirectory extends INodeWithAdditionalFields
}
/**
+ * During image loading, the search is unnecessary since the insert position
+ * should always be at the end of the map given the sequence they are
+ * serialized on disk.
+ */
+ public boolean addChildAtLoading(INode node) {
+ int pos;
+ if (!node.isReference()) {
+ pos = (children == null) ? (-1) : (-children.size() - 1);
+ addChild(node, pos);
+ return true;
+ } else {
+ return addChild(node);
+ }
+ }
+
+ /**
* Add the node to the children list at the given insertion point.
* The basic add method which actually calls children.add(..).
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org