Browse Source

AMBARI-4187 Disable redundant calls to server. (atkach)

atkach 11 years ago
parent
commit
44f03fb18d

+ 1 - 1
ambari-web/app/models/host.js

@@ -63,7 +63,7 @@ App.Host = DS.Model.extend({
 
   componentsWithStaleConfigsCount: function() {
     return this.get('hostComponents').filterProperty('staleConfigs', true).length;
-  }.property('hostComponents.@each'),
+  }.property('hostComponents.@each.staleConfigs'),
 
   publicHostNameFormatted: function() {
     return this.get('publicHostName').length < 43 ? this.get('publicHostName') : this.get('publicHostName').substr(0, 40) + '...';

+ 14 - 8
ambari-web/app/views/common/table_view.js

@@ -44,9 +44,13 @@ App.TableView = Em.View.extend({
     var name = this.get('controller.name');
 
     this.set('startIndexOnLoad', App.db.getStartIndex(name));
-    self.dataLoading().done(function (initValue) {
-      self.set('displayLength', initValue);
-    });
+    if (App.db.getDisplayLength(name)) {
+      this.set('displayLength', App.db.getDisplayLength(name));
+    } else {
+      self.dataLoading().done(function (initValue) {
+        self.set('displayLength', initValue);
+      });
+    }
 
     var filterConditions = App.db.getFilterConditions(name);
     if (filterConditions) {
@@ -205,7 +209,10 @@ App.TableView = Em.View.extend({
   }),
 
   rowsPerPageSelectView: Em.Select.extend({
-    content: ['10', '25', '50']
+    content: ['10', '25', '50'],
+    change: function () {
+      this.get('parentView').saveDisplayLength();
+    }
   }),
 
   // start index for displayed content on the page
@@ -277,13 +284,12 @@ App.TableView = Em.View.extend({
   saveDisplayLength: function() {
     var self = this;
     Em.run.next(function() {
-      //App.db.setDisplayLength(self.get('controller.name'), self.get('displayLength'));
-      var key = self.displayLengthKey();
+      App.db.setDisplayLength(self.get('controller.name'), self.get('displayLength'));
       if (!App.testMode) {
-        self.postUserPref(key, self.get('displayLength'));
+        self.postUserPref(self.displayLengthKey(), self.get('displayLength'));
       }
     });
-  }.observes('displayLength'),
+  },
 
   saveStartIndex: function() {
     if (this.get('filteringComplete')) {

+ 8 - 6
ambari-web/app/views/main/host/summary.js

@@ -71,17 +71,17 @@ App.MainHostSummaryView = Em.View.extend({
   loadDecommissionNodesList: function () {
     var self = this;
     var clusterName = App.router.get('clusterController.clusterName');
-    var persistUrl = App.apiPrefix + '/persist';
+    var persistUrl = App.apiPrefix + '/persist/decommissionDataNodesTag';
     var clusterUrl = App.apiPrefix + '/clusters/' + clusterName;
     var getConfigAjax = {
       type: 'GET',
       url: persistUrl,
       dataType: 'json',
       timeout: App.timeout,
-      success: function (data) {
-        if (data && data.decommissionDataNodesTag) {
+      success: function (decommissionDataNodesTag) {
+        if (decommissionDataNodesTag) {
           // We know the tag which contains the decommisioned nodes.
-          var configsUrl = clusterUrl + '/configurations?type=hdfs-exclude-file&tag=' + data.decommissionDataNodesTag;
+          var configsUrl = clusterUrl + '/configurations?type=hdfs-exclude-file&tag=' + decommissionDataNodesTag;
           var decomNodesAjax = {
             type: 'GET',
             url: configsUrl,
@@ -120,11 +120,13 @@ App.MainHostSummaryView = Em.View.extend({
           }
         }
       }
-    }
+    };
     jQuery.ajax(getConfigAjax);
   },
   didInsertElement: function () {
-    this.loadDecommissionNodesList();
+    if (this.get('content.hostComponents').someProperty('componentName', 'DATANODE')) {
+      this.loadDecommissionNodesList();
+    }
     this.addToolTip();
   },
   addToolTip: function() {

+ 49 - 26
ambari-web/test/views/wizard/step9_view_test.js

@@ -25,23 +25,31 @@ describe('App.HostStatusView', function () {
       p: 'isFailed',
       tests: [
         {
-          controller: {isStepCompleted: true},
-          obj: {status: 'failed'},
+          obj: {
+            status: 'failed',
+            progress: 100
+          },
           e: true
         },
         {
-          controller: {isStepCompleted: false},
-          obj: {status: 'failed'},
+          obj: {
+            status: 'failed',
+            progress: 99
+          },
           e: false
         },
         {
-          controller: {isStepCompleted: true},
-          obj: {status: 'success'},
+          obj: {
+            status: 'success',
+            progress: 100
+          },
           e: false
         },
         {
-          controller: {isStepCompleted: false},
-          obj: {status: 'success'},
+          obj: {
+            status: 'success',
+            progress: 99
+          },
           e: false
         }
       ]
@@ -50,23 +58,31 @@ describe('App.HostStatusView', function () {
       p: 'isSuccess',
       tests: [
         {
-          controller: {isStepCompleted: true},
-          obj: {status: 'success'},
+          obj: {
+            status: 'success',
+            progress: 100
+          },
           e: true
         },
         {
-          controller: {isStepCompleted: false},
-          obj: {status: 'success'},
+          obj: {
+            status: 'success',
+            progress: 99
+          },
           e: false
         },
         {
-          controller: {isStepCompleted: true},
-          obj: {status: 'failed'},
+          obj: {
+            status: 'failed',
+            progress: 100
+          },
           e: false
         },
         {
-          controller: {isStepCompleted: false},
-          obj: {status: 'failed'},
+          obj: {
+            status: 'failed',
+            progress: 99
+          },
           e: false
         }
       ]
@@ -75,23 +91,31 @@ describe('App.HostStatusView', function () {
       p: 'isWarning',
       tests: [
         {
-          controller: {isStepCompleted: true},
-          obj: {status: 'warning'},
+          obj: {
+            status: 'warning',
+            progress: 100
+          },
           e: true
         },
         {
-          controller: {isStepCompleted: false},
-          obj: {status: 'warning'},
+          obj: {
+            status: 'warning',
+            progress: 99
+          },
           e: false
         },
         {
-          controller: {isStepCompleted: true},
-          obj: {status: 'failed'},
+          obj: {
+            status: 'failed',
+            progress: 100
+          },
           e: false
         },
         {
-          controller: {isStepCompleted: false},
-          obj: {status: 'failed'},
+          obj: {
+            status: 'failed',
+            progress: 99
+          },
           e: false
         }
       ]
@@ -101,8 +125,7 @@ describe('App.HostStatusView', function () {
     describe(test.p, function() {
       test.tests.forEach(function(t) {
         var hostStatusView = App.HostStatusView.create();
-        it('controller.isStepCompleted = ' + t.controller.isStepCompleted + '; obj.status = ' + t.obj.status, function() {
-          hostStatusView.set('controller', t.controller);
+        it('obj.progress = ' + t.obj.progress + '; obj.status = ' + t.obj.status, function() {
           hostStatusView.set('obj', t.obj);
           expect(hostStatusView.get(test.p)).to.equal(t.e);
         });