Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.hadoop.util.JvmPauseMonitor;
import org.apache.hadoop.util.ShutdownHookManager;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
Expand Down Expand Up @@ -83,6 +84,8 @@ public class Router extends CompositeService {

private static final String METRICS_NAME = "Router";

private static long routerStartupTime = Time.monotonicNow();

public Router() {
super(Router.class.getName());
}
Expand Down Expand Up @@ -171,6 +174,10 @@ public void startWepApp() {
webApp = builder.start(new RouterWebApp(this));
}

public static long getRouterStartupTime() {
return routerStartupTime;
}

public static void main(String[] argv) {
Configuration conf = new YarnConfiguration();
Thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void render(Block html) {
div("#nav").
h3("Cluster").
ul().
li().a(url("server"), "ServerInfo").__().
li().a(url(""), "About").__().
li().a(url("federation"), "Federation").__().
li().a(url("nodes"), "Nodes").__().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public void index() {
render(AboutPage.class);
}

public void server() {
setTitle("About the current router server");
render(ServerPage.class);
}

public void about() {
setTitle("About the Cluster");
render(AboutPage.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void setup() {
bind(Router.class).toInstance(router);
}
route("/", RouterController.class);
route("/server", RouterController.class, "server");
route("/cluster", RouterController.class, "about");
route("/about", RouterController.class, "about");
route("/apps", RouterController.class, "apps");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.yarn.server.router.webapp;

import com.google.inject.Inject;
import org.apache.hadoop.util.VersionInfo;
import org.apache.hadoop.yarn.server.router.Router;
import org.apache.hadoop.yarn.util.YarnVersionInfo;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.hadoop.yarn.webapp.view.InfoBlock;

import java.util.Date;

/**
* Server block for the Router Web UI.
*/
public class ServerBlock extends HtmlBlock {

@Inject
ServerBlock(Router router, ViewContext ctx) {
super(ctx);
}

@Override
protected void render(Block html) {

info("Router Details")
.__("Router started on",
new Date(Router.getRouterStartupTime()))
.__("Router Version", YarnVersionInfo.getVersion())
.__("Hadoop Version", VersionInfo.getVersion());

html.__(InfoBlock.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.yarn.server.router.webapp;

import org.apache.hadoop.yarn.webapp.SubView;

/**
* Server page for the Router Web UI.
*/
public class ServerPage extends RouterView {

@Override
protected void preHead(Page.HTML<__> html) {
commonPreHead(html);
}

@Override
protected Class<? extends SubView> content() {
return ServerBlock.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
package org.apache.hadoop.yarn.server.router;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.security.authorize.AccessControlList;
import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
import org.apache.hadoop.util.VersionInfo;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.util.YarnVersionInfo;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -50,6 +53,9 @@ public void testServiceACLRefresh() {
conf.set("security.applicationclient.protocol.acl", aclsString);
conf.set("security.resourcemanager-administration.protocol.acl",
aclsString);
conf.set("yarn.router.clientrm.address", "0.0.0.0:1111");
conf.set("yarn.router.webapp.address", "0.0.0.0:1112");
conf.set("yarn.router.rmadmin.address", "0.0.0.0:1113");

Router router = new Router();
router.init(conf);
Expand Down Expand Up @@ -87,4 +93,15 @@ private void verifyServiceACLsRefresh(ServiceAuthorizationManager manager,
}
}

@Test
public void testStartTime() {
assertNotNull(Router.getRouterStartupTime());
}

@Test
public void testVersion() {
assertNotNull(YarnVersionInfo.getVersion());
assertNotNull(VersionInfo.getVersion());
}

}