Browse Source

AMBARI-5243 Confirm Hosts step: perfomance optimization in order to support large number of hosts. (atkach)

atkach 11 years ago
parent
commit
6d865b76ec

+ 13 - 1
ambari-web/app/controllers/wizard/step2_controller.js

@@ -18,6 +18,7 @@
 
 
 var App = require('app');
 var App = require('app');
 var validator = require('utils/validator');
 var validator = require('utils/validator');
+var lazyloading = require('utils/lazy_loading');
 
 
 App.WizardStep2Controller = Em.Controller.extend({
 App.WizardStep2Controller = Em.Controller.extend({
   name: 'wizardStep2Controller',
   name: 'wizardStep2Controller',
@@ -310,7 +311,18 @@ App.WizardStep2Controller = Em.Controller.extend({
       },
       },
       bodyClass: Ember.View.extend({
       bodyClass: Ember.View.extend({
         templateName: require('templates/common/items_list_popup'),
         templateName: require('templates/common/items_list_popup'),
-        items: hostNames
+        items: hostNames,
+        insertedItems: [],
+        didInsertElement: function() {
+          lazyloading.run({
+            destination: this.get('insertedItems'),
+            source: this.get('items'),
+            context: this,
+            initSize: 100,
+            chunkSize: 500,
+            delay: 100
+          });
+        }
       })
       })
     });
     });
   },
   },

+ 23 - 7
ambari-web/app/controllers/wizard/step3_controller.js

