This is an automated email from the ASF dual-hosted git repository.
prabhujoseph pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6c2ce3d YARN-10389. Option to override RMWebServices with custom
WebService class
6c2ce3d is described below
commit 6c2ce3d56b14ce4139cbecc1cfe026e5a838f319
Author: Prabhu Joseph <[email protected]>
AuthorDate: Thu Aug 6 19:15:16 2020 +0530
YARN-10389. Option to override RMWebServices with custom WebService class
Contributed by Tanu Ajmera. Reviewed by Bilwa ST and Sunil G.
---
.../org/apache/hadoop/yarn/conf/YarnConfiguration.java | 3 +++
.../src/main/resources/yarn-default.xml | 9 +++++++++
.../yarn/server/resourcemanager/webapp/RMWebApp.java | 17 ++++++++++-------
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
index 19ce622..6c1be0e 100644
---
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
+++
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java
@@ -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
diff --git
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
index 2208b00..47f1239 100644
---
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
+++
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml
@@ -3377,6 +3377,15 @@
</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
multiple lines have this pattern, then last one will be considered
diff --git
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java
index 5075d25..3ed53f6 100644
---
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java
+++
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java
@@ -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) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]