HDFS-14623. In NameNode Web UI, for Head the file (first 32K) old data is showing. Contributed by hemanthboyina.

This commit is contained in:
Wei-Chiu Chuang 2019-08-09 15:41:37 -07:00
parent 865021b8c9
commit ce3c5a3e3b

View File

@ -195,20 +195,28 @@
var processPreview = function(url) { var processPreview = function(url) {
url += "&noredirect=true"; url += "&noredirect=true";
$.ajax({ if(request && request.readyState != 4){
request.abort();
}
request = $.ajax({
cache: false,
type: 'GET', type: 'GET',
url: url, url: url,
async: false,
processData: false, processData: false,
crossDomain: true crossDomain: true
}).done(function(data) { }).done(function(data, textStatus, jqXHR) {
url = data.Location; url = data.Location;
$.ajax({ $.ajax({
cache: false,
type: 'GET', type: 'GET',
url: url, url: url,
async: false,
processData: false, processData: false,
crossDomain: true crossDomain: true
}).always(function(data) { }).always(function(data, textStatus, jqXHR) {
$('#file-info-preview-body').val(data); $('#file-info-preview-body').val(jqXHR.responseText);
$('#file-info-tail').show(); $('#file-info-tail').show();
}).fail(function(jqXHR, textStatus, errorThrown) { }).fail(function(jqXHR, textStatus, errorThrown) {
show_err_msg("Couldn't preview the file. " + errorThrown); show_err_msg("Couldn't preview the file. " + errorThrown);
@ -218,12 +226,17 @@
}); });
} }
$('#file-info-preview-tail').click(function() { var request = null;
$('#file-info-preview-tail')
.off('click')
.on('click', function() {
var offset = d.fileLength - TAIL_CHUNK_SIZE; var offset = d.fileLength - TAIL_CHUNK_SIZE;
var url = offset > 0 ? download_url + '&offset=' + offset : download_url; var url = offset > 0 ? download_url + '&offset=' + offset : download_url;
processPreview(url); processPreview(url);
}); });
$('#file-info-preview-head').click(function() { $('#file-info-preview-head')
.off('click')
.on('click', function() {
var url = d.fileLength > TAIL_CHUNK_SIZE ? download_url + '&length=' + TAIL_CHUNK_SIZE : download_url; var url = d.fileLength > TAIL_CHUNK_SIZE ? download_url + '&length=' + TAIL_CHUNK_SIZE : download_url;
processPreview(url); processPreview(url);
}); });