[ 
https://issues.apache.org/jira/browse/HADOOP-17028?focusedWorklogId=479133&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-479133
 ]

ASF GitHub Bot logged work on HADOOP-17028:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Sep/20 14:27
            Start Date: 04/Sep/20 14:27
    Worklog Time Spent: 10m 
      Work Description: steveloughran commented on a change in pull request 
#2260:
URL: https://github.com/apache/hadoop/pull/2260#discussion_r483645622



##########
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:
       nit: add a . to keep javadoc happy

##########
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:
       nit, curly { }

##########
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:
       this will dual init as thread #2 will block. You need another check 
inside the sync block so the second thread won't repeat itself

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
##########
@@ -893,6 +906,9 @@ public short getDefaultReplication(Path f) {
       return res.targetFileSystem.getDefaultReplication(res.remainingPath);
     } catch (FileNotFoundException e) {
       throw new NotInMountpointException(f, "getDefaultReplication"); 
+    } catch (IOException e) {
+      throw new RuntimeException("Not able to initialize fs in "

Review comment:
       FYI. I've got a WrappedIOException, but in #2069 making it a public 
`org.apache.hadoop.fs.functional.RuntimeIOException` whose cause is only ever 
IOE. Not something to be picked up here (yet), but worth knowing. I'm trying to 
make the functional & lambda/expression stuff more useable, 

##########
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:
       log the full stack trace

##########
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:
       +full exception log




----------------------------------------------------------------
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 479133)
    Time Spent: 1h 50m  (was: 1h 40m)

> ViewFS should initialize target filesystems lazily
> --------------------------------------------------
>
>                 Key: HADOOP-17028
>                 URL: https://issues.apache.org/jira/browse/HADOOP-17028
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: client-mounts, fs, viewfs
>    Affects Versions: 3.2.1
>            Reporter: Uma Maheswara Rao G
>            Assignee: Abhishek Das
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> Currently viewFS initialize all configured target filesystems when 
> viewfs#init itself.
> Some target file system initialization involve creating heavy objects and 
> proxy connections. Ex: DistributedFileSystem#initialize will create DFSClient 
> object which will create proxy connections to NN etc.
> For example: if ViewFS configured with 10 target fs with hdfs uri and 2 
> targets with s3a.
> If one of the client only work with s3a target, But ViewFS will initialize 
> all targets irrespective of what clients interested to work with. That means, 
> here client will create 10 DFS initializations and 2 s3a initializations. Its 
> unnecessary to have DFS initialization here. So, it will be a good idea to 
> initialize the target fs only when first time usage call come to particular 
> target fs scheme. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to