YARN-10389. Option to override RMWebServices with custom WebService class

Contributed by Tanu Ajmera. Reviewed by Bilwa ST and Sunil G.
This commit is contained in:
Prabhu Joseph 2020-08-06 19:15:16 +05:30 committed by Prabhu Joseph
parent 909f1e82d3
commit 6c2ce3d56b
3 changed files with 22 additions and 7 deletions

View File

@ -2406,6 +2406,9 @@ public class YarnConfiguration extends Configuration {
public static final String YARN_HTTP_WEBAPP_CUSTOM_UNWRAPPED_DAO_CLASSES =
"yarn.http.rmwebapp.custom.unwrapped.dao.classes";
public static final String YARN_WEBAPP_CUSTOM_WEBSERVICE_CLASS =
"yarn.webapp.custom.webservice.class";
/**
* Whether or not users are allowed to request that Docker containers honor
* the debug deletion delay. This is useful for troubleshooting Docker

View File

@ -3376,6 +3376,15 @@
<value></value>
</property>
<property>
<description>
Used to specify custom WebServices class to bind with RMWebApp overriding
the default RMWebServices.
</description>
<name>yarn.webapp.custom.webservice.class</name>
<value></value>
</property>
<property>
<description>The Node Label script to run. Script output Line starting with
"NODE_PARTITION:" will be considered as Node Label Partition. In case of

View File

@ -22,6 +22,7 @@ import static org.apache.hadoop.yarn.util.StringHelper.pajoin;
import java.net.InetSocketAddress;
import org.apache.hadoop.conf.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
@ -44,6 +45,7 @@ public class RMWebApp extends WebApp implements YarnWebParams {
LoggerFactory.getLogger(RMWebApp.class.getName());
private final ResourceManager rm;
private boolean standby = false;
private Configuration conf;
public RMWebApp(ResourceManager rm) {
this.rm = rm;
@ -51,15 +53,17 @@ public class RMWebApp extends WebApp implements YarnWebParams {
@Override
public void setup() {
conf = rm.getConfig();
bind(JAXBContextResolver.class);
bind(RMWebServices.class);
Class webService = conf.getClass(
YarnConfiguration.YARN_WEBAPP_CUSTOM_WEBSERVICE_CLASS,
RMWebServices.class);
bind(webService);
bind(GenericExceptionHandler.class);
bind(RMWebApp.class).toInstance(this);
bindExternalClasses();
bind(ResourceManager.class).toInstance(rm);
if (rm != null) {
bind(ResourceManager.class).toInstance(rm);
}
route("/", RmController.class);
route(pajoin("/nodes", NODE_STATE), RmController.class, "nodes");
route(pajoin("/apps", APP_STATE), RmController.class);
@ -99,8 +103,7 @@ public class RMWebApp extends WebApp implements YarnWebParams {
}
private void bindExternalClasses() {
YarnConfiguration yarnConf = new YarnConfiguration(rm.getConfig());
Class<?>[] externalClasses = yarnConf
Class<?>[] externalClasses = conf
.getClasses(YarnConfiguration.YARN_HTTP_WEBAPP_EXTERNAL_CLASSES);
for (Class<?> c : externalClasses) {
bind(c);
@ -111,7 +114,7 @@ public class RMWebApp extends WebApp implements YarnWebParams {
private String buildRedirectPath() {
// make a copy of the original configuration so not to mutate it. Also use
// an YarnConfiguration to force loading of yarn-site.xml.
YarnConfiguration yarnConf = new YarnConfiguration(rm.getConfig());
YarnConfiguration yarnConf = new YarnConfiguration(conf);
String activeRMHAId = RMHAUtils.findActiveRMHAId(yarnConf);
String path = "";
if (activeRMHAId != null) {