ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-6133 Incorrect summary on Review page in Add Service wizard. (atkach)
Date Mon, 16 Jun 2014 12:01:06 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk e29411798 -> 8a9dddee0


AMBARI-6133 Incorrect summary on Review page in Add Service wizard. (atkach)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8a9dddee
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8a9dddee
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8a9dddee

Branch: refs/heads/trunk
Commit: 8a9dddee047b3851106e3a68be173903630966e2
Parents: e294117
Author: atkach <atkach@hortonworks.com>
Authored: Mon Jun 16 14:57:10 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Mon Jun 16 14:57:10 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/installer.js         |  3 +-
 .../app/controllers/main/host/add_controller.js | 18 +++++-----
 .../controllers/main/service/add_controller.js  | 35 +++++++-------------
 ambari-web/app/controllers/wizard.js            | 24 +++++++++-----
 .../wizard/stack_upgrade/step3_controller.js    |  2 +-
 .../app/controllers/wizard/step2_controller.js  | 28 ++++++++++++----
 .../app/controllers/wizard/step3_controller.js  | 21 ++++++++----
 .../app/controllers/wizard/step5_controller.js  |  2 --
 .../app/controllers/wizard/step6_controller.js  |  7 +++-
 .../app/controllers/wizard/step8_controller.js  | 27 +++++----------
 ambari-web/app/views/main/host/add_view.js      | 12 +++----
 ambari-web/app/views/main/service/add_view.js   | 10 +++---
 12 files changed, 100 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index a44d868..0626b10 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -36,7 +36,6 @@ App.InstallerController = App.WizardController.extend({
     advancedServiceConfig: null,
     configGroups: [],
     slaveGroupProperties: null,
-    installedHosts: [],
     stacks: null,
     controllerName: 'installerController'
   }),
