Skip to content

Commit bec8b0f

Browse files
committed
YARN-11888. Serve the Capacity Scheduler UI.
1 parent 75c30c9 commit bec8b0f

File tree

7 files changed

+106
-8
lines changed

7 files changed

+106
-8
lines changed

LICENSE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/st
257257
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/jquery
258258
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/jt/jquery.jstree.js
259259
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/resources/TERMINAL
260+
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/node_modules
260261

261262
=======
262263
For hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/utils/cJSON.[ch]:

hadoop-assemblies/src/main/resources/assemblies/hadoop-yarn-dist.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@
211211
<include>**/*</include>
212212
</includes>
213213
</fileSet>
214+
<fileSet>
215+
<directory>hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/target/hadoop-yarn-capacity-scheduler-ui-${project.version}</directory>
216+
<outputDirectory>/share/hadoop/${hadoop.component}/webapps/scheduler-ui</outputDirectory>
217+
<includes>
218+
<include>**/*</include>
219+
</includes>
220+
</fileSet>
214221
<!-- Copy dependecies from hadoop-yarn-server-timelineservice as well -->
215222
<fileSet>
216223
<directory>hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/target/lib</directory>
@@ -280,6 +287,7 @@
280287
<excludes>
281288
<exclude>org.apache.hadoop:hadoop-yarn-server-timelineservice*</exclude>
282289
<exclude>org.apache.hadoop:hadoop-yarn-ui</exclude>
290+
<exclude>org.apache.hadoop:hadoop-yarn-capacity-scheduler-ui</exclude>
283291
<exclude>org.apache.hadoop:hadoop-yarn-csi</exclude>
284292
</excludes>
285293
<binaries>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,21 @@ private static void addDeprecatedKeys() {
378378

379379
public static final String YARN_WEBAPP_UI2_WARFILE_PATH = "yarn."
380380
+ "webapp.ui2.war-file-path";
381+
382+
/**
383+
* Enable YARN Capacity Scheduler UI.
384+
*/
385+
public static final String YARN_WEBAPP_SCHEDULER_UI_ENABLE = "yarn."
386+
+ "webapp.scheduler-ui.enable";
387+
public static final boolean DEFAULT_YARN_WEBAPP_SCHEDULER_UI_ENABLE = false;
388+
389+
public static final String YARN_WEBAPP_SCHEDULER_UI_WARFILE_PATH = "yarn."
390+
+ "webapp.scheduler-ui.war-file-path";
391+
392+
public static final String YARN_WEBAPP_SCHEDULER_UI_READ_ONLY_ENABLE = "yarn."
393+
+ "webapp.scheduler-ui.read-only.enable";
394+
public static final boolean DEFAULT_YARN_WEBAPP_SCHEDULER_UI_READ_ONLY = false;
395+
381396
public static final String YARN_API_SERVICES_ENABLE = "yarn."
382397
+ "webapp.api-service.enable";
383398
public static final String YARN_WEBAPP_UI1_ENABLE_TOOLS = "yarn."

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/WebApps.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,16 +481,22 @@ public WebApp start() {
481481
}
482482

483483
public WebApp start(WebApp webapp) {
484-
return start(webapp, null);
484+
return start(webapp, (WebAppContext[]) null);
485485
}
486486

487-
public WebApp start(WebApp webapp, WebAppContext ui2Context) {
487+
public WebApp start(WebApp webapp, WebAppContext... additionalContexts) {
488488
WebApp webApp = build(webapp);
489489
HttpServer2 httpServer = webApp.httpServer();
490-
if (ui2Context != null) {
491-
addFiltersForNewContext(ui2Context);
492-
httpServer.addHandlerAtFront(ui2Context);
490+
491+
if (additionalContexts != null) {
492+
for (WebAppContext context : additionalContexts) {
493+
if (context != null) {
494+
addFiltersForNewContext(context);
495+
httpServer.addHandlerAtFront(context);
496+
}
497+
}
493498
}
499+
494500
try {
495501
httpServer.start();
496502
LOG.info("Web app {} started at {}.", name, httpServer.getConnectorAddress(0).getPort());
@@ -500,15 +506,15 @@ public WebApp start(WebApp webapp, WebAppContext ui2Context) {
500506
return webApp;
501507
}
502508

503-
private void addFiltersForNewContext(WebAppContext ui2Context) {
509+
private void addFiltersForNewContext(WebAppContext uiContext) {
504510
Map<String, String> params = getConfigParameters(csrfConfigPrefix);
505511

506512
if (hasCSRFEnabled(params)) {
507513
LOG.info("CSRF Protection has been enabled for the {} application. "
508514
+ "Please ensure that there is an authentication mechanism "
509515
+ "enabled (kerberos, custom, etc).", name);
510516
String restCsrfClassName = RestCsrfPreventionFilter.class.getName();
511-
HttpServer2.defineFilter(ui2Context, restCsrfClassName,
517+
HttpServer2.defineFilter(uiContext, restCsrfClassName,
512518
restCsrfClassName, params, new String[]{"/*"});
513519
}
514520
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,30 @@
336336
<value></value>
337337
</property>
338338

339+
<property>
340+
<description>To enable YARN Capacity Scheduler UI.</description>
341+
<name>yarn.webapp.scheduler-ui.enable</name>
342+
<value>false</value>
343+
</property>
344+
345+
<property>
346+
<description>
347+
The WAR file path for the YARN Capacity Scheduler UI.
348+
If not specified, the scheduler UI will be loaded from the classpath.
349+
</description>
350+
<name>yarn.webapp.scheduler-ui.war-file-path</name>
351+
<value></value>
352+
</property>
353+
354+
<property>
355+
<description>
356+
Enable read-only mode for YARN Capacity Scheduler UI.
357+
When set to true, the UI will not allow configuration changes.
358+
</description>
359+
<name>yarn.webapp.scheduler-ui.read-only.enable</name>
360+
<value>false</value>
361+
</property>
362+
339363
<property>
340364
<description>
341365
Enable services rest api on ResourceManager.

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ public class ResourceManager extends CompositeService
190190
*/
191191
public static final String UI2_WEBAPP_NAME = "/ui2";
192192

193+
/*
194+
* Scheduler UI webapp name
195+
*/
196+
public static final String SCHEDULER_UI_WEBAPP_NAME = "/scheduler-ui";
197+
193198
/**
194199
* "Always On" services. Services that need to run always irrespective of
195200
* the HA state of the RM.
@@ -1479,6 +1484,38 @@ protected void startWepApp() {
14791484
}
14801485
}
14811486

1487+
WebAppContext schedulerUiWebAppContext = null;
1488+
if (getConfig().getBoolean(YarnConfiguration.YARN_WEBAPP_SCHEDULER_UI_ENABLE,
1489+
YarnConfiguration.DEFAULT_YARN_WEBAPP_SCHEDULER_UI_ENABLE)) {
1490+
String onDiskPath = getConfig()
1491+
.get(YarnConfiguration.YARN_WEBAPP_SCHEDULER_UI_WARFILE_PATH);
1492+
1493+
schedulerUiWebAppContext = new WebAppContext();
1494+
schedulerUiWebAppContext.setContextPath(SCHEDULER_UI_WEBAPP_NAME);
1495+
1496+
if (onDiskPath == null) {
1497+
String war = "hadoop-yarn-capacity-scheduler-ui-" + VersionInfo.getVersion() + ".war";
1498+
URL url = getClass().getClassLoader().getResource(war);
1499+
1500+
if (url == null) {
1501+
onDiskPath = getWebAppsPath("scheduler-ui");
1502+
} else {
1503+
onDiskPath = url.getFile();
1504+
}
1505+
}
1506+
if (onDiskPath == null || onDiskPath.isEmpty()) {
1507+
LOG.error("No war file or webapps found for scheduler-ui !");
1508+
} else {
1509+
if (onDiskPath.endsWith(".war")) {
1510+
schedulerUiWebAppContext.setWar(onDiskPath);
1511+
LOG.info("Using war file at: {}.", onDiskPath);
1512+
} else {
1513+
schedulerUiWebAppContext.setResourceBase(onDiskPath);
1514+
LOG.info("Using webapps at: {}.", onDiskPath);
1515+
}
1516+
}
1517+
}
1518+
14821519
builder.withAttribute(IsResourceManagerActiveServlet.RM_ATTRIBUTE, this);
14831520
builder.withServlet(IsResourceManagerActiveServlet.SERVLET_NAME,
14841521
IsResourceManagerActiveServlet.PATH_SPEC,
@@ -1487,7 +1524,7 @@ protected void startWepApp() {
14871524
try {
14881525
RMWebApp rmWebApp = new RMWebApp(this);
14891526
builder.withResourceConfig(rmWebApp.resourceConfig());
1490-
webApp = builder.start(rmWebApp, uiWebAppContext);
1527+
webApp = builder.start(rmWebApp, uiWebAppContext, schedulerUiWebAppContext);
14911528
} catch (WebAppException e) {
14921529
webApp = e.getWebApp();
14931530
throw e;

hadoop-yarn-project/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@
155155
<type>${yarn.ui.packaging}</type>
156156
<scope>provided</scope>
157157
</dependency>
158+
<dependency>
159+
<groupId>org.apache.hadoop</groupId>
160+
<artifactId>hadoop-yarn-capacity-scheduler-ui</artifactId>
161+
<version>${project.version}</version>
162+
<type>${yarn.ui.packaging}</type>
163+
<scope>provided</scope>
164+
</dependency>
158165
<dependency>
159166
<groupId>org.apache.hadoop</groupId>
160167
<artifactId>hadoop-yarn-server-timelineservice-hbase-server-2</artifactId>

0 commit comments

Comments
 (0)