Преглед изворни кода

AMBARI-4841 Incorrect behavior of HA wizard on second step. (atkach)

atkach пре 11 година
родитељ
комит
1aeb5aa1ce

+ 7 - 3
ambari-web/app/controllers/main/admin/highAvailability/step2_controller.js

@@ -24,6 +24,11 @@ App.HighAvailabilityWizardStep2Controller = App.WizardStep5Controller.extend({
 
   name:"highAvailabilityWizardStep2Controller",
 
+  /**
+   * master components which could be assigned to multiple hosts
+   */
+  multipleComponents: ['NAMENODE', 'JOURNALNODE'],
+
   /**
    * Load services info to appropriate variable and return masterComponentHosts
    * @return Array
@@ -42,12 +47,12 @@ App.HighAvailabilityWizardStep2Controller = App.WizardStep5Controller.extend({
 
       var masterServices = self.get("selectedServicesMasters").filterProperty("selectedHost", item);
       masterServices.forEach(function(item){
-        if(item.component_name == "NAMENODE" || item.component_name == "JOURNALNODE"){
+        if(this.get('multipleComponents').contains(item.component_name)){
           item.set('color','green');
         }else{
           item.set('color','grey');
         }
-      });
+      }, this);
 
       mappingObject = Ember.Object.create({
         host_name:item,
@@ -108,7 +113,6 @@ App.HighAvailabilityWizardStep2Controller = App.WizardStep5Controller.extend({
 
     masterComponents.forEach(function (item) {
       var componentObj = Ember.Object.create(item);
-      componentObj.set("availableHosts", this.get("hosts"));
       result.push(componentObj);
     }, this);
 

+ 5 - 2
ambari-web/app/controllers/wizard/step5_controller.js

@@ -40,7 +40,10 @@ App.WizardStep5Controller = Em.Controller.extend({
   isReassignHive: function () {
     return this.get('servicesMasters').objectAt(0) && this.get('servicesMasters').objectAt(0).component_name == 'HIVE_SERVER' && this.get('isReassignWizard');
   }.property('isReassignWizard', 'servicesMasters'),
-
+  /**
+   * master components which could be assigned to multiple hosts
+   */
+  multipleComponents: ['ZOOKEEPER_SERVER', 'HBASE_MASTER'],
   /**
    * Define state for submit button. Return true only for Reassign Master Wizard and if more than one master component was reassigned.
    */
@@ -169,7 +172,7 @@ App.WizardStep5Controller = Em.Controller.extend({
       var componentInfo = masterComponents.filterProperty('service_name', services[index]);
 
       componentInfo.forEach(function (_componentInfo) {
-        if (_componentInfo.component_name == 'ZOOKEEPER_SERVER' || _componentInfo.component_name == 'HBASE_MASTER') {
+        if (this.get('multipleComponents').contains(_componentInfo.component_name)) {
           var savedComponents = masterHosts.filterProperty('component', _componentInfo.component_name);
           if (savedComponents.length) {
 

+ 2 - 0
ambari-web/app/messages.js

@@ -185,6 +185,8 @@ Em.I18n.translations = {
   'common.url': 'URL',
   'common.advanced': 'Advanced',
   'common.download': 'Download',
+  'common.current': 'Current',
+  'common.additional': 'Additional',
   'common.time.start': 'Start Time',
   'common.time.end': 'End Time',
   'common.hostLog.popup.logDir.path':'/var/lib/ambari-agent/data/',

+ 2 - 3
ambari-web/app/templates/main/admin/highAvailability/step2.hbs

@@ -28,16 +28,15 @@
       <div class="control-group">
         <label class="control-label">
           {{#if isCurNameNode}}
-          Current
+            {{t common.current}}
           {{/if}}
           {{#if isAddNameNode}}
-          Additional
+            {{t common.additional}}
           {{/if}}
           {{display_name}}:
         </label>
         <div class="controls">
           {{view App.SelectHostView
-            contentBinding="availableHosts"
             optionValuePath="content.host_name"
             optionLabelPath="content.host_info"
             selectedHostBinding="selectedHost"

+ 4 - 2
ambari-web/app/views/wizard/step5_view.js

@@ -43,6 +43,7 @@ App.SelectHostView = Em.Select.extend({
 
   change: function () {
     this.get('controller').assignHostToMaster(this.get("componentName"), this.get("value"), this.get("zId"));
+    this.set('selectedHost', this.get('value'));
     this.get('controller').set('componentToRebalance', this.get("componentName"));
     this.get('controller').incrementProperty('rebalanceComponentHostsCounter');
   },
@@ -60,17 +61,18 @@ App.SelectHostView = Em.Select.extend({
 
   /**
    * get available hosts
-   * Since ZOOKEEPER_SERVER or HBASE_MASTER component can be assigned to multiple hosts,
+   * @multipleComponents component can be assigned to multiple hosts,
    * shared hosts among the same component should be filtered out
    * @return {*}
    */
   getAvailableHosts: function () {
     var hosts = this.get('controller.hosts').slice();
     var componentName = this.get('componentName');
+    var multipleComponents = this.get('controller.multipleComponents');
     var occupiedHosts = this.get('controller.selectedServicesMasters')
       .filterProperty('component_name', componentName)
       .mapProperty('selectedHost').without(this.get('selectedHost'));
-    if (componentName == 'ZOOKEEPER_SERVER' || componentName == 'HBASE_MASTER') {
+    if (multipleComponents.contains(componentName)) {
       return hosts.filter(function (host) {
         return !occupiedHosts.contains(host.get('host_name'));
       }, this);