Repository: ambari Updated Branches: refs/heads/trunk 27f566dd7 -> df3fca0fb
AMBARI-11101 Apply property changes in Yarn when ranger-yarn-plugin is enabled. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7edcfc4d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7edcfc4d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7edcfc4d Branch: refs/heads/trunk Commit: 7edcfc4d6dac9088ad019c532916c64fe1754e73 Parents: 27f566d Author: Andrii Tkach <atk...@hortonworks.com> Authored: Wed May 13 15:02:47 2015 +0300 Committer: Andrii Tkach <atk...@hortonworks.com> Committed: Wed May 13 18:04:37 2015 +0300 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../configs/modification_handlers/hbase.js | 8 +- .../utils/configs/modification_handlers/hdfs.js | 8 +- .../utils/configs/modification_handlers/hive.js | 6 -- .../utils/configs/modification_handlers/knox.js | 6 -- .../modification_handler.js | 6 ++ .../configs/modification_handlers/storm.js | 8 +- .../utils/configs/modification_handlers/yarn.js | 71 ++++++++++++++++++ .../configs/service_configs_by_category_view.js | 7 +- .../modification_handler_test.js | 78 ++++++++++++++++++++ 10 files changed, 163 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index eed4cc7..eeafa57 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -165,6 +165,7 @@ var files = ['test/init_model_test', 'test/utils/ui_effects_test', 'test/utils/updater_test', 'test/utils/configs/config_property_helper_test', + 'test/utils/configs/modification_handlers/modification_handler_test', 'test/views/common/chart/linear_time_test', 'test/views/common/configs/widgets/combo_config_widget_view_test', 'test/views/common/configs/widgets/config_widget_view_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/utils/configs/modification_handlers/hbase.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/modification_handlers/hbase.js b/ambari-web/app/utils/configs/modification_handlers/hbase.js index b5a342f..f093507 100644 --- a/ambari-web/app/utils/configs/modification_handlers/hbase.js +++ b/ambari-web/app/utils/configs/modification_handlers/hbase.js @@ -21,12 +21,6 @@ require('utils/configs/modification_handlers/modification_handler'); module.exports = App.ServiceConfigModificationHandler.create({ serviceId : 'HBASE', - getConfig : function(allConfigs, configName, configFilename, configServiceName) { - return allConfigs.findProperty("serviceName", configServiceName).get("configs").find(function(config) { - return configName == config.get('name') && (configFilename == null || configFilename == config.get('filename')); - }); - }, - updateConfigClasses : function(configClasses, authEnabled, affectedProperties, addOldValue) { if (configClasses != null) { var xaAuthCoProcessorClass = "com.xasecure.authorization.hbase.XaSecureAuthorizationCoprocessor"; @@ -91,7 +85,7 @@ module.exports = App.ServiceConfigModificationHandler.create({ var newAuthEnabledValue = authEnabled ? "true" : "false"; var newRpcProtectionValue = authEnabled ? "privacy" : "authentication"; - // Add Hive-Ranger configs + // Add HBase-Ranger configs this.updateConfigClasses(configMasterClasses, authEnabled, affectedProperties, configAuthEnabled.get('value') == 'true'); this.updateConfigClasses(configRegionClasses, authEnabled, affectedProperties, configAuthEnabled.get('value') == 'true'); if (newRpcProtectionValue !== configRpcProtection.get('value')) { http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/utils/configs/modification_handlers/hdfs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/modification_handlers/hdfs.js b/ambari-web/app/utils/configs/modification_handlers/hdfs.js index bff1ddd..bd18a48 100644 --- a/ambari-web/app/utils/configs/modification_handlers/hdfs.js +++ b/ambari-web/app/utils/configs/modification_handlers/hdfs.js @@ -21,12 +21,6 @@ require('utils/configs/modification_handlers/modification_handler'); module.exports = App.ServiceConfigModificationHandler.create({ serviceId : 'HDFS', - getConfig : function(allConfigs, configName, configFilename, configServiceName) { - return allConfigs.findProperty("serviceName", configServiceName).get("configs").find(function(config) { - return configName == config.get('name') && (configFilename == null || configFilename == config.get('filename')); - }); - }, - getDependentConfigChanges : function(changedConfig, selectedServices, allConfigs, securityEnabled) { var affectedProperties = []; var newValue = changedConfig.get("value"); @@ -41,7 +35,7 @@ module.exports = App.ServiceConfigModificationHandler.create({ var newDfsPermissionsEnabled = rangerPluginEnabled ? "true" : "true"; var newAttributesProviderClass = 'org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer'; - // Add Hive-Ranger configs + // Add HDFS-Ranger configs if (configDfsPermissionsEnabled != null && newDfsPermissionsEnabled !== configDfsPermissionsEnabled.get('value')) { affectedProperties.push({ serviceName : "HDFS", http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/utils/configs/modification_handlers/hive.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/modification_handlers/hive.js b/ambari-web/app/utils/configs/modification_handlers/hive.js index 092ef40..e34e488 100644 --- a/ambari-web/app/utils/configs/modification_handlers/hive.js +++ b/ambari-web/app/utils/configs/modification_handlers/hive.js @@ -21,12 +21,6 @@ require('utils/configs/modification_handlers/modification_handler'); module.exports = App.ServiceConfigModificationHandler.create({ serviceId : 'HIVE', - getConfig : function(allConfigs, configName, configFilename, configServiceName) { - return allConfigs.findProperty("serviceName", configServiceName).get("configs").find(function(config) { - return configName == config.get('name') && (configFilename == null || configFilename == config.get('filename')); - }); - }, - getDependentConfigChanges : function(changedConfig, selectedServices, allConfigs, securityEnabled) { var affectedProperties = []; var newValue = changedConfig.get("value"); http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/utils/configs/modification_handlers/knox.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/modification_handlers/knox.js b/ambari-web/app/utils/configs/modification_handlers/knox.js index 3b0740c..482c535 100644 --- a/ambari-web/app/utils/configs/modification_handlers/knox.js +++ b/ambari-web/app/utils/configs/modification_handlers/knox.js @@ -21,12 +21,6 @@ require('utils/configs/modification_handlers/modification_handler'); module.exports = App.ServiceConfigModificationHandler.create({ serviceId : 'KNOX', - getConfig : function(allConfigs, configName, configFilename, configServiceName) { - return allConfigs.findProperty("serviceName", configServiceName).get("configs").find(function(config) { - return configName == config.get('name') && (configFilename == null || configFilename == config.get('filename')); - }); - }, - getDependentConfigChanges : function(changedConfig, selectedServices, allConfigs, securityEnabled) { var affectedProperties = []; var newValue = changedConfig.get("value"); http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/utils/configs/modification_handlers/modification_handler.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/modification_handlers/modification_handler.js b/ambari-web/app/utils/configs/modification_handlers/modification_handler.js index 5b32cde..5ec6c8b 100644 --- a/ambari-web/app/utils/configs/modification_handlers/modification_handler.js +++ b/ambari-web/app/utils/configs/modification_handlers/modification_handler.js @@ -58,6 +58,12 @@ App.ServiceConfigModificationHandler = Em.Object.extend({ */ getDependentConfigChanges : function(changedConfig, selectedServices, allConfigs, securityEnabled) { return []; + }, + + getConfig: function(allConfigs, configName, configFilename, configServiceName) { + return allConfigs.findProperty('serviceName', configServiceName).get('configs').find(function(config) { + return configName == config.get('name') && (configFilename == null || configFilename == config.get('filename')); + }); } }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/utils/configs/modification_handlers/storm.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/modification_handlers/storm.js b/ambari-web/app/utils/configs/modification_handlers/storm.js index 3e27e3e..3dbe8be 100644 --- a/ambari-web/app/utils/configs/modification_handlers/storm.js +++ b/ambari-web/app/utils/configs/modification_handlers/storm.js @@ -21,12 +21,6 @@ require('utils/configs/modification_handlers/modification_handler'); module.exports = App.ServiceConfigModificationHandler.create({ serviceId : 'STORM', - getConfig : function(allConfigs, configName, configFilename, configServiceName) { - return allConfigs.findProperty("serviceName", configServiceName).get("configs").find(function(config) { - return configName == config.get('name') && (configFilename == null || configFilename == config.get('filename')); - }); - }, - getDependentConfigChanges : function(changedConfig, selectedServices, allConfigs, securityEnabled) { var affectedProperties = []; var newValue = changedConfig.get("value"); @@ -42,7 +36,7 @@ module.exports = App.ServiceConfigModificationHandler.create({ var newNimbusAuthorizer = authEnabled ? "com.xasecure.authorization.storm.authorizer.XaSecureStormAuthorizer" : "backtype.storm.security.auth.authorizer.SimpleACLAuthorizer"; - // Add Hive-Ranger configs + // Add Storm-Ranger configs if (newNimbusAuthorizer !== configNimbusAuthorizer.get('value')) { affectedProperties.push({ serviceName : "STORM", http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/utils/configs/modification_handlers/yarn.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/modification_handlers/yarn.js b/ambari-web/app/utils/configs/modification_handlers/yarn.js new file mode 100644 index 0000000..55bb1a9 --- /dev/null +++ b/ambari-web/app/utils/configs/modification_handlers/yarn.js @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * 'License'); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +var App = require('app'); +require('utils/configs/modification_handlers/modification_handler'); + +module.exports = App.ServiceConfigModificationHandler.create({ + serviceId: 'YARN', + + getDependentConfigChanges: function (changedConfig, selectedServices, allConfigs, securityEnabled) { + var affectedProperties = [], + newValue = changedConfig.get('value'), + rangerPluginEnabledName = 'ranger-yarn-plugin-enabled', + affectedPropertyName = changedConfig.get('name'); + if (affectedPropertyName == rangerPluginEnabledName) { + var configYarnAclEnable = this.getConfig(allConfigs, 'yarn.acl.enable', 'yarn-site.xml', 'YARN'), + configAuthorizationProviderClass = this.getConfig(allConfigs, 'yarn.authorization-provider', 'yarn-site.xml', 'YARN'), + isAuthorizationProviderClassNotSet = typeof configAuthorizationProviderClass === 'undefined', + rangerPluginEnabled = newValue == 'Yes', + newYarnAclEnable = 'true', + newAuthorizationProviderClass = 'org.apache.ranger.authorization.yarn.authorizer.RangerYarnAuthorizer'; + + // Add YARN-Ranger configs + if (rangerPluginEnabled) { + if (configYarnAclEnable != null && newYarnAclEnable !== configYarnAclEnable.get('value')) { + affectedProperties.push({ + serviceName: 'YARN', + sourceServiceName: 'YARN', + propertyName: 'yarn.acl.enable', + propertyDisplayName: 'yarn.acl.enable', + newValue: newYarnAclEnable, + curValue: configYarnAclEnable.get('value'), + changedPropertyName: rangerPluginEnabledName, + removed: false, + filename: 'yarn-site.xml' + }); + } + if (isAuthorizationProviderClassNotSet || newAuthorizationProviderClass !== configAuthorizationProviderClass.get('value')) { + affectedProperties.push({ + serviceName: 'YARN', + sourceServiceName: 'YARN', + propertyName: 'yarn.authorization-provider', + propertyDisplayName: 'yarn.authorization-provider', + newValue: newAuthorizationProviderClass, + curValue: isAuthorizationProviderClassNotSet ? '': configAuthorizationProviderClass.get('value'), + changedPropertyName: rangerPluginEnabledName, + removed: false, + isNewProperty: isAuthorizationProviderClassNotSet, + filename: 'yarn-site.xml', + categoryName: 'Custom yarn-site' + }); + } + } + } + return affectedProperties; + } +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/app/views/common/configs/service_configs_by_category_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js index ae77abe..56f34bf 100644 --- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js +++ b/ambari-web/app/views/common/configs/service_configs_by_category_view.js @@ -189,9 +189,10 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri this.hide(); }, onUndo: function () { - var affected = self.get("newAffectedProperties").objectAt(0); - self.get("controller.stepConfigs").findProperty("serviceName", affected.sourceServiceName).get("configs") - .findProperty("name", affected.changedPropertyName).set("value", $.trim(affected.curValue)); + var affected = self.get("newAffectedProperties").objectAt(0), + changedProperty = self.get("controller.stepConfigs").findProperty("serviceName", affected.sourceServiceName) + .get("configs").findProperty("name", affected.changedPropertyName); + changedProperty.set('value', changedProperty.get('defaultValue')); self.get("controller").set("miscModalVisible", false); this.hide(); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/7edcfc4d/ambari-web/test/utils/configs/modification_handlers/modification_handler_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/configs/modification_handlers/modification_handler_test.js b/ambari-web/test/utils/configs/modification_handlers/modification_handler_test.js new file mode 100644 index 0000000..c3af838 --- /dev/null +++ b/ambari-web/test/utils/configs/modification_handlers/modification_handler_test.js @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +require('utils/configs/modification_handlers/modification_handler'); + +describe('App.ServiceConfigModificationHandler', function () { + + var handler = App.ServiceConfigModificationHandler.create(); + + describe('#getConfig', function () { + + var allConfigs = [ + Em.Object.create({ + serviceName: 's', + configs: [ + Em.Object.create({ + name: 'c1', + filename: 'f1' + }) + ] + }) + ], + cases = [ + { + configName: 'c0', + result: undefined, + title: 'property isn\'t defined' + }, + { + configName: 'c1', + result: Em.Object.create({ + name: 'c1', + filename: 'f1' + }), + title: 'property is defined, filename isn\'t passed' + }, + { + configName: 'c1', + configFilename: 'f1', + result: Em.Object.create({ + name: 'c1', + filename: 'f1' + }), + title: 'property is defined, filename is passed' + }, + { + configName: 'c1', + configFilename: 'f2', + result: undefined, + title: 'property is defined, filenames don\'t match' + } + ]; + + cases.forEach(function (item) { + it(item.title, function () { + expect(handler.getConfig(allConfigs, item.configName, item.configFilename, 's')).to.eql(item.result); + }); + }); + + }); + +});