Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 7bb1e3335 -> 70b4ba403


AMBARI-20516 create table failing with HiveAccessControlException (additional 
patch). (ababiichuk)


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

Branch: refs/heads/branch-2.5
Commit: 70b4ba403dd7e890d7fcc5964b1cd231ee6e98c0
Parents: 7bb1e33
Author: ababiichuk <[email protected]>
Authored: Thu Mar 23 19:46:05 2017 +0200
Committer: ababiichuk <[email protected]>
Committed: Thu Mar 23 19:46:05 2017 +0200

----------------------------------------------------------------------
 .../wizard/step7/assign_master_controller.js    | 116 +++++++++++++++++++
 .../app/models/configs/theme/config_action.js   |  35 +++++-
 .../configs/add_component_config_initializer.js |  12 +-
 .../utils/configs/move_hm_config_initializer.js |   2 +-
 .../utils/configs/move_hs_config_initializer.js |   2 +-
 .../step7/assign_master_controller_test.js      |  29 ++---
 6 files changed, 173 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/70b4ba40/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 580b761..e2c5fa6 100644
--- a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
+++ b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
@@ -18,6 +18,7 @@
 
 var stringUtils = require('utils/string_utils');
 var numberUtils = require('utils/number_utils');
+var blueprintUtils = require('utils/blueprint');
 
 App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin, 