@@ -112,7 +111,7 @@ App.InstallerController = App.WizardController.extend({
    * Will be used at <code>Assign Masters(step5)</code> step
    */
   loadConfirmedHosts: function () {
-    this.set('content.hosts', this.getDBProperty('hosts') || []);
+    this.set('content.hosts', this.getDBProperty('hosts') || {});
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/main/host/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/add_controller.js b/ambari-web/app/controllers/main/host/add_controller.js
index 54305ba..86bba2d 100644
--- a/ambari-web/app/controllers/main/host/add_controller.js
+++ b/ambari-web/app/controllers/main/host/add_controller.js
@@ -54,8 +54,7 @@ App.AddHostController = App.WizardController.extend({
     advancedServiceConfig: null,
     controllerName: 'addHostController',
     serviceConfigGroups: null,
-    configGroups: null,
-    installedHosts: null
+    configGroups: null
   }),
 
   /**
@@ -159,13 +158,15 @@ App.AddHostController = App.WizardController.extend({
     var clients = [];
     var serviceComponents = App.StackServiceComponent.find();
     var clientComponents = [];
-    var installedHosts = this.get('content.installedHosts');
+    var hosts = this.get('content.hosts');
 
-    installedHosts.forEach(function (host) {
-      host.hostComponents.forEach(function (componentName) {
-        clientComponents[componentName] = true;
-      }, this);
-    });
+    for (var hostName in hosts) {
+      if(hosts[hostName].isInstalled) {
+        hosts[hostName].hostComponents.forEach(function (component) {
+          clientComponents[component.HostRoles.component_name] = true;
+        }, this);
+      }
+    }
 
     this.get('content.services').filterProperty('isSelected').forEach(function (_service)
{
       var client = serviceComponents.filterProperty('serviceName', _service.serviceName).findProperty('isClient');
@@ -347,7 +348,6 @@ App.AddHostController = App.WizardController.extend({
       case '2':
         this.loadServices();
       case '1':
-        this.load('installedHosts');
         this.load('hosts');
         this.load('installOptions');
         this.load('cluster');

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/main/service/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js
index 441e20b..5d1cf1e 100644
--- a/ambari-web/app/controllers/main/service/add_controller.js
+++ b/ambari-web/app/controllers/main/service/add_controller.js
@@ -73,19 +73,6 @@ App.AddServiceController = App.WizardController.extend({
   },
 
   /**
-   * Load confirmed hosts.
-   * Will be used at <code>Assign Masters(step5)</code> step
-   */
-  loadConfirmedHosts: function () {
-    var hosts = this.getDBProperty('hosts');
-
-    if (hosts) {
-      this.set('content.hosts', hosts);
-    }
-    console.log('AddServiceController.loadConfirmedHosts: loaded hosts', hosts);
-  },
-
-  /**
    * Load services data from server.
    */
   loadServicesFromServer: function() {
@@ -243,7 +230,7 @@ App.AddServiceController = App.WizardController.extend({
     var selectedServices = this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName');
     var installedComponentsMap = {};
     var uninstalledComponents = [];
-    var installedHosts = this.get('content.hosts');
+    var hosts = this.get('content.hosts');
 
     components.forEach(function (component) {
       if (installedServices.contains(component.get('serviceName'))) {
@@ -254,12 +241,14 @@ App.AddServiceController = App.WizardController.extend({
     }, this);
     installedComponentsMap['HDFS_CLIENT'] = [];
 
-    for (var hostName in installedHosts) {
-      installedHosts[hostName].hostComponents.forEach(function (componentName) {
-        if (installedComponentsMap[componentName]) {
-          installedComponentsMap[componentName].push(hostName);
-        }
-      });
+    for (var hostName in hosts) {
+      if (hosts[hostName].isInstalled) {
+        hosts[hostName].hostComponents.forEach(function (component) {
+          if (installedComponentsMap[component.HostRoles.component_name]) {
+            installedComponentsMap[component.HostRoles.component_name].push(hostName);
+          }
+        }, this);
+      }
     }
 
     for (var componentName in installedComponentsMap) {
@@ -305,8 +294,8 @@ App.AddServiceController = App.WizardController.extend({
     var dbHosts = this.get('content.hosts');
 
     for (var hostName in dbHosts) {
-      dbHosts[hostName].hostComponents.forEach(function (componentName) {
-        clientComponents[componentName] = true;
+      dbHosts[hostName].hostComponents.forEach(function (component) {
+        clientComponents[component.HostRoles.component_name] = true;
       }, this);
     }
 
@@ -346,7 +335,7 @@ App.AddServiceController = App.WizardController.extend({
         this.loadSlaveComponentHosts();//depends on loadServices
       case '2':
         this.loadMasterComponentHosts();
-        this.loadConfirmedHosts();
+        this.load('hosts');
       case '1':
         this.loadServices();
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 21a0f3d..2914fad 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -264,8 +264,8 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
     var installOptions = jQuery.extend({}, this.get('installOptionsTemplate'));
     this.set('content.installOptions', installOptions);
     this.setDBProperty('installOptions', installOptions);
-    this.set('content.hosts', []);
-    this.setDBProperty('hosts', []);
+    this.set('content.hosts', {});
+    this.setDBProperty('hosts', {});
   },
 
   toObject: function (object) {
@@ -611,10 +611,18 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * @param stepController App.WizardStep3Controller
    */
   saveConfirmedHosts: function (stepController) {
-    var hostInfo = {};
-    stepController.get('content.hosts').forEach(function (_host) {
+    var hosts = this.get('content.hosts');
+
+    //add previously installed hosts
+    for (var hostName in hosts) {
+      if (!hosts[hostName].isInstalled) {
+        delete hosts[hostName];
+      }
+    }
+
+    stepController.get('confirmedHosts').forEach(function (_host) {
       if (_host.bootStatus == 'REGISTERED') {
-        hostInfo[_host.name] = {
+        hosts[_host.name] = {
           name: _host.name,
           cpu: _host.cpu,
           memory: _host.memory,
@@ -627,9 +635,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
         };
       }
     });
-    console.log('wizardController:saveConfirmedHosts: save hosts ', hostInfo);
-    this.setDBProperty('hosts', hostInfo);
-    this.set('content.hosts', hostInfo);
+    console.log('wizardController:saveConfirmedHosts: save hosts ', hosts);
+    this.setDBProperty('hosts', hosts);
+    this.set('content.hosts', hosts);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js b/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js
index 617de40..c948b1f 100644
--- a/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js
@@ -95,7 +95,7 @@ App.StackUpgradeStep3Controller = Em.Controller.extend({
   /**
    * load hosts for each process
    */
-  loadHosts: function () {
+  loadHosts: function () {//TODO replace App.Host.find() with content.hosts loaded directly
from server
     var hosts = [];
     var installedHosts = App.Host.find();
     this.get('processes').forEach(function(process){

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/wizard/step2_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step2_controller.js b/ambari-web/app/controllers/wizard/step2_controller.js
index 53153b5..a7ecdec 100644
--- a/ambari-web/app/controllers/wizard/step2_controller.js
+++ b/ambari-web/app/controllers/wizard/step2_controller.js
@@ -144,12 +144,16 @@ App.WizardStep2Controller = Em.Controller.extend({
   }.property('hostsError', 'sshKeyError', 'sshUserError'),
 
   installedHostNames: function () {
-    if (this.get('content.controllerName') === 'addHostController') {
-      return this.get('content.installedHosts').mapProperty('name');
-    } else {
-      return [];
+    var installedHostsName = [];
+    var hosts = this.get('content.hosts');
+
+    for (var hostName in hosts) {
+      if (hosts[hostName].isInstalled) {
+        installedHostsName.push(hostName);
+      }
     }
-  }.property('content.controllerName'),
+    return installedHostsName;
+  }.property('content.hosts'),
 
   /**
    * Set not installed hosts to the hostNameArr
@@ -226,7 +230,8 @@ App.WizardStep2Controller = Em.Controller.extend({
       hostInfo[hostNameArr[i]] = {
         name: hostNameArr[i],
         installType: this.get('installType'),
-        bootStatus: 'PENDING'
+        bootStatus: 'PENDING',
+        isInstalled: false
       };
     }
 
@@ -512,7 +517,16 @@ App.WizardStep2Controller = Em.Controller.extend({
    * @method saveHosts
    */
   saveHosts: function () {
-    this.set('content.hosts', this.getHostInfo());
+    var hosts = this.get('content.hosts');
+
+    //add previously installed hosts
+    for (var hostName in hosts) {
+      if (!hosts[hostName].isInstalled) {
+        delete hosts[hostName];
+      }
+    }
+
+    this.set('content.hosts', $.extend(hosts, this.getHostInfo()));
     this.setAmbariJavaHome();
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/wizard/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js
index 5fa1c8d..5e12f52 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/step3_controller.js
@@ -96,8 +96,16 @@ App.WizardStep3Controller = Em.Controller.extend({
    * @type {string[]}
    */
   hostsInCluster: function () {
-    return this.get('content.installedHosts').getEach('name');
-  }.property('content.installedHosts'),
+    var installedHostsName = [];
+    var hosts = this.get('content.hosts');
+
+    for (var hostName in hosts) {
+      if (hosts[hostName].isInstalled) {
+        installedHostsName.push(hostName);
+      }
+    }
+    return installedHostsName;
+  }.property('content.hosts'),
 
   /**
    * All hosts warnings
@@ -218,7 +226,7 @@ App.WizardStep3Controller = Em.Controller.extend({
     }
 
     for (var index in hostsInfo) {
-      if (hostsInfo.hasOwnProperty(index)) {
+      if (hostsInfo.hasOwnProperty(index) && !hostsInfo[index].isInstalled) {
         hosts.pushObject(App.HostInfo.create({
           name: hostsInfo[index].name,
           bootStatus: bootStatus,
@@ -1148,17 +1156,18 @@ App.WizardStep3Controller = Em.Controller.extend({
    * @method submit
    */
   submit: function () {
+    var self = this;
+
     if (this.get('isHostHaveWarnings')) {
-      var self = this;
       return App.showConfirmationPopup(
         function () {
-          self.set('content.hosts', self.get('bootHosts'));
+          self.set('confirmedHosts', self.get('bootHosts'));
           App.router.send('next');
         },
         Em.I18n.t('installer.step3.hostWarningsPopup.hostHasWarnings'));
     }
     else {
-      this.set('content.hosts', this.get('bootHosts'));
+      this.set('confirmedHosts', this.get('bootHosts'));
       App.router.send('next');
     }
     return null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/wizard/step5_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step5_controller.js b/ambari-web/app/controllers/wizard/step5_controller.js
index 0f6a79a..5d1137f 100644
--- a/ambari-web/app/controllers/wizard/step5_controller.js
+++ b/ambari-web/app/controllers/wizard/step5_controller.js
@@ -277,7 +277,6 @@ App.WizardStep5Controller = Em.Controller.extend({
    * @method renderHostInfo
    */
   renderHostInfo: function () {
-
     var hostInfo = this.get('content.hosts');
     var result = [];
 
@@ -286,7 +285,6 @@ App.WizardStep5Controller = Em.Controller.extend({
       if (_host.bootStatus === 'REGISTERED') {
         result.push(Em.Object.create({
           host_name: _host.name,
-
           cpu: _host.cpu,
           memory: _host.memory,
           disk_info: _host.disk_info,

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/wizard/step6_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step6_controller.js b/ambari-web/app/controllers/wizard/step6_controller.js
index e11c63e..85800fb 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -332,10 +332,15 @@ App.WizardStep6Controller = Em.Controller.extend({
   getHostNames: function () {
     var hostInfo = this.get('content.hosts');
     var hostNames = [];
+    //flag identify whether get all hosts or only uninstalled(newly added) hosts
+    var getUninstalledHosts = (this.get('content.controllerName') !== 'addServiceController');
+
     for (var index in hostInfo) {
       if (hostInfo.hasOwnProperty(index)) {
         if (hostInfo[index].bootStatus === 'REGISTERED') {
-          hostNames.push(hostInfo[index].name);
+          if(!getUninstalledHosts || !hostInfo[index].isInstalled) {
+            hostNames.push(hostInfo[index].name);
+          }
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 7d03066..6ae3fb8 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -30,11 +30,6 @@ App.WizardStep8Controller = Em.Controller.extend({
   rawContent: require('data/review_configs'),
 
   /**
-   * @type {Object[]}
-   */
-  totalHosts: [],
-
-  /**
    * List of data about cluster (based on formatted <code>rawContent</code>)
    * @type {Object[]}
    */
@@ -553,22 +548,16 @@ App.WizardStep8Controller = Em.Controller.extend({
     this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
 
     //hosts
-    var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
-    var slaveHosts = this.get('content.slaveComponentHosts');
-
-    var hostObj = [];
-    slaveHosts.forEach(function (_hosts) {
-      hostObj = hostObj.concat(_hosts.hosts);
-    }, this);
-
-    slaveHosts = hostObj.mapProperty('hostName').uniq();
+    var newHostsCount = 0;
+    var totalHostsCount = 0;
+    var hosts = this.get('content.hosts');
+    for (var hostName in hosts) {
+      newHostsCount += ~~(!hosts[hostName].isInstalled);
+      totalHostsCount++;
+    }
 
-    var componentHosts = masterHosts.concat(slaveHosts).uniq();
-    var totalHosts = App.Host.find().mapProperty('hostName').concat(componentHosts).uniq();
-    var newHostsCount = totalHosts.length - App.Host.find().content.length;
-    this.set('totalHosts', totalHosts);
     var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
-    totalHostsObj.config_value = totalHosts.length + ' (' + newHostsCount + ' new)';
+    totalHostsObj.config_value = totalHostsCount + ' (' + newHostsCount + ' new)';
     this.get('clusterInfo').pushObject(Em.Object.create(totalHostsObj));
 
     //repo

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/views/main/host/add_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/add_view.js b/ambari-web/app/views/main/host/add_view.js
index 84a4311..0faeb76 100644
--- a/ambari-web/app/views/main/host/add_view.js
+++ b/ambari-web/app/views/main/host/add_view.js
@@ -72,21 +72,21 @@ App.AddHostView = Em.View.extend({
   },
 
   loadHostsSuccessCallback: function (response) {
-    var installedHosts = [];
+    var installedHosts = {};
 
     response.items.forEach(function (item) {
-      installedHosts.push({
+      installedHosts[item.Hosts.host_name] = {
         name: item.Hosts.host_name,
         cpu: item.Hosts.cpu_count,
         memory: item.Hosts.total_mem,
         disk_info: item.Hosts.disk_info,
         bootStatus: "REGISTERED",
         isInstalled: true,
-        hostComponents: item.host_components.mapProperty('HostRoles.component_name')
-      });
+        hostComponents: item.host_components
+      };
     });
-    this.get('controller').setDBProperty('installedHosts', installedHosts);
-    this.set('controller.content.installedHosts', installedHosts);
+    this.get('controller').setDBProperty('hosts', installedHosts);
+    this.set('controller.content.hosts', installedHosts);
     this.set('isLoaded', true);
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a9dddee/ambari-web/app/views/main/service/add_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/add_view.js b/ambari-web/app/views/main/service/add_view.js
index 82042db..da659aa 100644
--- a/ambari-web/app/views/main/service/add_view.js
+++ b/ambari-web/app/views/main/service/add_view.js
@@ -75,21 +75,21 @@ App.AddServiceView = Em.View.extend({
   },
 
   loadHostsSuccessCallback: function (response) {
-    var hosts = {};
+    var installedHosts = {};
 
     response.items.forEach(function (item) {
-      hosts[item.Hosts.host_name] = {
+      installedHosts[item.Hosts.host_name] = {
         name: item.Hosts.host_name,
         cpu: item.Hosts.cpu_count,
         memory: item.Hosts.total_mem,
         disk_info: item.Hosts.disk_info,
         bootStatus: "REGISTERED",
         isInstalled: true,
-        hostComponents: item.host_components.mapProperty('HostRoles.component_name')
+        hostComponents: item.host_components
       };
     });
-    this.get('controller').setDBProperty('hosts', hosts);
-    this.set('controller.content.hosts', hosts);
+    this.get('controller').setDBProperty('hosts', installedHosts);
+    this.set('controller.content.hosts', installedHosts);
     this.set('isLoaded', true);
   },
 


Mime
View raw message