Skip to content

Commit 5a16515

Browse files
author
luoyuan
committed
YARN-11012. Add version and process startup time on Router web page
1 parent 20b78c8 commit 5a16515

File tree

6 files changed

+102
-0
lines changed

6 files changed

+102
-0
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/Router.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.hadoop.util.JvmPauseMonitor;
3030
import org.apache.hadoop.util.ShutdownHookManager;
3131
import org.apache.hadoop.util.StringUtils;
32+
import org.apache.hadoop.util.Time;
3233
import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
3334
import org.apache.hadoop.yarn.conf.YarnConfiguration;
3435
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
@@ -83,6 +84,8 @@ public class Router extends CompositeService {
8384

8485
private static final String METRICS_NAME = "Router";
8586

87+
private static long routerStartupTime = Time.monotonicNow();
88+
8689
public Router() {
8790
super(Router.class.getName());
8891
}
@@ -171,6 +174,10 @@ public void startWepApp() {
171174
webApp = builder.start(new RouterWebApp(this));
172175
}
173176

177+
public static long getRouterStartupTime() {
178+
return routerStartupTime;
179+
}
180+
174181
public static void main(String[] argv) {
175182
Configuration conf = new YarnConfiguration();
176183
Thread

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/NavBlock.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public void render(Block html) {
3131
div("#nav").
3232
h3("Cluster").
3333
ul().
34+
li().a(url("server"), "ServerInfo").__().
3435
li().a(url(""), "About").__().
3536
li().a(url("federation"), "Federation").__().
3637
li().a(url("nodes"), "Nodes").__().

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public void index() {
3838
render(AboutPage.class);
3939
}
4040

41+
public void server() {
42+
setTitle("About the current router server");
43+
render(ServerPage.class);
44+
}
45+
4146
public void about() {
4247
setTitle("About the Cluster");
4348
render(AboutPage.class);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebApp.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public void setup() {
4545
bind(Router.class).toInstance(router);
4646
}
4747
route("/", RouterController.class);
48+
route("/server", RouterController.class, "server");
4849
route("/cluster", RouterController.class, "about");
4950
route("/about", RouterController.class, "about");
5051
route("/apps", RouterController.class, "apps");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.yarn.server.router.webapp;
20+
21+
import com.google.inject.Inject;
22+
import org.apache.hadoop.util.VersionInfo;
23+
import org.apache.hadoop.yarn.server.router.Router;
24+
import org.apache.hadoop.yarn.util.YarnVersionInfo;
25+
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
26+
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
27+
28+
import java.util.Date;
29+
30+
/**
31+
* Server block for the Router Web UI.
32+
*/
33+
public class ServerBlock extends HtmlBlock {
34+
35+
@Inject
36+
ServerBlock(Router router, ViewContext ctx) {
37+
super(ctx);
38+
}
39+
40+
@Override
41+
protected void render(Block html) {
42+
43+
info("Router Details")
44+
.__("Router started on",
45+
new Date(Router.getRouterStartupTime()))
46+
.__("Router Version", YarnVersionInfo.getVersion())
47+
.__("Hadoop Version", VersionInfo.getVersion());
48+
49+
html.__(InfoBlock.class);
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.yarn.server.router.webapp;
20+
21+
import org.apache.hadoop.yarn.webapp.SubView;
22+
23+
/**
24+
* Server page for the Router Web UI.
25+
*/
26+
public class ServerPage extends RouterView {
27+
28+
@Override
29+
protected void preHead(Page.HTML<__> html) {
30+
commonPreHead(html);
31+
}
32+
33+
@Override
34+
protected Class<? extends SubView> content() {
35+
return ServerBlock.class;
36+
}
37+
}

0 commit comments

Comments
 (0)