YARN-1758. Fixed ResourceManager to not mandate the presence of site specific configuration files and thus fix failures in downstream tests. Contributed by Xuan Gong.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1573695 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
146bf6c01e
commit
a60434368c
@ -368,6 +368,10 @@ Release 2.4.0 - UNRELEASED
|
|||||||
|
|
||||||
YARN-1760. TestRMAdminService assumes CapacityScheduler. (kasha)
|
YARN-1760. TestRMAdminService assumes CapacityScheduler. (kasha)
|
||||||
|
|
||||||
|
YARN-1758. Fixed ResourceManager to not mandate the presence of site specific
|
||||||
|
configuration files and thus fix failures in downstream tests. (Xuan Gong via
|
||||||
|
vinodkv)
|
||||||
|
|
||||||
Release 2.3.1 - UNRELEASED
|
Release 2.3.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -54,13 +54,14 @@ public synchronized InputStream getConfigurationInputStream(
|
|||||||
if (YarnConfiguration.RM_CONFIGURATION_FILES.contains(name)) {
|
if (YarnConfiguration.RM_CONFIGURATION_FILES.contains(name)) {
|
||||||
filePath = new Path(this.configDir, name);
|
filePath = new Path(this.configDir, name);
|
||||||
if (!fs.exists(filePath)) {
|
if (!fs.exists(filePath)) {
|
||||||
throw new YarnException("Can not find Configuration: " + name + " in "
|
LOG.info(filePath + " not found");
|
||||||
+ configDir);
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filePath = new Path(name);
|
filePath = new Path(name);
|
||||||
if (!fs.exists(filePath)) {
|
if (!fs.exists(filePath)) {
|
||||||
throw new YarnException("Can not find file: " + name);
|
LOG.info(filePath + " not found");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fs.open(filePath);
|
return fs.open(filePath);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -538,8 +539,11 @@ public UpdateNodeResourceResponse updateNodeResource(
|
|||||||
|
|
||||||
private synchronized Configuration getConfiguration(Configuration conf,
|
private synchronized Configuration getConfiguration(Configuration conf,
|
||||||
String confFileName) throws YarnException, IOException {
|
String confFileName) throws YarnException, IOException {
|
||||||
conf.addResource(this.rmContext.getConfigurationProvider()
|
InputStream confFileInputStream = this.rmContext.getConfigurationProvider()
|
||||||
.getConfigurationInputStream(conf, confFileName));
|
.getConfigurationInputStream(conf, confFileName);
|
||||||
|
if (confFileInputStream != null) {
|
||||||
|
conf.addResource(confFileInputStream);
|
||||||
|
}
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -142,9 +143,13 @@ protected void serviceStart() throws Exception {
|
|||||||
if (conf.getBoolean(
|
if (conf.getBoolean(
|
||||||
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
|
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
|
||||||
false)) {
|
false)) {
|
||||||
conf.addResource(this.rmContext.getConfigurationProvider()
|
InputStream inputStream =
|
||||||
.getConfigurationInputStream(conf,
|
this.rmContext.getConfigurationProvider()
|
||||||
YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE));
|
.getConfigurationInputStream(conf,
|
||||||
|
YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE);
|
||||||
|
if (inputStream != null) {
|
||||||
|
conf.addResource(inputStream);
|
||||||
|
}
|
||||||
refreshServiceAcls(conf, RMPolicyProvider.getInstance());
|
refreshServiceAcls(conf, RMPolicyProvider.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.security.AccessControlException;
|
import java.security.AccessControlException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -170,9 +171,13 @@ protected void serviceStart() throws Exception {
|
|||||||
if (conf.getBoolean(
|
if (conf.getBoolean(
|
||||||
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
|
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
|
||||||
false)) {
|
false)) {
|
||||||
conf.addResource(this.rmContext.getConfigurationProvider()
|
InputStream inputStream =
|
||||||
.getConfigurationInputStream(conf,
|
this.rmContext.getConfigurationProvider()
|
||||||
YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE));
|
.getConfigurationInputStream(conf,
|
||||||
|
YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE);
|
||||||
|
if (inputStream != null) {
|
||||||
|
conf.addResource(inputStream);
|
||||||
|
}
|
||||||
refreshServiceAcls(conf, RMPolicyProvider.getInstance());
|
refreshServiceAcls(conf, RMPolicyProvider.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
@ -190,13 +191,20 @@ protected void serviceInit(Configuration conf) throws Exception {
|
|||||||
rmContext.setConfigurationProvider(configurationProvider);
|
rmContext.setConfigurationProvider(configurationProvider);
|
||||||
|
|
||||||
// load yarn-site.xml
|
// load yarn-site.xml
|
||||||
this.conf.addResource(this.configurationProvider
|
InputStream yarnSiteXMLInputStream =
|
||||||
.getConfigurationInputStream(this.conf,
|
this.configurationProvider.getConfigurationInputStream(this.conf,
|
||||||
YarnConfiguration.YARN_SITE_CONFIGURATION_FILE));
|
YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
|
||||||
|
if (yarnSiteXMLInputStream != null) {
|
||||||
|
this.conf.addResource(yarnSiteXMLInputStream);
|
||||||
|
}
|
||||||
// load core-site.xml
|
// load core-site.xml
|
||||||
this.conf.addResource(this.configurationProvider
|
InputStream coreSiteXMLInputStream =
|
||||||
.getConfigurationInputStream(this.conf,
|
this.configurationProvider.getConfigurationInputStream(this.conf,
|
||||||
YarnConfiguration.CORE_SITE_CONFIGURATION_FILE));
|
YarnConfiguration.CORE_SITE_CONFIGURATION_FILE);
|
||||||
|
if (coreSiteXMLInputStream != null) {
|
||||||
|
this.conf.addResource(coreSiteXMLInputStream);
|
||||||
|
}
|
||||||
|
|
||||||
// Do refreshUserToGroupsMappings with loaded core-site.xml
|
// Do refreshUserToGroupsMappings with loaded core-site.xml
|
||||||
Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(this.conf)
|
Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(this.conf)
|
||||||
.refresh();
|
.refresh();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@ -163,9 +164,13 @@ protected void serviceStart() throws Exception {
|
|||||||
if (conf.getBoolean(
|
if (conf.getBoolean(
|
||||||
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
|
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
|
||||||
false)) {
|
false)) {
|
||||||
conf.addResource(this.rmContext.getConfigurationProvider()
|
InputStream inputStream =
|
||||||
.getConfigurationInputStream(conf,
|
this.rmContext.getConfigurationProvider()
|
||||||
YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE));
|
.getConfigurationInputStream(conf,
|
||||||
|
YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE);
|
||||||
|
if (inputStream != null) {
|
||||||
|
conf.addResource(inputStream);
|
||||||
|
}
|
||||||
refreshServiceAcls(conf, RMPolicyProvider.getInstance());
|
refreshServiceAcls(conf, RMPolicyProvider.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
|
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -1024,10 +1025,15 @@ public List<ApplicationAttemptId> getAppsInQueue(String queueName) {
|
|||||||
private CapacitySchedulerConfiguration loadCapacitySchedulerConfiguration(
|
private CapacitySchedulerConfiguration loadCapacitySchedulerConfiguration(
|
||||||
Configuration configuration) throws IOException {
|
Configuration configuration) throws IOException {
|
||||||
try {
|
try {
|
||||||
configuration.addResource(this.rmContext.getConfigurationProvider()
|
InputStream CSInputStream =
|
||||||
.getConfigurationInputStream(configuration,
|
this.rmContext.getConfigurationProvider()
|
||||||
YarnConfiguration.CS_CONFIGURATION_FILE));
|
.getConfigurationInputStream(configuration,
|
||||||
return new CapacitySchedulerConfiguration(configuration, false);
|
YarnConfiguration.CS_CONFIGURATION_FILE);
|
||||||
|
if (CSInputStream != null) {
|
||||||
|
configuration.addResource(CSInputStream);
|
||||||
|
return new CapacitySchedulerConfiguration(configuration, false);
|
||||||
|
}
|
||||||
|
return new CapacitySchedulerConfiguration(configuration, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
@ -126,14 +126,6 @@ public void testAdminRefreshQueuesWithFileSystemBasedConfigurationProvider()
|
|||||||
throws IOException, YarnException {
|
throws IOException, YarnException {
|
||||||
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
||||||
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
||||||
try {
|
|
||||||
rm = new MockRM(configuration);
|
|
||||||
rm.init(configuration);
|
|
||||||
rm.start();
|
|
||||||
fail("Should throw an exception");
|
|
||||||
} catch(Exception ex) {
|
|
||||||
// Expect exception here
|
|
||||||
}
|
|
||||||
|
|
||||||
//upload default configurations
|
//upload default configurations
|
||||||
uploadDefaultConfiguration();
|
uploadDefaultConfiguration();
|
||||||
@ -180,14 +172,6 @@ public void testAdminAclsWithFileSystemBasedConfigurationProvider()
|
|||||||
throws IOException, YarnException {
|
throws IOException, YarnException {
|
||||||
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
||||||
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
||||||
try {
|
|
||||||
rm = new MockRM(configuration);
|
|
||||||
rm.init(configuration);
|
|
||||||
rm.start();
|
|
||||||
fail("Should throw an exception");
|
|
||||||
} catch(Exception ex) {
|
|
||||||
// Expect exception here
|
|
||||||
}
|
|
||||||
|
|
||||||
//upload default configurations
|
//upload default configurations
|
||||||
uploadDefaultConfiguration();
|
uploadDefaultConfiguration();
|
||||||
@ -246,14 +230,6 @@ public void testServiceAclsRefreshWithFileSystemBasedConfigurationProvider()
|
|||||||
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
||||||
ResourceManager resourceManager = null;
|
ResourceManager resourceManager = null;
|
||||||
try {
|
try {
|
||||||
try {
|
|
||||||
resourceManager = new ResourceManager();
|
|
||||||
resourceManager.init(configuration);
|
|
||||||
resourceManager.start();
|
|
||||||
fail("Should throw an exception");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// expect to get an exception here
|
|
||||||
}
|
|
||||||
|
|
||||||
//upload default configurations
|
//upload default configurations
|
||||||
uploadDefaultConfiguration();
|
uploadDefaultConfiguration();
|
||||||
@ -350,14 +326,6 @@ private void verifyServiceACLsRefresh(ServiceAuthorizationManager manager,
|
|||||||
throws IOException, YarnException {
|
throws IOException, YarnException {
|
||||||
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
||||||
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
||||||
try {
|
|
||||||
rm = new MockRM(configuration);
|
|
||||||
rm.init(configuration);
|
|
||||||
rm.start();
|
|
||||||
fail("Should throw an exception");
|
|
||||||
} catch(Exception ex) {
|
|
||||||
// Expect exception here
|
|
||||||
}
|
|
||||||
|
|
||||||
//upload default configurations
|
//upload default configurations
|
||||||
uploadDefaultConfiguration();
|
uploadDefaultConfiguration();
|
||||||
@ -408,14 +376,6 @@ public void testRefreshUserToGroupsMappingsWithLocalConfigurationProvider() {
|
|||||||
throws IOException, YarnException {
|
throws IOException, YarnException {
|
||||||
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
||||||
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
||||||
try {
|
|
||||||
rm = new MockRM(configuration);
|
|
||||||
rm.init(configuration);
|
|
||||||
rm.start();
|
|
||||||
fail("Should throw an exception");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// Expect exception here
|
|
||||||
}
|
|
||||||
|
|
||||||
String user = UserGroupInformation.getCurrentUser().getUserName();
|
String user = UserGroupInformation.getCurrentUser().getUserName();
|
||||||
List<String> groupWithInit =
|
List<String> groupWithInit =
|
||||||
@ -484,14 +444,6 @@ public void testRefreshNodesWithFileSystemBasedConfigurationProvider()
|
|||||||
throws IOException, YarnException {
|
throws IOException, YarnException {
|
||||||
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
||||||
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
||||||
try {
|
|
||||||
rm = new MockRM(configuration);
|
|
||||||
rm.init(configuration);
|
|
||||||
rm.start();
|
|
||||||
fail("Should throw an exception");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// Expect exception here
|
|
||||||
}
|
|
||||||
|
|
||||||
// upload default configurations
|
// upload default configurations
|
||||||
uploadDefaultConfiguration();
|
uploadDefaultConfiguration();
|
||||||
@ -617,6 +569,27 @@ public void testRMHAWithFileSystemBasedConfiguration() throws IOException,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRMStartsWithoutConfigurationFilesProvided() {
|
||||||
|
// enable FileSystemBasedConfigurationProvider without uploading
|
||||||
|
// any configuration files into Remote File System.
|
||||||
|
configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
|
||||||
|
"org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
|
||||||
|
|
||||||
|
// The configurationProvider will return NULL instead of
|
||||||
|
// throwing out Exceptions, if there are no configuration files provided.
|
||||||
|
// RM will not load the remote Configuration files,
|
||||||
|
// and should start successfully.
|
||||||
|
try {
|
||||||
|
rm = new MockRM(configuration);
|
||||||
|
rm.init(configuration);
|
||||||
|
rm.start();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
fail("Should not get any exceptions");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private String writeConfigurationXML(Configuration conf, String confXMLName)
|
private String writeConfigurationXML(Configuration conf, String confXMLName)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
DataOutputStream output = null;
|
DataOutputStream output = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user