abhishekdas99 commented on a change in pull request #2260:
URL: https://github.com/apache/hadoop/pull/2260#discussion_r644310313



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
##########
@@ -284,7 +288,20 @@ boolean isInternalDir() {
       return false;
     }
 
-    public T getTargetFileSystem() {
+    /**
+     * Gets lazily loaded instance of FileSystem

Review comment:
       added . at the end of the line

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
##########
@@ -284,7 +288,20 @@ boolean isInternalDir() {
       return false;
     }
 
-    public T getTargetFileSystem() {
+    /**
+     * Gets lazily loaded instance of FileSystem
+     * @return An Initialized instance of T
+     * @throws IOException
+     */
+    public T getTargetFileSystem() throws IOException {
+      if (targetFileSystem != null)
+        return targetFileSystem;

Review comment:
       Done

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
##########
@@ -284,7 +288,20 @@ boolean isInternalDir() {
       return false;
     }
 
-    public T getTargetFileSystem() {
+    /**
+     * Gets lazily loaded instance of FileSystem
+     * @return An Initialized instance of T
+     * @throws IOException
+     */
+    public T getTargetFileSystem() throws IOException {
+      if (targetFileSystem != null)
+        return targetFileSystem;
+
+      if (targetDirLinkList.length == 1) {
+        synchronized (this) {
+          targetFileSystem = fileSystemInitFunc.apply(targetDirLinkList[0]);

Review comment:
       Added extra check

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -855,7 +861,11 @@ public void setVerifyChecksum(final boolean 
verifyChecksum) {
     List<InodeTree.MountPoint<FileSystem>> mountPoints = 
         fsState.getMountPoints();
     for (InodeTree.MountPoint<FileSystem> mount : mountPoints) {
-      mount.target.targetFileSystem.setVerifyChecksum(verifyChecksum);
+      try {
+        mount.target.getTargetFileSystem().setVerifyChecksum(verifyChecksum);
+      } catch (IOException ex) {
+        LOG.error("Could not set verifyChecksum for source path " + mount.src);
+      }

Review comment:
       Changed the code.

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -936,8 +956,13 @@ public void setWriteChecksum(final boolean writeChecksum) {
         fsState.getMountPoints();
     Set<FileSystem> children = new HashSet<FileSystem>();
     for (InodeTree.MountPoint<FileSystem> mountPoint : mountPoints) {
-      FileSystem targetFs = mountPoint.target.targetFileSystem;
-      children.addAll(Arrays.asList(targetFs.getChildFileSystems()));
+      try {
+        FileSystem targetFs = mountPoint.target.getTargetFileSystem();
+        children.addAll(Arrays.asList(targetFs.getChildFileSystems()));
+      } catch (IOException ex) {
+        LOG.error("Could not add child filesystems "
+            + "for source path " + mountPoint.src);

Review comment:
       Changed the code.

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
##########
@@ -37,6 +37,7 @@
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.UnsupportedFileSystemException;
+import org.apache.hadoop.fs.impl.FunctionsRaisingIOE.FunctionRaisingIOE;

Review comment:
       replaced 
`org.apache.hadoop.fs.impl.FunctionsRaisingIOE.FunctionRaisingIOE` with 
`org.apache.hadoop.util.functional.FunctionRaisingIOE`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to