App.AssignMasterComponents, {
 
@@ -392,9 +393,20 @@ App.AssignMasterOnStep7Controller = 
Em.Controller.extend(App.BlueprintMixin, App
       var componentHostName = 
self.getSelectedHostName(configActionComponent.componentName);
       var config = self.get('configWidgetContext.config');
       var oldValueKey = context.get('controller.wizardController.name') === 
'installerController' ? 'initialValue' : 'savedValue';
+
+      // TODO remove after stack advisor is able to handle this case
+      // workaround for hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive 
Server Interactive from Install Wizard
+      var serviceConfigs = 
context.get('controller.stepConfigs').findProperty('serviceName', 
context.get('controller.selectedService.serviceName')).get('configs');
+      var dependencies = context.get('config.configAction.dependencies');
+
       if (self.get('content.controllerName')) {
         self.saveMasterComponentHosts();
         self.saveRecommendationsHostGroups();
+
+        // TODO remove after stack advisor is able to handle this case
+        // workaround for hadoop.proxyuser.{{hiveUser}}.hosts after adding 
Hive Server Interactive from Install Wizard
+        var miscConfigs = 
context.get('controller.stepConfigs').findProperty('serviceName', 
'MISC').get('configs');
+        serviceConfigs = serviceConfigs.concat(miscConfigs);
       } else {
         self.setGlobalComponentToBeAdded(configActionComponent.componentName, 
componentHostName);
         self.clearComponentsToBeDeleted(configActionComponent.componentName);
@@ -402,11 +414,115 @@ App.AssignMasterOnStep7Controller = 
Em.Controller.extend(App.BlueprintMixin, App
 
       configActionComponent.hostName = componentHostName;
       config.set('configActionComponent', configActionComponent);
+      /* TODO uncomment after stack advisor is able to handle this case
       context.get('controller').loadConfigRecommendations([{
         type: App.config.getConfigTagFromFileName(config.get('fileName')),
         name: config.get('name'),
         old_value: config.get(oldValueKey)
       }]);
+      */
+
+      // TODO remove after stack advisor is able to handle this case
+      // workaround for hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive 
Server Interactive
+      if (dependencies) {
+        var foreignKeys = {};
+        if (dependencies.foreignKeys) {
+          dependencies.foreignKeys.forEach(function (dependency) {
+            var matchingProperty = serviceConfigs.find(function (property) {
+              return property.get('filename') === 
App.config.getOriginalFileName(dependency.fileName) && property.get('name') === 
dependency.propertyName;
+            });
+            if (matchingProperty) {
+              foreignKeys[dependency.key] = matchingProperty.get('value');
+            }
+          });
+        }
+        if (dependencies.properties && dependencies.initializer) {
+          var initializer = App.get(dependencies.initializer.name);
+          var setup = Em.getProperties(foreignKeys, 
dependencies.initializer.setupKeys);
+          initializer.setup(setup);
+          var blueprintObject = {};
+          dependencies.properties.forEach(function (property) {
+            var propertyObject = Em.getProperties(property, ['name', 
'fileName']);
+            if (property.nameTemplate) {
+              var name = property.nameTemplate;
+              Em.keys(foreignKeys).forEach(function (key) {
+                name = name.replace('{{' + key + '}}', foreignKeys[key]);
+              });
+              propertyObject.name = name;
+            }
+            if (!blueprintObject[property.fileName]) {
+              blueprintObject[property.fileName] = {
+                properties: {}
+              };
+            }
+            var masterComponents = [];
+            if (self.get('content.controllerName')) {
+              var savedMasterComponents = 
context.get('controller.content.masterComponentHosts').filter(function 
(componentObject) {
+                return 
dependencies.initializer.componentNames.contains(componentObject.component);
+              });
+              masterComponents = savedMasterComponents.map(function 
(componentObject) {
+                var masterComponent = Em.getProperties(componentObject, 
['component', 'hostName']);
+                masterComponent.isInstalled = true;
+                return masterComponent;
+              });
+            } else {
+              var hostsMap = blueprintUtils.getComponentForHosts();
+              Em.keys(hostsMap).forEach(function (hostName) {
+                hostsMap[hostName].forEach(function (componentName) {
+                  if 
(dependencies.initializer.componentNames.contains(componentName)) {
+                    masterComponents.push({
+                      component: componentName,
+                      hostName: hostName,
+                      isInstalled: true
+                    });
+                  }
+                });
+              });
+            }
+            var result = initializer.initialValue(propertyObject, {
+              masterComponentHosts: masterComponents
+            });
+            var propertiesMap = 
blueprintObject[propertyObject.fileName].properties;
+            propertiesMap[propertyObject.name] = result.value;
+            if (property.isHostsList) {
+              var service = 
App.config.get('serviceByConfigTypeMap')[propertyObject.fileName];
+              if (service) {
+                var serviceName = service.get('serviceName');
+                var configs = serviceName === 
context.get('controller.selectedService.serviceName') ? serviceConfigs :
+                  
context.get('controller.stepConfigs').findProperty('serviceName', 
serviceName).get('configs');
+                var originalFileName = 
App.config.getOriginalFileName(propertyObject.fileName);
+                var currentProperty = configs.find(function (configProperty) {
+                  return configProperty.get('filename') === originalFileName 
&& configProperty.get('name') === propertyObject.name;
+                });
+                if (currentProperty) {
+                  propertiesMap[propertyObject.name] = 
currentProperty.get('value');
+                  App.config.updateHostsListValue(propertiesMap, 
propertyObject.fileName, propertyObject.name, propertyObject.value, 
property.isHostsArray);
+                }
+              }
+            }
+            context.get('controller').loadRecommendationsSuccess({
+              resources: [
+                {
+                  recommendations: {
+                    blueprint: {
+                      configurations: blueprintObject
+                    }
+                  }
+                }
+              ]
+            }, null, {
+              dataToSend: {
+                changed_configurations: [{
+                  type: 
App.config.getConfigTagFromFileName(config.get('fileName')),
+                  name: config.get('name'),
+                  old_value: config.get(oldValueKey)
+                }]
+              }
+            });
+            initializer.cleanup();
+          });
+        }
+      }
     });
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/70b4ba40/ambari-web/app/models/configs/theme/config_action.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/theme/config_action.js 
b/ambari-web/app/models/configs/theme/config_action.js
index b2ba09a..cc24d45 100644
--- a/ambari-web/app/models/configs/theme/config_action.js
+++ b/ambari-web/app/models/configs/theme/config_action.js
@@ -52,7 +52,14 @@ App.ConfigAction = DS.Model.extend({
   popupProperties: DS.attr('object', {
     defaultValue: function () { return {}; }
   }),
-  serviceName: DS.attr('string')
+  serviceName: DS.attr('string'),
+  // TODO remove after stack advisor is able to handle this case
+  // dependencies is used as workaround for 
hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive Server Interactive from 
Install Wizard
+  dependencies: DS.attr('object', {
+    defaultValue: function () {
+      return {};
+    }
+  })
 });
 
 App.ConfigAction.FIXTURES = [
@@ -63,7 +70,31 @@ App.ConfigAction.FIXTURES = [
     file_name: "hive-interactive-env.xml",
     if:'${hive-interactive-env/enable_hive_interactive}',
     then:'add',
-    else: 'delete'
+    else: 'delete',
+    // TODO remove after stack advisor is able to handle this case
+    // dependencies is used as workaround for 
hadoop.proxyuser.{{hiveUser}}.hosts after adding Hive Server Interactive from 
Install Wizard
+    dependencies: {
+      initializer: {
+        name: 'AddHiveServerInteractiveInitializer',
+        setupKeys: ['hiveUser'],
+        componentNames: ['HIVE_SERVER', 'WEBHCAT_SERVER', 'HIVE_METASTORE', 
'HIVE_SERVER_INTERACTIVE']
+      },
+      properties: [
+        {
+          fileName: 'core-site',
+          nameTemplate: 'hadoop.proxyuser.{{hiveUser}}.hosts',
+          isHostsList: true,
+          isHostsArray: false
+        }
+      ],
+      foreignKeys: [
+        {
+          key: 'hiveUser',
+          fileName: 'hive-env.xml',
+          propertyName: 'hive_user'
+        }
+      ]
+    }
   },
   {
     id: 2,

http://git-wip-us.apache.org/repos/asf/ambari/blob/70b4ba40/ambari-web/app/utils/configs/add_component_config_initializer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/add_component_config_initializer.js 
b/ambari-web/app/utils/configs/add_component_config_initializer.js
index 21fb6b4..2ffd4b4 100644
--- a/ambari-web/app/utils/configs/add_component_config_initializer.js
+++ b/ambari-web/app/utils/configs/add_component_config_initializer.js
@@ -58,7 +58,7 @@ App.AddComponentConfigInitializer = 
App.HaConfigInitializerClass.extend(App.Host
       'hadoop.registry.zk.quorum': this.getHDPStackOnlyHostsPortConfig('2.2', 
'ZOOKEEPER_SERVER', '', '', ',', 'zkClientPort', true),
       'nimbus.seeds': 
this.getHostsListComponentJSONStringifiedConfig('NIMBUS', true),
       'hadoop.proxyuser.{{webhcatUser}}.hosts': 
this.getComponentsHostsConfig(['HIVE_SERVER', 'WEBHCAT_SERVER', 
'HIVE_METASTORE'], false, true),
-      'hadoop.proxyuser.{{hiveUser}}.hosts': 
this.getComponentsHostsConfig(['HIVE_SERVER', 'WEBHCAT_SERVER', 
'HIVE_METASTORE'], false, true),
+      'hadoop.proxyuser.{{hiveUser}}.hosts': 
this.getComponentsHostsConfig(['HIVE_SERVER', 'WEBHCAT_SERVER', 
'HIVE_METASTORE', 'HIVE_SERVER_INTERACTIVE'], false, true),
       'hive.metastore.uris': this.getHostsWithPortConfig(['HIVE_METASTORE'], 
'thrift://', '', ',thrift://', 'hiveMetastorePort', true),
       'atlas.audit.hbase.zookeeper.quorum': 
this.getHostsListComponentConfig('ZOOKEEPER_SERVER', true),
       'atlas.graph.storage.hostname': 
this.getHostsListComponentConfig('ZOOKEEPER_SERVER', true),
@@ -332,3 +332,13 @@ App.AddWebHCatComponentsInitializer = 
App.AddComponentConfigInitializer.create({
     'hadoop.proxyuser.{{webhcatUser}}.hosts'
   ]
 });
+
+/**
+ * Hive Server Interactive component add initializer.
+ * @instance App.AddHiveServerInteractiveInitializer
+ */
+App.AddHiveServerInteractiveInitializer = 
App.AddComponentConfigInitializer.create({
+  initializeForProperties: [
+    'hadoop.proxyuser.{{hiveUser}}.hosts'
+  ]
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/70b4ba40/ambari-web/app/utils/configs/move_hm_config_initializer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/move_hm_config_initializer.js 
b/ambari-web/app/utils/configs/move_hm_config_initializer.js
index ab150e9..c5f6c1f 100644
--- a/ambari-web/app/utils/configs/move_hm_config_initializer.js
+++ b/ambari-web/app/utils/configs/move_hm_config_initializer.js
@@ -27,7 +27,7 @@ 
require('utils/configs/move_hive_component_config_initializer_class');
 App.MoveHmConfigInitializer = 
App.MoveHiveComponentConfigInitializerClass.create({
 
   initializers: {
-    'hadoop.proxyuser.{{hiveUser}}.hosts': 
App.MoveHiveComponentConfigInitializerClass.getHostsWithComponentsConfig(['HIVE_SERVER',
 'HIVE_METASTORE'], 'HIVE_METASTORE')
+    'hadoop.proxyuser.{{hiveUser}}.hosts': 
App.MoveHiveComponentConfigInitializerClass.getHostsWithComponentsConfig(['HIVE_SERVER',
 'HIVE_METASTORE', 'HIVE_SERVER_INTERACTIVE'], 'HIVE_METASTORE')
   },
 
   uniqueInitializers: {

http://git-wip-us.apache.org/repos/asf/ambari/blob/70b4ba40/ambari-web/app/utils/configs/move_hs_config_initializer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/move_hs_config_initializer.js 
b/ambari-web/app/utils/configs/move_hs_config_initializer.js
index 7b15d0d..394d722 100644
--- a/ambari-web/app/utils/configs/move_hs_config_initializer.js
+++ b/ambari-web/app/utils/configs/move_hs_config_initializer.js
@@ -27,7 +27,7 @@ 
require('utils/configs/move_hive_component_config_initializer_class');
 App.MoveHsConfigInitializer = 
App.MoveHiveComponentConfigInitializerClass.create({
 
   initializers: {
-    'hadoop.proxyuser.{{hiveUser}}.hosts': 
App.MoveHiveComponentConfigInitializerClass.getHostsWithComponentsConfig(['HIVE_SERVER',
 'HIVE_METASTORE'], 'HIVE_SERVER')
+    'hadoop.proxyuser.{{hiveUser}}.hosts': 
App.MoveHiveComponentConfigInitializerClass.getHostsWithComponentsConfig(['HIVE_SERVER',
 'HIVE_METASTORE', 'HIVE_SERVER_INTERACTIVE'], 'HIVE_SERVER')
   }
 
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/70b4ba40/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 0f3c599..e70055b 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
@@ -325,8 +325,7 @@ describe('App.AssignMasterOnStep7Controller', function () {
       mock = {
         saveMasterComponentHosts: Em.K,
         loadMasterComponentHosts: Em.K,
-        setDBProperty: Em.K,
-        loadConfigRecommendations: Em.K
+        setDBProperty: Em.K
       },
       config = Em.Object.create({
         filename: 'file1',
@@ -339,7 +338,6 @@ describe('App.AssignMasterOnStep7Controller', function () {
       sinon.stub(mock, 'saveMasterComponentHosts');
       sinon.stub(mock, 'loadMasterComponentHosts');
       sinon.stub(mock, 'setDBProperty');
-      sinon.stub(mock, 'loadConfigRecommendations');
       sinon.stub(App.config, 'getConfigTagFromFileName', function (value) {
         return value;
       });
@@ -367,6 +365,9 @@ describe('App.AssignMasterOnStep7Controller', function () {
             toggleProperty: Em.K
           }),
           controller: Em.Object.create({
+            selectedService: {
+              serviceName: 'S1'
+            },
             wizardController: {
               name: 'ctrl'
             },
@@ -376,9 +377,14 @@ describe('App.AssignMasterOnStep7Controller', function () {
                 configs: [
                   config
                 ]
+              }),
+              Em.Object.create({
+                serviceName: 'MISC',
+                configs: [
+                  config
+                ]
               })
-            ],
-            loadConfigRecommendations: mock.loadConfigRecommendations
+            ]
           })
         })
       });
@@ -391,7 +397,6 @@ describe('App.AssignMasterOnStep7Controller', function () {
       mock.saveMasterComponentHosts.restore();
       mock.loadMasterComponentHosts.restore();
       mock.setDBProperty.restore();
-      mock.loadConfigRecommendations.restore();
       App.config.getConfigTagFromFileName.restore();
     });
 
@@ -409,17 +414,5 @@ describe('App.AssignMasterOnStep7Controller', function () {
         hostName: 'host1'
       });
     });
-
-    it("loadConfigRecommendations should be called once", function () {
-      expect(mock.loadConfigRecommendations.calledOnce).to.be.true;
-    });
-
-    it("loadConfigRecommendations should be called with correct arguments", 
function () {
-      expect(mock.loadConfigRecommendations.calledWith([{
-        type: 'file1',
-        name: 'conf1',
-        old_value: 'val1'
-      }])).to.be.true;
-    });
   });
 });
\ No newline at end of file

Reply via email to