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:
parent
909f1e82d3
commit
6c2ce3d56b
@ -2406,6 +2406,9 @@ public static boolean isAclEnabled(Configuration conf) {
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
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 RMWebApp(ResourceManager rm) {
|
||||
|
||||
@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 String getRedirectPath() {
|
||||
}
|
||||
|
||||
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 @@ private void bindExternalClasses() {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user