YARN-7143. FileNotFound handling in ResourceUtils is inconsistent Change-Id: Ib1bb487e14a15edd2b5a42cf5078c5a2b295f069
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/462f6c49 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/462f6c49 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/462f6c49 Branch: refs/heads/HDFS-7240 Commit: 462f6c490efd2a38a9ba639bcda47b3aa667f650 Parents: a1382a1 Author: Daniel Templeton <templ...@apache.org> Authored: Thu Nov 9 10:36:49 2017 -0800 Committer: Daniel Templeton <templ...@apache.org> Committed: Thu Nov 9 11:58:49 2017 -0800 ---------------------------------------------------------------------- .../yarn/util/resource/ResourceUtils.java | 56 ++++++++------------ 1 file changed, 23 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/462f6c49/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java index c9cc27b..9c9c0ef8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java @@ -342,17 +342,14 @@ public class ResourceUtils { if (!initializedResources) { synchronized (ResourceUtils.class) { if (!initializedResources) { - if (conf == null) { - conf = new YarnConfiguration(); - } - try { - addResourcesFileToConf(resourceFile, conf); - } catch (FileNotFoundException fe) { - if (LOG.isDebugEnabled()) { - LOG.debug("Unable to find '" + resourceFile + "'."); - } + Configuration resConf = conf; + + if (resConf == null) { + resConf = new YarnConfiguration(); } - initializeResourcesMap(conf); + + addResourcesFileToConf(resourceFile, resConf); + initializeResourcesMap(resConf); } } } @@ -389,7 +386,7 @@ public class ResourceUtils { } private static void addResourcesFileToConf(String resourceFile, - Configuration conf) throws FileNotFoundException { + Configuration conf) { try { InputStream ris = getConfInputStream(resourceFile, conf); if (LOG.isDebugEnabled()) { @@ -397,15 +394,11 @@ public class ResourceUtils { } conf.addResource(ris); } catch (FileNotFoundException fe) { - throw fe; - } catch (IOException ie) { + LOG.info("Unable to find '" + resourceFile + "'."); + } catch (IOException | YarnException ex) { LOG.fatal("Exception trying to read resource types configuration '" - + resourceFile + "'.", ie); - throw new YarnRuntimeException(ie); - } catch (YarnException ye) { - LOG.fatal("YARN Exception trying to read resource types configuration '" - + resourceFile + "'.", ye); - throw new YarnRuntimeException(ye); + + resourceFile + "'.", ex); + throw new YarnRuntimeException(ex); } } @@ -467,22 +460,19 @@ public class ResourceUtils { private static Map<String, ResourceInformation> initializeNodeResourceInformation( Configuration conf) { Map<String, ResourceInformation> nodeResources = new HashMap<>(); - try { - addResourcesFileToConf( - YarnConfiguration.NODE_RESOURCES_CONFIGURATION_FILE, conf); - for (Map.Entry<String, String> entry : conf) { - String key = entry.getKey(); - String value = entry.getValue(); - if (key.startsWith(YarnConfiguration.NM_RESOURCES_PREFIX)) { - addResourceInformation(key, value, nodeResources); - } - } - } catch (FileNotFoundException fe) { - if (LOG.isDebugEnabled()) { - LOG.debug("Couldn't find node resources file: " - + YarnConfiguration.NODE_RESOURCES_CONFIGURATION_FILE); + + addResourcesFileToConf(YarnConfiguration.NODE_RESOURCES_CONFIGURATION_FILE, + conf); + + for (Map.Entry<String, String> entry : conf) { + String key = entry.getKey(); + String value = entry.getValue(); + + if (key.startsWith(YarnConfiguration.NM_RESOURCES_PREFIX)) { + addResourceInformation(key, value, nodeResources); } } + return nodeResources; } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org