HDFS-5749. Web UI does not show up during the period of loading FSImage. (Contributed by Haohui Mai)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1568578 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Arpit Agarwal 2014-02-15 01:20:19 +00:00
parent 3f6a6c88bb
commit 8b63c41891
3 changed files with 45 additions and 26 deletions

View File

@ -464,6 +464,9 @@ Release 2.4.0 - UNRELEASED
HDFS-5953. TestBlockReaderFactory fails in trunk. (Akira Ajisaka via wang) HDFS-5953. TestBlockReaderFactory fails in trunk. (Akira Ajisaka via wang)
HDFS-5759. Web UI does not show up during the period of loading FSImage.
(Haohui Mai via Arpit Agarwal)
Release 2.3.1 - UNRELEASED Release 2.3.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -151,7 +151,7 @@
{/fs} {/fs}
</table> </table>
<div class="page-header"><h1>Namenode Journal Status</h1></div> <div class="page-header"><h1>NameNode Journal Status</h1></div>
<p><b>Current transaction ID:</b> {nn.JournalTransactionInfo.LastAppliedOrWrittenTxId}</p> <p><b>Current transaction ID:</b> {nn.JournalTransactionInfo.LastAppliedOrWrittenTxId}</p>
<table class="table" title="NameNode Journals"> <table class="table" title="NameNode Journals">
<thead> <thead>

View File

@ -50,24 +50,23 @@
var data = {}; var data = {};
// Workarounds for the fact that JMXJsonServlet returns non-standard JSON strings // Workarounds for the fact that JMXJsonServlet returns non-standard JSON strings
function data_workaround(d) { function workaround(nn) {
d.nn.JournalTransactionInfo = JSON.parse(d.nn.JournalTransactionInfo); nn.JournalTransactionInfo = JSON.parse(nn.JournalTransactionInfo);
d.nn.NameJournalStatus = JSON.parse(d.nn.NameJournalStatus); nn.NameJournalStatus = JSON.parse(nn.NameJournalStatus);
d.nn.NameDirStatuses = JSON.parse(d.nn.NameDirStatuses); nn.NameDirStatuses = JSON.parse(nn.NameDirStatuses);
d.nn.NodeUsage = JSON.parse(d.nn.NodeUsage); nn.NodeUsage = JSON.parse(nn.NodeUsage);
d.nn.CorruptFiles = JSON.parse(d.nn.CorruptFiles); nn.CorruptFiles = JSON.parse(nn.CorruptFiles);
return d; return nn;
} }
load_json( load_json(
BEANS, BEANS,
function(d) { guard_with_startup_progress(function(d) {
for (var k in d) { for (var k in d) {
data[k] = d[k].beans[0]; data[k] = k === 'nn' ? workaround(d[k].beans[0]) : d[k].beans[0];
} }
data = data_workaround(data);
render(); render();
}, }),
function (url, jqxhr, text, err) { function (url, jqxhr, text, err) {
show_err_msg('<p>Failed to retrieve data from ' + url + ', cause: ' + err + '</p>'); show_err_msg('<p>Failed to retrieve data from ' + url + ', cause: ' + err + '</p>');
}); });
@ -92,6 +91,19 @@
show_err_msg('<p>Failed to retrieve data from ' + url + ', cause: ' + err + '</p>'); show_err_msg('<p>Failed to retrieve data from ' + url + ', cause: ' + err + '</p>');
} }
function guard_with_startup_progress(fn) {
return function() {
try {
fn.apply(this, arguments);
} catch (err) {
if (err instanceof TypeError) {
show_err_msg('NameNode is still loading. Redirecting to the Startup Progress page.');
load_startup_progress();
}
}
};
}
function load_startup_progress() { function load_startup_progress() {
function workaround(r) { function workaround(r) {
function rename_property(o, s, d) { function rename_property(o, s, d) {
@ -143,25 +155,29 @@
return r; return r;
} }
$.get('/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo', function (resp) { $.get(
'/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo',
guard_with_startup_progress(function (resp) {
var data = workaround(resp.beans[0]); var data = workaround(resp.beans[0]);
dust.render('datanode-info', data, function(err, out) { dust.render('datanode-info', data, function(err, out) {
$('#tab-datanode').html(out); $('#tab-datanode').html(out);
$('#ui-tabs a[href="#tab-datanode"]').tab('show'); $('#ui-tabs a[href="#tab-datanode"]').tab('show');
}); });
}).error(ajax_error_handler); })).error(ajax_error_handler);
} }
$('a[href="#tab-datanode"]').click(load_datanode_info); $('a[href="#tab-datanode"]').click(load_datanode_info);
function load_snapshot_info() { function load_snapshot_info() {
$.get('/jmx?qry=Hadoop:service=NameNode,name=FSNamesystemState', function (resp) { $.get(
'/jmx?qry=Hadoop:service=NameNode,name=FSNamesystemState',
guard_with_startup_progress(function (resp) {
var data = JSON.parse(resp.beans[0].SnapshotStats); var data = JSON.parse(resp.beans[0].SnapshotStats);
dust.render('snapshot-info', data, function(err, out) { dust.render('snapshot-info', data, function(err, out) {
$('#tab-snapshot').html(out); $('#tab-snapshot').html(out);
$('#ui-tabs a[href="#tab-snapshot"]').tab('show'); $('#ui-tabs a[href="#tab-snapshot"]').tab('show');
}); });
}).error(ajax_error_handler); })).error(ajax_error_handler);
} }
$('#ui-tabs a[href="#tab-snapshot"]').click(load_snapshot_info); $('#ui-tabs a[href="#tab-snapshot"]').click(load_snapshot_info);