ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-15997. After HSI is enabled in install wizard the validation call does not send HSI in the component list of the host_group resulting in validation errors. (jaimin)
Date Thu, 21 Apr 2016 22:57:19 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d408e2c80 -> 1c7a284b2


AMBARI-15997. After HSI is enabled in install wizard the validation call does not send HSI
in the component list of the host_group resulting in validation errors. (jaimin)


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

Branch: refs/heads/trunk
Commit: 1c7a284b2f2747670cd8d68292f29930312d3fc1
Parents: d408e2c
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Thu Apr 21 15:56:19 2016 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Thu Apr 21 15:56:29 2016 -0700

----------------------------------------------------------------------
 ambari-web/app/app.js                           |  15 +++
 ambari-web/app/controllers/installer.js         |   3 +-
 .../controllers/main/service/info/configs.js    |   2 +
 ambari-web/app/controllers/main/service/item.js |   2 +-
 .../app/controllers/wizard/step6_controller.js  |   2 +-
 .../wizard/step7/assign_master_controller.js    | 123 +++++++++++++++++--
 ambari-web/app/mixins/common/serverValidator.js |   2 +-
 ambari-web/app/utils/blueprint.js               |  34 +++--
 .../configs/widgets/config_widget_view.js       |   2 +
 .../step7/assign_master_controller_test.js      |  22 ++--
 10 files changed, 181 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index 5fa4448..ac45874 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -187,6 +187,21 @@ module.exports = Em.Application.create({
 
   allHostNames: [],
 
+  /**
+   * This object is populated to keep track of uninstalled components to be included in the
layout for recommendation/validation call
+   * @type {object}
+   * keys = componentName, hostName
+   */
+  componentToBeAdded: {},
+
+
+  /**
+   * This object is populated to keep track of installed components to be excluded in the
layout for recommendation/validation call
+   * @type {object}
+   * keys = componentName, hostName
+   */
+  componentToBeDeleted: {},
+
   uiOnlyConfigDerivedFromTheme: [],
 
   currentStackVersionNumber: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index 9c92282..73f9801 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -46,7 +46,8 @@ App.InstallerController = App.WizardController.extend({
      */
     recommendations: null,
     /**
-     * recommendationsHostGroups - current component assignment after 5 and 6 steps
+     * recommendationsHostGroups - current component assignment after 5 and 6 steps, 
+     * or adding hiveserver2 interactive on "configure services" page
      * (uses for host groups validation and to load recommended configs)
      */
     recommendationsHostGroups: null,

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index b589040..b6e6c21 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -243,6 +243,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader,
A
       }
     });
     this.get('requestsInProgress').clear();
+    App.set('componentToBeAdded', {});
+    App.set('componentToBeDeleted', {});
     this.clearLoadInfo();
     this.clearSaveInfo();
     this.clearRecommendationsInfo();

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index b1ea523..4c772a3 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -1287,7 +1287,7 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
   hostGroups: function() {
     var hostGroup = blueprintUtils.generateHostGroups(App.get('allHostNames'));
     return blueprintUtils.removeDeletedComponents(hostGroup, [this.get('serviceNamesToDelete')]);
-  }.property('serviceNamesToDelete', 'App.allHostNames'),
+  }.property('serviceNamesToDelete', 'App.allHostNames', 'App.componentToBeAdded', 'App.componentToBeDeleted'),
 
   /**
    * List of services without removed

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/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 ff8f36a..3adc636 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -605,7 +605,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
       masterBlueprint = self.getCurrentMasterSlaveBlueprint();
       hostNames = hostNames.concat(App.Host.find().mapProperty("hostName")).uniq();
       slaveBlueprint = blueprintUtils.addComponentsToBlueprint(slaveBlueprint, invisibleSlavesAndClients);
-      }
+    }
 
     var bluePrintsForValidation = blueprintUtils.mergeBlueprints(masterBlueprint, slaveBlueprint);
     this.set('content.recommendationsHostGroups', bluePrintsForValidation);

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
index 196932d..d68fa8e 100644
--- a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
+++ b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
@@ -53,7 +53,6 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
     this.set('configWidgetContext', context);
     this.set('content', context.get('controller.content'));
     this.set('configActionComponent', hostComponent);
-    this.set('mastersToCreate', [hostComponent.componentName]);
     var missingDependentServices = this.getAllMissingDependentServices();
     var isNonWizardPage = !this.get('content.controllerName');
     switch (action) {
@@ -61,10 +60,12 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
         if (missingDependentServices.length && isNonWizardPage) {
           this.showInstallServicesPopup(missingDependentServices);
         } else {
+          this.set('mastersToCreate', [hostComponent.componentName]);
           this.showAssignComponentPopup();
         }
         break;
       case 'DELETE':
+        this.set('mastersToCreate', [hostComponent.componentName]);
         this.removeMasterComponent();
         break;
     }
@@ -139,11 +140,25 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
     if (this.get('content.controllerName')) {
       var parentController = App.router.get(this.get('content.controllerName'));
       var masterComponentHosts = this.get('content.masterComponentHosts');
+      var recommendationsHostGroups = this.get('content.recommendationsHostGroups');
       componentsToDelete.forEach(function (_componentName) {
         masterComponentHosts = masterComponentHosts.rejectProperty('component', _componentName);
+        recommendationsHostGroups.blueprint.host_groups.forEach(function(hostGroup){
+          hostGroup.components = hostGroup.components.rejectProperty('name', _componentName);
+        }, this);
       }, this);
       this.get('content').set('masterComponentHosts', masterComponentHosts);
       parentController.setDBProperty('masterComponentHosts', masterComponentHosts);
+      parentController.setDBProperty('recommendationsHostGroups', recommendationsHostGroups);
+    } else {
+      this.clearComponentsToBeAdded(componentsToDelete[0]);
+      var hostComponent = App.HostComponent.find().findProperty('componentName', componentsToDelete[0]);
+      if (hostComponent) {
+        App.set('componentToBeDeleted', Em.Object.create({
+          componentName: componentsToDelete[0],
+          hostName: hostComponent.get('hostName')
+        }));
+      }
     }
     var configActionComponent = this.get('configActionComponent');
     this.get('configWidgetContext.config').set('configActionComponent', configActionComponent);
@@ -218,6 +233,98 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
     });
   },
 
+  /**
+   * This method saves masterComponent layout that is used on subsequent "Review" and "Install
start and Test services" pages.
+   * @private
+   * @method {saveMasterComponentHosts}
+   */
+  saveMasterComponentHosts: function() {
+    var controller = App.router.get(this.get('content.controllerName'));
+    controller.saveMasterComponentHosts(this);
+  },
+
+  /**
+   * This method saves host group layout that is used for blueprint validation call made
while transitioning to "Review" page.
+   * @private
+   * @method {saveRecommendationsHostGroups}
+   */
+  saveRecommendationsHostGroups: function() {
+    var controller = App.router.get(this.get('content.controllerName'));
+    var recommendationsHostGroups = this.get('content.recommendationsHostGroups');
+    var masterComponentHosts = this.get('content.masterComponentHosts');
+    var mastersToCreate = this.get('mastersToCreate');
+    mastersToCreate.forEach(function(componentName) {
+      var hostName = this.getSelectedHostName(componentName);
+      if (hostName && recommendationsHostGroups) {
+        var hostGroups = recommendationsHostGroups.blueprint_cluster_binding.host_groups;
+        var isHostPresent = false;
+        var i = 0;
+        while (i < hostGroups.length) {
+          var hosts = hostGroups[i].hosts;
+          isHostPresent =  hosts.someProperty('fqdn', hostName);
+          if (isHostPresent) break;
+          i++;
+        }
+        if (isHostPresent) {
+          var hostGroupName = hostGroups[i].name;
+          var hostGroup =  recommendationsHostGroups.blueprint.host_groups.findProperty('name',
hostGroupName);
+          var addHostComponentInGroup =  !hostGroup.components.someProperty('name', componentName);
+          if (addHostComponentInGroup) {
+            hostGroup.components.pushObject({name: componentName});
+          }
+        }
+      }
+    }, this);
+    controller.setDBProperty('recommendationsHostGroups', recommendationsHostGroups);
+  },
+
+  /**
+   * Get the fqdn hostname as selected by the user for the component.
+   * @param componentName
+   * @return {String}
+   */
+  getSelectedHostName: function(componentName) {
+    var selectedServicesMasters = this.get('selectedServicesMasters');
+    return selectedServicesMasters.findProperty('component_name', componentName).selectedHost;
+  },
+
+  /**
+   * set App.componentToBeAdded to use it on subsequent validation call while saving configuration
+   * @param componentName {String}
+   * @param hostName {String}
+   * @method {setGlobalComponentToBeAdded}
+   */
+  setGlobalComponentToBeAdded: function(componentName, hostName) {
+    var componentToBeAdded = Em.Object.create({
+       componentName: componentName,
+       hostNames: [hostName]
+    });
+    App.set('componentToBeAdded', componentToBeAdded);
+  },
+
+  /**
+   * clear 'componentToBeDeleted' object
+   * @param componentName {String}
+   * @public
+   * @method {clearComponentsToBeDeleted}
+   */
+  clearComponentsToBeDeleted: function(componentName) {
+    var componentsToBeDeleted = App.get('componentToBeDeleted');
+    if (!App.isEmptyObject(componentsToBeDeleted) && componentsToBeDeleted.get('componentName')
=== componentName) {
+      App.set('componentToBeDeleted', {});
+    }
+  },
+
+  /**
+   * clear 'componentToBeAdded' object
+   * @param componentName  {String}
+   */
+  clearComponentsToBeAdded: function(componentName) {
+    var componentsToBeAdded = App.get('componentToBeAdded');
+    if (!App.isEmptyObject(componentsToBeAdded) && componentsToBeAdded.get('componentName')
=== componentName) {
+      App.set('componentToBeAdded', {});
+    }
+  },
 
   /**
    * Submit button click handler
@@ -225,14 +332,16 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin,
App
    */
   submit: function () {
     this.get('popup').hide();
-    if (this.get('content.controllerName')) {
-      var controller = App.router.get(this.get('content.controllerName'));
-      controller.saveMasterComponentHosts(this);
-    }
-    var selectedServicesMasters = this.get('selectedServicesMasters');
     var context = this.get('configWidgetContext');
     var configActionComponent = this.get('configActionComponent');
-    var componentHostName = selectedServicesMasters.findProperty('component_name', configActionComponent.componentName).selectedHost;
+    var componentHostName = this.getSelectedHostName(configActionComponent.componentName);
+    if (this.get('content.controllerName')) {
+      this.saveMasterComponentHosts();
+      this.saveRecommendationsHostGroups();
+    } else {
+      this.setGlobalComponentToBeAdded(configActionComponent.componentName, componentHostName);
+      this.clearComponentsToBeDeleted(configActionComponent.componentName);
+    }
 
     var hostComponentConfig = context.get('config.configAction.hostComponentConfig');
     var serviceConfigs = context.get('controller.stepConfigs').findProperty('serviceName',
context.get('config.serviceName')).get('configs');

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/app/mixins/common/serverValidator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/serverValidator.js b/ambari-web/app/mixins/common/serverValidator.js
index a2e1d09..3f40424 100644
--- a/ambari-web/app/mixins/common/serverValidator.js
+++ b/ambari-web/app/mixins/common/serverValidator.js
@@ -94,7 +94,7 @@ App.ServerValidatorMixin = Em.Mixin.create({
    */
   hostGroups: function() {
     return this.get('content.recommendationsHostGroups') || blueprintUtils.generateHostGroups(App.get('allHostNames'));
-  }.property('content.recommendationsHostGroups', 'App.allHostNames'),
+  }.property('content.recommendationsHostGroups', 'App.allHostNames', 'App.componentToBeAdded',
'App.componentToBeDeleted'),
 
   /**
    * controller that is child of this mixin has to contain stepConfigs

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/app/utils/blueprint.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/blueprint.js b/ambari-web/app/utils/blueprint.js
index 30e69af..ca9a3e2 100644
--- a/ambari-web/app/utils/blueprint.js
+++ b/ambari-web/app/utils/blueprint.js
@@ -423,15 +423,33 @@ module.exports = {
    */
   getComponentForHosts: function() {
     var hostsMap = {};
-    App.ClientComponent.find().forEach(function(c) {
-      hostsMap = this._generateHostMap(hostsMap, c.get('hostNames'), c.get('componentName'));
-    }, this);
-    App.SlaveComponent.find().forEach(function (c) {
-      hostsMap = this._generateHostMap(hostsMap, c.get('hostNames'), c.get('componentName'));
-    }, this);
-    App.MasterComponent.find().forEach(function (c) {
-      hostsMap = this._generateHostMap(hostsMap, c.get('hostNames'), c.get('componentName'));
+    var componentModels = [App.ClientComponent, App.SlaveComponent, App.MasterComponent];
+    componentModels.forEach(function(_model){
+      _model.find().forEach(function(c) {
+        hostsMap = this._generateHostMap(hostsMap, c.get('hostNames'), c.get('componentName'));
+      }, this);  
     }, this);
+
+    this.changeHostsMapForConfigActions(hostsMap);
     return hostsMap;
+  },
+
+  /**
+   * Adds or removes the component name entry as saved in App.componentToBeAdded and App.componentToBeDeleted
from the 'hostsMap'
+   * @param hostsMap {object}
+   * @private
+   * @method {changeHostsMapForConfigActions}
+   */
+  changeHostsMapForConfigActions: function(hostsMap) {
+    var componentToBeAdded =  App.get('componentToBeAdded');
+    var componentToBeDeleted =  App.get('componentToBeDeleted');
+    if (!App.isEmptyObject(componentToBeAdded)) {
+      hostsMap = this._generateHostMap(hostsMap, componentToBeAdded.get('hostNames'), componentToBeAdded.get('componentName'));
+    } else if (!App.isEmptyObject(componentToBeDeleted) && hostsMap[componentToBeDeleted.hostName])
{
+      var index = hostsMap[componentToBeDeleted.hostName].indexOf(componentToBeDeleted.componentName);
+      if (index > -1) {
+        hostsMap[componentToBeDeleted.hostName].splice(index, 1);
+      }
+    }
   }
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/config_widget_view.js b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
index 1078386..817643a 100644
--- a/ambari-web/app/views/common/configs/widgets/config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
@@ -468,6 +468,8 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo
         if (isComponentToBeInstalled) {
           this.set('controller.saveInProgress', true);
           assignMasterOnStep7Controller.execute(this, 'ADD', hostComponent);
+        } else {
+          assignMasterOnStep7Controller.clearComponentsToBeDeleted(hostComponent.componentName);
         }
         break;
       case 'delete':

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c7a284b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
index 2d467c2..0bc1c05 100644
--- a/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
+++ b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
@@ -194,7 +194,11 @@ describe('App.AssignMasterOnStep7Controller', function () {
           masterComponentHosts: [
             {component: 'C1'},
             {component: 'C2'}
-          ]
+          ],
+          recommendationsHostGroups: {
+            blueprint: {host_groups: [{name: 'host-group-1', components: [{name: 'C1'}, {name:
'C2'}]}]},
+            blueprint_cluster_binding: {host_groups: [{name: 'host-group-1', hosts: [{fqdn:
'localhost'}]}]}
+          }
         }),
         configWidgetContext: {
           config: Em.Object.create()
@@ -203,6 +207,7 @@ describe('App.AssignMasterOnStep7Controller', function () {
       view.set('mastersToCreate', ['C2']);
       view.removeMasterComponent();
       expect(view.get('content.masterComponentHosts')).to.be.eql([{component: 'C1'}]);
+      expect(view.get('content.recommendationsHostGroups').blueprint).to.be.eql({host_groups:
[{name: 'host-group-1', components: [{name: 'C1'}]}]});
       expect(mock.setDBProperty.calledWith('masterComponentHosts', [{component: 'C1'}])).to.be.true;
     });
   });
@@ -311,8 +316,9 @@ describe('App.AssignMasterOnStep7Controller', function () {
     var popup = {
       hide: Em.K
       },
-      router = {
-        saveMasterComponentHosts: Em.K
+      mock = {
+        saveMasterComponentHosts: Em.K,
+        setDBProperty: Em.K
       },
       config = Em.Object.create({
         filename: 'file1',
@@ -321,8 +327,9 @@ describe('App.AssignMasterOnStep7Controller', function () {
 
     beforeEach(function() {
       sinon.stub(popup, 'hide');
-      sinon.stub(App.router, 'get').returns(router);
-      sinon.stub(router, 'saveMasterComponentHosts');
+      sinon.stub(App.router, 'get').returns(mock);
+      sinon.stub(mock, 'saveMasterComponentHosts');
+      sinon.stub(mock, 'setDBProperty');
       view.reopen({
         content: Em.Object.create({
           controllerName: 'ctrl1'
@@ -365,11 +372,12 @@ describe('App.AssignMasterOnStep7Controller', function () {
     afterEach(function() {
       App.router.get.restore();
       popup.hide.restore();
-      router.saveMasterComponentHosts.restore();
+      mock.saveMasterComponentHosts.restore();
+      mock.setDBProperty.restore();
     });
 
     it("saveMasterComponentHosts should be called", function() {
-      expect(router.saveMasterComponentHosts.calledOnce).to.be.true;
+      expect(mock.saveMasterComponentHosts.calledOnce).to.be.true;
     });
 
     it("configActionComponent should be set", function() {


Mime
View raw message