Skip to content

Commit 29b2dfb

Browse files
committed
YARN-11888. Serve the Capacity Scheduler UI.
1 parent 1995d34 commit 29b2dfb

File tree

12 files changed

+135
-9
lines changed

12 files changed

+135
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/npm-debug.log
4747
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/testem.log
4848
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/dist
4949
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tmp
50+
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/node_modules/
5051
yarnregistry.pdf
5152
patchprocess/
5253
.history/

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-capacity-scheduler-ui/src/main/webapp/react-router.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export default {
55
// Server-side render by default, to enable SPA mode set this to `false`
66
ssr: false,
77
appDirectory: "src/app",
8+
basename: "/scheduler-ui",
89
} satisfies Config;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/app/entry.client.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ async function enableMocking() {
4040
}
4141

4242
enableMocking().then(() => {
43+
// Handle servlet welcome-file redirect to index.html
44+
// React Router doesn't need index.html in the URL, so redirect without it
45+
if (window.location.pathname.endsWith('/index.html')) {
46+
const newPath = window.location.pathname.replace(/\/index\.html$/, '/');
47+
window.history.replaceState(null, '', newPath + window.location.search + window.location.hash);
48+
}
49+
4350
startTransition(() => {
4451
hydrateRoot(
4552
document,

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/app/root.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,21 @@ export default function App() {
5555
</ValidationProvider>
5656
);
5757
}
58+
59+
export function HydrateFallback() {
60+
return (
61+
<div className="flex h-screen items-center justify-center bg-background">
62+
<div className="text-center space-y-4">
63+
<div
64+
className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"
65+
role="status"
66+
>
67+
<span className="sr-only">Loading...</span>
68+
</div>
69+
<p className="text-sm text-muted-foreground">
70+
Loading YARN Capacity Scheduler UI...
71+
</p>
72+
</div>
73+
</div>
74+
);
75+
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default defineConfig(({ mode }) => {
1414
const clusterProxyTarget = env.VITE_CLUSTER_PROXY_TARGET;
1515

1616
return {
17+
base: '/scheduler-ui/',
1718
plugins: [
1819
tailwindcss(),
1920
reactRouter(),

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.

0 commit comments

Comments
 (0)