From d8313b227495d748abe8884eee34db507476cee1 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Sat, 28 Sep 2019 17:20:44 -0700 Subject: [PATCH] HDFS-14850. Optimize FileSystemAccessService#getFileSystemConfiguration. Contributed by Lisheng Sun. --- .../hadoop/FileSystemAccessService.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java index 61d3b4505fe..b2bba088911 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java @@ -136,6 +136,7 @@ public class FileSystemAccessService extends BaseService implements FileSystemAc private Collection nameNodeWhitelist; Configuration serviceHadoopConf; + private Configuration fileSystemConf; private AtomicInteger unmanagedFileSystems = new AtomicInteger(); @@ -188,6 +189,7 @@ public class FileSystemAccessService extends BaseService implements FileSystemAc } try { serviceHadoopConf = loadHadoopConf(hadoopConfDir); + fileSystemConf = getNewFileSystemConfiguration(); } catch (IOException ex) { throw new ServiceException(FileSystemAccessException.ERROR.H11, ex.toString(), ex); } @@ -212,6 +214,16 @@ public class FileSystemAccessService extends BaseService implements FileSystemAc return hadoopConf; } + private Configuration getNewFileSystemConfiguration() { + Configuration conf = new Configuration(true); + ConfigurationUtils.copy(serviceHadoopConf, conf); + conf.setBoolean(FILE_SYSTEM_SERVICE_CREATED, true); + + // Force-clear server-side umask to make HttpFS match WebHDFS behavior + conf.set(FsPermission.UMASK_LABEL, "000"); + return conf; + } + @Override public void postInit() throws ServiceException { super.postInit(); @@ -397,14 +409,7 @@ public class FileSystemAccessService extends BaseService implements FileSystemAc @Override public Configuration getFileSystemConfiguration() { - Configuration conf = new Configuration(true); - ConfigurationUtils.copy(serviceHadoopConf, conf); - conf.setBoolean(FILE_SYSTEM_SERVICE_CREATED, true); - - // Force-clear server-side umask to make HttpFS match WebHDFS behavior - conf.set(FsPermission.UMASK_LABEL, "000"); - - return conf; + return fileSystemConf; } }