From f5f12b576efc7ab289fa88cca6e5760b5a7a12a9 Mon Sep 17 00:00:00 2001 From: Jonathan Eagles Date: Wed, 31 May 2017 10:18:09 -0500 Subject: [PATCH] =?UTF-8?q?YARN-6497.=20Method=20length=20of=20ResourceMan?= =?UTF-8?q?ager#serviceInit()=20is=20too=20long=20(Gergely=20Nov=C3=A1k=20?= =?UTF-8?q?via=20jeagles)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit cbfed0e82f57e96b8d5309e0613057963840554f) --- .../resourcemanager/ResourceManager.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index 3a93c6e118f..0573690cf62 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -57,6 +57,7 @@ import org.apache.hadoop.yarn.event.AsyncDispatcher; import org.apache.hadoop.yarn.event.Dispatcher; import org.apache.hadoop.yarn.event.EventDispatcher; import org.apache.hadoop.yarn.event.EventHandler; +import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; import org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter; import org.apache.hadoop.yarn.server.resourcemanager.amlauncher.AMLauncherEventType; @@ -220,13 +221,7 @@ public class ResourceManager extends CompositeService implements Recoverable { rmContext.setConfigurationProvider(configurationProvider); // load core-site.xml - InputStream coreSiteXMLInputStream = - this.configurationProvider.getConfigurationInputStream(this.conf, - YarnConfiguration.CORE_SITE_CONFIGURATION_FILE); - if (coreSiteXMLInputStream != null) { - this.conf.addResource(coreSiteXMLInputStream, - YarnConfiguration.CORE_SITE_CONFIGURATION_FILE); - } + loadConfigurationXml(YarnConfiguration.CORE_SITE_CONFIGURATION_FILE); // Do refreshUserToGroupsMappings with loaded core-site.xml Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(this.conf) @@ -239,13 +234,7 @@ public class ResourceManager extends CompositeService implements Recoverable { ProxyUsers.refreshSuperUserGroupsConfiguration(this.conf); // load yarn-site.xml - InputStream yarnSiteXMLInputStream = - this.configurationProvider.getConfigurationInputStream(this.conf, - YarnConfiguration.YARN_SITE_CONFIGURATION_FILE); - if (yarnSiteXMLInputStream != null) { - this.conf.addResource(yarnSiteXMLInputStream, - YarnConfiguration.YARN_SITE_CONFIGURATION_FILE); - } + loadConfigurationXml(YarnConfiguration.YARN_SITE_CONFIGURATION_FILE); validateConfigs(this.conf); @@ -311,6 +300,16 @@ public class ResourceManager extends CompositeService implements Recoverable { super.serviceInit(this.conf); } + private void loadConfigurationXml(String configurationFile) + throws YarnException, IOException { + InputStream configurationInputStream = + this.configurationProvider.getConfigurationInputStream(this.conf, + configurationFile); + if (configurationInputStream != null) { + this.conf.addResource(configurationInputStream, configurationFile); + } + } + protected EmbeddedElector createEmbeddedElector() throws IOException { EmbeddedElector elector; curatorEnabled =