YARN-7143. FileNotFound handling in ResourceUtils is inconsistent
Change-Id: Ib1bb487e14a15edd2b5a42cf5078c5a2b295f069
This commit is contained in:
parent
a1382a18df
commit
462f6c490e
@ -342,17 +342,14 @@ private static void initializeResourceTypesIfNeeded(Configuration conf,
|
|||||||
if (!initializedResources) {
|
if (!initializedResources) {
|
||||||
synchronized (ResourceUtils.class) {
|
synchronized (ResourceUtils.class) {
|
||||||
if (!initializedResources) {
|
if (!initializedResources) {
|
||||||
if (conf == null) {
|
Configuration resConf = conf;
|
||||||
conf = new YarnConfiguration();
|
|
||||||
|
if (resConf == null) {
|
||||||
|
resConf = new YarnConfiguration();
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
addResourcesFileToConf(resourceFile, conf);
|
addResourcesFileToConf(resourceFile, resConf);
|
||||||
} catch (FileNotFoundException fe) {
|
initializeResourcesMap(resConf);
|
||||||
if (LOG.isDebugEnabled()) {
|
|
||||||
LOG.debug("Unable to find '" + resourceFile + "'.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
initializeResourcesMap(conf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,7 +386,7 @@ private static InputStream getConfInputStream(String resourceFile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addResourcesFileToConf(String resourceFile,
|
private static void addResourcesFileToConf(String resourceFile,
|
||||||
Configuration conf) throws FileNotFoundException {
|
Configuration conf) {
|
||||||
try {
|
try {
|
||||||
InputStream ris = getConfInputStream(resourceFile, conf);
|
InputStream ris = getConfInputStream(resourceFile, conf);
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
@ -397,15 +394,11 @@ private static void addResourcesFileToConf(String resourceFile,
|
|||||||
}
|
}
|
||||||
conf.addResource(ris);
|
conf.addResource(ris);
|
||||||
} catch (FileNotFoundException fe) {
|
} catch (FileNotFoundException fe) {
|
||||||
throw fe;
|
LOG.info("Unable to find '" + resourceFile + "'.");
|
||||||
} catch (IOException ie) {
|
} catch (IOException | YarnException ex) {
|
||||||
LOG.fatal("Exception trying to read resource types configuration '"
|
LOG.fatal("Exception trying to read resource types configuration '"
|
||||||
+ resourceFile + "'.", ie);
|
+ resourceFile + "'.", ex);
|
||||||
throw new YarnRuntimeException(ie);
|
throw new YarnRuntimeException(ex);
|
||||||
} catch (YarnException ye) {
|
|
||||||
LOG.fatal("YARN Exception trying to read resource types configuration '"
|
|
||||||
+ resourceFile + "'.", ye);
|
|
||||||
throw new YarnRuntimeException(ye);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,22 +460,19 @@ public static Map<String, ResourceInformation> getNodeResourceInformation(
|
|||||||
private static Map<String, ResourceInformation> initializeNodeResourceInformation(
|
private static Map<String, ResourceInformation> initializeNodeResourceInformation(
|
||||||
Configuration conf) {
|
Configuration conf) {
|
||||||
Map<String, ResourceInformation> nodeResources = new HashMap<>();
|
Map<String, ResourceInformation> nodeResources = new HashMap<>();
|
||||||
try {
|
|
||||||
addResourcesFileToConf(
|
addResourcesFileToConf(YarnConfiguration.NODE_RESOURCES_CONFIGURATION_FILE,
|
||||||
YarnConfiguration.NODE_RESOURCES_CONFIGURATION_FILE, conf);
|
conf);
|
||||||
for (Map.Entry<String, String> entry : conf) {
|
|
||||||
String key = entry.getKey();
|
for (Map.Entry<String, String> entry : conf) {
|
||||||
String value = entry.getValue();
|
String key = entry.getKey();
|
||||||
if (key.startsWith(YarnConfiguration.NM_RESOURCES_PREFIX)) {
|
String value = entry.getValue();
|
||||||
addResourceInformation(key, value, nodeResources);
|
|
||||||
}
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeResources;
|
return nodeResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user