@@ -43,7 +43,7 @@ App.WizardStep3Controller = Em.Controller.extend({
 
 
   navigateStep: function () {
   navigateStep: function () {
     if(this.get('isLoaded')){
     if(this.get('isLoaded')){
-      if (this.get('content.installOptions.manualInstall') !== true) {
+      if (!this.get('content.installOptions.manualInstall')) {
         if (!this.get('wizardController').getDBProperty('bootStatus')) {
         if (!this.get('wizardController').getDBProperty('bootStatus')) {
           this.startBootstrap();
           this.startBootstrap();
         }
         }
@@ -51,13 +51,11 @@ App.WizardStep3Controller = Em.Controller.extend({
         this.set('bootHosts', this.get('hosts'));
         this.set('bootHosts', this.get('hosts'));
         if (App.testMode) {
         if (App.testMode) {
           this.getHostInfo();
           this.getHostInfo();
-          this.get('bootHosts').setEach('bootStatus', 'REGISTERED');
           this.get('bootHosts').setEach('cpu', '2');
           this.get('bootHosts').setEach('cpu', '2');
           this.get('bootHosts').setEach('memory', '2000000');
           this.get('bootHosts').setEach('memory', '2000000');
           this.set('isSubmitDisabled', false);
           this.set('isSubmitDisabled', false);
         } else {
         } else {
           this.set('registrationStartedAt', null);
           this.set('registrationStartedAt', null);
-          this.get('bootHosts').setEach('bootStatus', 'DONE');
           this.startRegistration();
           this.startRegistration();
         }
         }
       }
       }
@@ -88,11 +86,15 @@ App.WizardStep3Controller = Em.Controller.extend({
   loadHosts: function () {
   loadHosts: function () {
     var hostsInfo = this.get('content.hosts');
     var hostsInfo = this.get('content.hosts');
     var hosts = [];
     var hosts = [];
+    var bootStatus = (this.get('content.installOptions.manualInstall')) ? 'DONE' : 'PENDING';
+    if (App.testMode) {
+      bootStatus = 'REGISTERED';
+    }
 
 
     for (var index in hostsInfo) {
     for (var index in hostsInfo) {
       var hostInfo = App.HostInfo.create({
       var hostInfo = App.HostInfo.create({
         name: hostsInfo[index].name,
         name: hostsInfo[index].name,
-        bootStatus: hostsInfo[index].bootStatus,
+        bootStatus: bootStatus,
         isChecked: false
         isChecked: false
       });
       });
 
 
@@ -159,8 +161,19 @@ App.WizardStep3Controller = Em.Controller.extend({
       },
       },
       secondary: null,
       secondary: null,
       bodyClass: Ember.View.extend({
       bodyClass: Ember.View.extend({
+        templateName: require('templates/common/items_list_popup'),
         items: selectedHosts,
         items: selectedHosts,
-        templateName: require('templates/common/items_list_popup')
+        insertedItems: [],
+        didInsertElement: function() {
+          lazyloading.run({
+            destination: this.get('insertedItems'),
+            source: this.get('items'),
+            context: this,
+            initSize: 100,
+            chunkSize: 500,
+            delay: 100
+          });
+        }
       })
       })
     });
     });
   },
   },
@@ -206,12 +219,15 @@ App.WizardStep3Controller = Em.Controller.extend({
     this.numPolls = 0;
     this.numPolls = 0;
     this.set('registrationStartedAt', null);
     this.set('registrationStartedAt', null);
     this.set('bootHosts', this.get('hosts'));
     this.set('bootHosts', this.get('hosts'));
-    this.get('bootHosts').setEach('bootStatus', 'PENDING');
     this.doBootstrap();
     this.doBootstrap();
   },
   },
 
 
   isRegistrationInProgress: true,
   isRegistrationInProgress: true,
 
 
+  setRegistrationInProgressOnce: function () {
+    Ember.run.once(this, 'setRegistrationInProgress');
+  }.observes('bootHosts.@each.bootStatus'),
+
   setRegistrationInProgress: function () {
   setRegistrationInProgress: function () {
     var bootHosts = this.get('bootHosts');
     var bootHosts = this.get('bootHosts');
     //if hosts aren't loaded yet then registration should be in progress
     //if hosts aren't loaded yet then registration should be in progress
@@ -223,7 +239,7 @@ App.WizardStep3Controller = Em.Controller.extend({
       }
       }
     }
     }
     this.set('isRegistrationInProgress', result);
     this.set('isRegistrationInProgress', result);
-  }.observes('bootHosts.@each.bootStatus'),
+  },
 
 
   disablePreviousSteps: function () {
   disablePreviousSteps: function () {
     App.router.get('installerController.isStepDisabled').filter(function (step) {
     App.router.get('installerController.isStepDisabled').filter(function (step) {

+ 1 - 1
ambari-web/app/templates/common/items_list_popup.hbs

@@ -16,6 +16,6 @@
 * limitations under the License.
 * limitations under the License.
 }}
 }}
 
 
-{{#each item in view.items}}
+{{#each item in view.insertedItems}}
     <p>{{item}}</p>
     <p>{{item}}</p>
 {{/each}}
 {{/each}}

+ 12 - 6
ambari-web/app/views/wizard/step3_view.js

@@ -67,12 +67,12 @@ App.WizardStep3View = App.TableView.extend({
     this.get('content').setEach('isChecked', false);
     this.get('content').setEach('isChecked', false);
   },
   },
 
 
-  watchSelectionOnce: function(){
+  watchSelectionOnce: function () {
     Em.run.once(this, 'watchSelection');
     Em.run.once(this, 'watchSelection');
-  }.observes('content.@each.isChecked'),
+  }.observes('content.@each.isChecked', 'pageContent'),
 
 
   /**
   /**
-   * watch selection and calculate flags as:
+   * watch selection and calculate such flags as:
    * - noHostsSelected
    * - noHostsSelected
    * - selectedHostsCount
    * - selectedHostsCount
    * - pageChecked
    * - pageChecked
@@ -116,6 +116,12 @@ App.WizardStep3View = App.TableView.extend({
     ];
     ];
   }.property(),
   }.property(),
 
 
+  hostBootStatusObserver: function(){
+    Ember.run.once(this, 'countCategoryHosts');
+    Ember.run.once(this, 'filter');
+    Ember.run.once(this, 'monitorStatuses');
+  }.observes('content.@each.bootStatus'),
+
   countCategoryHosts: function () {
   countCategoryHosts: function () {
     var counters = {
     var counters = {
       "RUNNING": 0,
       "RUNNING": 0,
@@ -132,7 +138,7 @@ App.WizardStep3View = App.TableView.extend({
     this.get('categories').forEach(function(category) {
     this.get('categories').forEach(function(category) {
       category.set('hostsCount', counters[category.get('hostsBootStatus')]);
       category.set('hostsCount', counters[category.get('hostsBootStatus')]);
     }, this);
     }, this);
-  }.observes('content.@each.bootStatus'),
+  },
 
 
 
 
   /**
   /**
@@ -147,7 +153,7 @@ App.WizardStep3View = App.TableView.extend({
       result = this.get('content').filterProperty('bootStatus', this.get('selectedCategory.hostsBootStatus'));
       result = this.get('content').filterProperty('bootStatus', this.get('selectedCategory.hostsBootStatus'));
     }
     }
     this.set('filteredContent', result);
     this.set('filteredContent', result);
-  }.observes('content.@each.bootStatus', 'selectedCategory'),
+  }.observes('selectedCategory'),
   /**
   /**
    * Trigger on Category click
    * Trigger on Category click
    * @param {Object} event
    * @param {Object} event
@@ -193,7 +199,7 @@ App.WizardStep3View = App.TableView.extend({
         this.set('message', Em.I18n.t('installer.step3.warnings.someWarnings').format((hosts.length - failedHosts), failedHosts));
         this.set('message', Em.I18n.t('installer.step3.warnings.someWarnings').format((hosts.length - failedHosts), failedHosts));
       }
       }
     }
     }
-  }.observes('controller.isWarningsLoaded', 'controller.isHostHaveWarnings', 'controller.bootHosts.@each.bootStatus', 'controller.repoCategoryWarnings', 'controller.diskCategoryWarnings')
+  }.observes('controller.isWarningsLoaded', 'controller.isHostHaveWarnings', 'controller.repoCategoryWarnings', 'controller.diskCategoryWarnings')
 });
 });
 
 
 //todo: move it inside WizardStep3View
 //todo: move it inside WizardStep3View

+ 0 - 23
ambari-web/test/installer/step3_test.js

@@ -281,27 +281,4 @@ describe('App.WizardStep3Controller', function () {
       });
       });
     });
     });
   });
   });
-
-  describe('#noHostsSelected', function() {
-    tests.forEach(function(test) {
-      it(test.m + ' - nothing checked', function() {
-        var controller = App.WizardStep3Controller.create({
-          hosts: test.bootHosts
-        });
-        controller.get('hosts').setEach('isChecked', false);
-        console.log(controller.hosts);
-        expect(controller.get('noHostsSelected')).to.equal(true);
-      });
-      it(test.m + ' - one checked', function() {
-        var controller = App.WizardStep3Controller.create({
-          hosts: test.bootHosts
-        });
-        controller.get('hosts').setEach('isChecked', true);
-        expect(controller.get('noHostsSelected')).to.equal(false);
-      });
-    });
-  });
-
-
-
 });
 });