Procházet zdrojové kódy

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

Wei-Chiu Chuang před 5 roky
rodič
revize
ce3c5a3e3b

+ 19 - 6
hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js

@@ -195,20 +195,28 @@
 
       var processPreview = function(url) {
         url += "&noredirect=true";
-        $.ajax({
+        if(request && request.readyState != 4){
+         request.abort();
+        }
+      request =  $.ajax({
+           cache: false,
           type: 'GET',
           url: url,
+          async: false,
           processData: false,
           crossDomain: true
-        }).done(function(data) {
+        }).done(function(data, textStatus, jqXHR) {
+
           url = data.Location;
           $.ajax({
+            cache: false,
             type: 'GET',
             url: url,
+            async: false,
             processData: false,
             crossDomain: true
-          }).always(function(data) {
-            $('#file-info-preview-body').val(data);
+          }).always(function(data, textStatus, jqXHR) {
+            $('#file-info-preview-body').val(jqXHR.responseText);
             $('#file-info-tail').show();
           }).fail(function(jqXHR, textStatus, 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 url = offset > 0 ? download_url + '&offset=' + offset : download_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;
         processPreview(url);
       });