Explorar el Código

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

atkach hace 11 años
padre
commit
8a9dddee04

+ 1 - 2
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') || {});
   },
 
   /**

+ 9 - 9
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');

+ 12 - 23
ambari-web/app/controllers/main/service/add_controller.js

@@ -72,19 +72,6 @@ App.AddServiceController = App.WizardController.extend({
     return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
   },
 
-  /**
-   * 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.
    */
@@ -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();
     }

+ 16 - 8
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);
   },
 
   /**

+ 1 - 1
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){

+ 21 - 7
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();
   }
 

+ 15 - 6
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;

+ 0 - 2
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,

+ 6 - 1
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);
+          }
         }
       }
     }

+ 8 - 19
ambari-web/app/controllers/wizard/step8_controller.js

@@ -29,11 +29,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

+ 6 - 6
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);
   },
 

+ 5 - 5
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);
   },