Bläddra i källkod

HDFS-11648. Lazy construct the IIP pathname. Contributed by Daryn Sharp.

(cherry picked from commit 8ed230c805625549b1cecc830e909a7027bb4961)
(cherry picked from commit 9dfe0b35158cc0046a82cbfea2218a4ad61f329e)
Kihwal Lee 8 år sedan
förälder
incheckning
1903665b23

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

@@ -99,6 +99,9 @@ Release 2.7.4 - UNRELEASED
 
     HDFS-10619. Cache path in InodesInPath. (daryn via kihwal, backported by zhz)
 
+    HDFS-11648. Lazy construct the IIP pathname.
+    (daryn via kihwal, backported by zhz)
+
   OPTIMIZATIONS
 
     HDFS-10896. Move lock logging logic from FSNamesystem into FSNamesystemLock.

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

@@ -270,7 +270,7 @@ public class INodesInPath {
   }
 
   private final byte[][] path;
-  private final String pathname;
+  private volatile String pathname;
 
   /**
    * Array with the specified number of INodes resolved for a given path.
@@ -293,7 +293,6 @@ public class INodesInPath {
     Preconditions.checkArgument(inodes != null && path != null);
     this.inodes = inodes;
     this.path = path;
-    this.pathname = DFSUtil.byteArray2PathString(path);
     this.isSnapshot = isSnapshot;
     this.snapshotId = snapshotId;
   }
@@ -349,6 +348,9 @@ public class INodesInPath {
 
   /** @return the full path in string form */
   public String getPath() {
+    if (pathname == null) {
+      pathname = DFSUtil.byteArray2PathString(path);
+    }
     return pathname;
   }