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-5759. Web UI does not show up during the period of loading FSImage.
(Haohui Mai via Arpit Agarwal)
Release 2.3.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -151,7 +151,7 @@
{/fs}
</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>
<table class="table" title="NameNode Journals">
<thead>

View File

@ -50,24 +50,23 @@
var data = {};
// Workarounds for the fact that JMXJsonServlet returns non-standard JSON strings
function data_workaround(d) {
d.nn.JournalTransactionInfo = JSON.parse(d.nn.JournalTransactionInfo);
d.nn.NameJournalStatus = JSON.parse(d.nn.NameJournalStatus);
d.nn.NameDirStatuses = JSON.parse(d.nn.NameDirStatuses);
d.nn.NodeUsage = JSON.parse(d.nn.NodeUsage);
d.nn.CorruptFiles = JSON.parse(d.nn.CorruptFiles);
return d;
function workaround(nn) {
nn.JournalTransactionInfo = JSON.parse(nn.JournalTransactionInfo);
nn.NameJournalStatus = JSON.parse(nn.NameJournalStatus);
nn.NameDirStatuses = JSON.parse(nn.NameDirStatuses);
nn.NodeUsage = JSON.parse(nn.NodeUsage);
nn.CorruptFiles = JSON.parse(nn.CorruptFiles);
return nn;
}
load_json(
BEANS,
function(d) {
guard_with_startup_progress(function(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();
},
}),
function (url, jqxhr, text, err) {
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>');
}
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 workaround(r) {
function rename_property(o, s, d) {
@ -143,25 +155,29 @@
return r;
}
$.get('/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo', function (resp) {
var data = workaround(resp.beans[0]);
dust.render('datanode-info', data, function(err, out) {
$('#tab-datanode').html(out);
$('#ui-tabs a[href="#tab-datanode"]').tab('show');
});
}).error(ajax_error_handler);
$.get(
'/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo',
guard_with_startup_progress(function (resp) {
var data = workaround(resp.beans[0]);
dust.render('datanode-info', data, function(err, out) {
$('#tab-datanode').html(out);
$('#ui-tabs a[href="#tab-datanode"]').tab('show');
});
})).error(ajax_error_handler);
}
$('a[href="#tab-datanode"]').click(load_datanode_info);
function load_snapshot_info() {
$.get('/jmx?qry=Hadoop:service=NameNode,name=FSNamesystemState', function (resp) {
var data = JSON.parse(resp.beans[0].SnapshotStats);
dust.render('snapshot-info', data, function(err, out) {
$('#tab-snapshot').html(out);
$('#ui-tabs a[href="#tab-snapshot"]').tab('show');
});
}).error(ajax_error_handler);
$.get(
'/jmx?qry=Hadoop:service=NameNode,name=FSNamesystemState',
guard_with_startup_progress(function (resp) {
var data = JSON.parse(resp.beans[0].SnapshotStats);
dust.render('snapshot-info', data, function(err, out) {
$('#tab-snapshot').html(out);
$('#ui-tabs a[href="#tab-snapshot"]').tab('show');
});
})).error(ajax_error_handler);
}
$('#ui-tabs a[href="#tab-snapshot"]').click(load_snapshot_info);