Repository: ambari Updated Branches: refs/heads/trunk 07ee9b8ca -> b85a15c8a
Revert "AMBARI-14399 Ranger error counter works wrong in some cases. (ababiichuk)" Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b85a15c8 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b85a15c8 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b85a15c8 Branch: refs/heads/trunk Commit: b85a15c8aa68049b5af24bc71953ce84bd04bff8 Parents: 07ee9b8 Author: Aleksandr Kovalenko <[email protected]> Authored: Wed Dec 16 21:08:20 2015 +0200 Committer: Aleksandr Kovalenko <[email protected]> Committed: Wed Dec 16 21:08:20 2015 +0200 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 10 ++- .../app/controllers/wizard/step7_controller.js | 17 +++- .../models/configs/objects/service_config.js | 87 ++++++++++++-------- .../configs/objects/service_config_category.js | 33 +++++++- .../configs/objects/service_config_property.js | 13 ++- .../app/models/configs/theme/sub_section.js | 18 ++-- .../app/models/configs/theme/sub_section_tab.js | 21 +++-- 7 files changed, 125 insertions(+), 74 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b85a15c8/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 564306b..f031ae8 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -122,9 +122,13 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A * Number of errors in the configs in the selected service (only for AdvancedTab if App supports Enhanced Configs) * @type {number} */ - errorsCount: function() { - return this.get('selectedService.configsWithErrors').rejectProperty('widgetType').length; - }.property('selectedService.configsWithErrors'), + errorsCount: function () { + return this.get('selectedService.configs').filter(function (config) { + return Em.isNone(config.get('widgetType')); + }).filter(function(config) { + return !config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false); + }).filterProperty('isVisible').length; + }.property('[email protected]', '[email protected]', '[email protected]'), /** * Determines if Save-button should be disabled http://git-wip-us.apache.org/repos/asf/ambari/blob/b85a15c8/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index 503bb62..8877dbc 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -132,9 +132,13 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E * Number of errors in the configs in the selected service * @type {number} */ - errorsCount: function() { - return this.get('selectedService.configsWithErrors').rejectProperty('widgetType').length; - }.property('selectedService.configsWithErrors'), + errorsCount: function () { + return this.get('selectedService.configs').filter(function (config) { + return Em.isNone(config.get('widgetType')); + }).filter(function(config) { + return !config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false); + }).filterProperty('isVisible').length; + }.property('[email protected]', '[email protected]','[email protected]'), /** * Should Next-button be disabled @@ -661,7 +665,12 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E } else if (configCondition.get('type') === 'config') { //simulate section wrapper for condition type "config" themeResource = Em.Object.create({ - configProperties: [App.config.configId(configCondition.get('configName'), configCondition.get('fileName'))] + configProperties: [ + Em.Object.create({ + name: configCondition.get('configName'), + fileName: configCondition.get('fileName') + }) + ] }); } if (themeResource) { http://git-wip-us.apache.org/repos/asf/ambari/blob/b85a15c8/ambari-web/app/models/configs/objects/service_config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/objects/service_config.js b/ambari-web/app/models/configs/objects/service_config.js index f5da880..5d827b7 100644 --- a/ambari-web/app/models/configs/objects/service_config.js +++ b/ambari-web/app/models/configs/objects/service_config.js @@ -21,47 +21,24 @@ var App = require('app'); App.ServiceConfig = Ember.Object.extend({ serviceName: '', configCategories: [], - configCategoriesMap: function() { - var categoriesMap = {}; - this.get('configCategories').forEach(function(c) { - if (!categoriesMap[c.get('name')]) categoriesMap[c.get('name')] = c; - }); - return categoriesMap; - }.property('configCategories.[]'), - configs: [], + configs: null, restartRequired: false, restartRequiredMessage: '', restartRequiredHostsAndComponents: {}, configGroups: [], dependentServiceNames: [], initConfigsLength: 0, // configs length after initialization in order to watch changes - - errorCount: Em.computed.alias('configsWithErrors.length'), - - visibleProperties: function() { - return this.get('configs').filter(function(c) { - return c.get('isVisible') && !c.get('hiddenBySection'); - }); - }.property('[email protected]', '[email protected]'), - - configsWithErrors: function() { - return this.get('visibleProperties').filter(function(c) { - return !c.get('isValid') || !c.get('isValidOverride'); + errorCount: function () { + var overrideErrors = 0, + masterErrors = 0, + slaveErrors = 0, + configs = this.get('configs'), + configCategories = this.get('configCategories'), + enhancedConfigsErrors = 0; + configCategories.forEach(function (_category) { + slaveErrors += _category.get('slaveErrorCount'); + _category.set('nonSlaveErrorCount', 0); }); - }.property('[email protected]', '[email protected]'), - - observeErrors: function() { - this.get('configCategories').setEach('errorCount', 0); - this.get('configsWithErrors').forEach(function(c) { - if (this.get('configCategoriesMap')[c.get('category')]) { - this.get('configCategoriesMap')[c.get('category')].incrementProperty('errorCount'); - } - }, this); - }.observes('configsWithErrors'), - - observeForeignKeys: function() { - //TODO refactor or move this login to other place - var configs = this.get('configs'); configs.forEach(function (item) { if (item.get('isVisible')) { var options = item.get('options'); @@ -78,7 +55,29 @@ App.ServiceConfig = Ember.Object.extend({ } } }); - }.observes('[email protected]'), + configs.forEach(function (item) { + var category = configCategories.findProperty('name', item.get('category')); + if (category && !item.get('isValid') && item.get('isVisible') && !item.get('widgetType')) { + category.incrementProperty('nonSlaveErrorCount'); + masterErrors++; + } + if (!item.get('isValid') && item.get('widgetType') && item.get('isVisible') && !item.get('hiddenBySection')) { + enhancedConfigsErrors++; + } + if (item.get('overrides')) { + item.get('overrides').forEach(function (e) { + if (e.error) { + if (category && !Em.get(e, 'parentSCP.widget')) { + category.incrementProperty('nonSlaveErrorCount'); + } + overrideErrors++; + } + }); + } + }); + return masterErrors + slaveErrors + overrideErrors + enhancedConfigsErrors; + }.property('[email protected]', '[email protected]', '[email protected]', '[email protected]'), + /** * checks if for example for kdc_type, the value isn't just the pretty version of the saved value, for example mit-kdc * and Existing MIT KDC are the same value, but they are interpreted as being changed. This function fixes that @@ -119,6 +118,24 @@ App.ServiceConfig = Ember.Object.extend({ } }); +App.SlaveConfigs = Ember.Object.extend({ + componentName: null, + displayName: null, + hosts: null, + groups: null +}); + +App.Group = Ember.Object.extend({ + name: null, + hostNames: null, + properties: null, + errorCount: function () { + if (this.get('properties')) { + return this.get('properties').filterProperty('isValid', false).filterProperty('isVisible', true).get('length'); + } + }.property('[email protected]', '[email protected]') +}); + App.ConfigSiteTag = Ember.Object.extend({ site: DS.attr('string'), tag: DS.attr('string'), http://git-wip-us.apache.org/repos/asf/ambari/blob/b85a15c8/ambari-web/app/models/configs/objects/service_config_category.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/objects/service_config_category.js b/ambari-web/app/models/configs/objects/service_config_category.js index 26f46c9..c351d97 100644 --- a/ambari-web/app/models/configs/objects/service_config_category.js +++ b/ambari-web/app/models/configs/objects/service_config_category.js @@ -24,6 +24,7 @@ App.ServiceConfigCategory = Ember.Object.extend({ * We cant have spaces in the name as this is being used as HTML element id while rendering. Hence we introduced 'displayName' where we can have spaces like 'Secondary Name Node' etc. */ displayName: null, + slaveConfigs: null, /** * check whether to show custom view in category instead of default */ @@ -39,8 +40,38 @@ App.ServiceConfigCategory = Ember.Object.extend({ * Can this category add new properties. Used for custom configurations. */ canAddProperty: false, + nonSlaveErrorCount: 0, + primaryName: function () { + switch (this.get('name')) { + case 'DataNode': + return 'DATANODE'; + break; + case 'TaskTracker': + return 'TASKTRACKER'; + break; + case 'RegionServer': + return 'HBASE_REGIONSERVER'; + } + return null; + }.property('name'), - errorCount: 0, + + isForMasterComponent: Em.computed.existsIn('name', ['NameNode', 'SNameNode', 'JobTracker', 'HBase Master', 'Oozie Master', + 'Hive Metastore', 'WebHCat Server', 'ZooKeeper Server', 'Ganglia']), + + isForSlaveComponent: Em.computed.existsIn('name', ['DataNode', 'TaskTracker', 'RegionServer']), + + slaveErrorCount: function () { + var length = 0; + if (this.get('slaveConfigs.groups')) { + this.get('slaveConfigs.groups').forEach(function (_group) { + length += _group.get('errorCount'); + }, this); + } + return length; + }.property('[email protected]'), + + errorCount: Em.computed.sumProperties('slaveErrorCount', 'nonSlaveErrorCount'), isAdvanced : function(){ var name = this.get('name'); http://git-wip-us.apache.org/repos/asf/ambari/blob/b85a15c8/ambari-web/app/models/configs/objects/service_config_property.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/objects/service_config_property.js b/ambari-web/app/models/configs/objects/service_config_property.js index 5e24448..feeb976 100644 --- a/ambari-web/app/models/configs/objects/service_config_property.js +++ b/ambari-web/app/models/configs/objects/service_config_property.js @@ -169,8 +169,9 @@ App.ServiceConfigProperty = Em.Object.extend({ } }); return originalSCPIssued || overridesIssue; - }.property('errorMessage', 'warnMessage', '[email protected]', '[email protected]'), + }.property('errorMessage', 'warnMessage', 'overrideErrorTrigger'), + overrideErrorTrigger: 0, //Trigger for overridable property error index: null, //sequence number in category editDone: false, //Text field: on focusOut: true, on focusIn: false isNotSaved: false, // user property was added but not saved @@ -201,13 +202,11 @@ App.ServiceConfigProperty = Em.Object.extend({ additionalView: null, /** - * Is property has active override with error + * On Overridable property error message, change overrideErrorTrigger value to recount number of errors service have */ - isValidOverride: function () { - return this.get('overrides.length') ? !this.get('overrides').find(function(o) { - return o.get('isEditable') && o.get('errorMessage'); - }) : true; - }.property("[email protected]"), + observeErrors: function () { + this.set("overrideErrorTrigger", this.get("overrideErrorTrigger") + 1); + }.observes("[email protected]"), /** * No override capabilities for fields which are not edtiable * and fields which represent master hosts. http://git-wip-us.apache.org/repos/asf/ambari/blob/b85a15c8/ambari-web/app/models/configs/theme/sub_section.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/theme/sub_section.js b/ambari-web/app/models/configs/theme/sub_section.js index 7274569..c89500d 100644 --- a/ambari-web/app/models/configs/theme/sub_section.js +++ b/ambari-web/app/models/configs/theme/sub_section.js @@ -94,25 +94,17 @@ App.SubSection = DS.Model.extend({ showTabs: Em.computed.and('hasTabs', 'someSubSectionTabIsVisible'), - visibleProperties: function() { - return this.get('configs').filter(function(c) { - return c.get('isVisible') && !c.get('hiddenBySection'); - }); - }.property('[email protected]', '[email protected]'), - - visibleTabs: Em.computed.filterBy('subSectionTabs', 'isVisible', true), - /** * Number of the errors in all configs * @type {number} */ errorsCount: function () { - var propertiesWithErrors = this.get('visibleProperties').filter(function(c) { - return !c.get('isValid') || !c.get('isValidOverride'); + var visibleTabs = this.get('subSectionTabs').filterProperty('isVisible'); + var subSectionTabsErrors = visibleTabs.length ? visibleTabs.mapProperty('errorsCount').reduce(Em.sum, 0) : 0; + return subSectionTabsErrors + this.get('configs').filter(function(config) { + return config.get('isVisible') && (!config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false)); }).length; - var tabsWithErrors = this.get('visibleTabs').mapProperty('errorsCount').reduce(Em.sum, 0); - return propertiesWithErrors + tabsWithErrors; - }.property('[email protected]', '[email protected]', '[email protected]'), + }.property('[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]'), /** * @type {boolean} http://git-wip-us.apache.org/repos/asf/ambari/blob/b85a15c8/ambari-web/app/models/configs/theme/sub_section_tab.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/theme/sub_section_tab.js b/ambari-web/app/models/configs/theme/sub_section_tab.js index 2262882..7550f23 100644 --- a/ambari-web/app/models/configs/theme/sub_section_tab.js +++ b/ambari-web/app/models/configs/theme/sub_section_tab.js @@ -55,21 +55,15 @@ App.SubSectionTab = DS.Model.extend({ */ isActive: DS.attr('boolean', {defaultValue: false}), - visibleProperties: function() { - return this.get('configs').filter(function(c) { - return c.get('isVisible') && !c.get('hiddenBySection'); - }); - }.property('[email protected]', '[email protected]'), - /** * Number of the errors in all configs * @type {number} */ errorsCount: function () { - return this.get('visibleProperties').filter(function(config) { - return !config.get('isValid') || !config.get('isValidOverride'); + return this.get('configs').filter(function(config) { + return config.get('isVisible') && (!config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false)); }).length; - }.property('[email protected]', '[email protected]'), + }.property('[email protected]', '[email protected]', '[email protected]'), /** * If the visibility of subsection is dependent on a value of some config @@ -81,12 +75,17 @@ App.SubSectionTab = DS.Model.extend({ * If there is no configs, subsection can't be hidden * @type {boolean} */ - isHiddenByFilter: Em.computed.everyBy('visibleProperties', 'isHiddenByFilter', true), + isHiddenByFilter: function () { + var configs = this.get('configs').filter(function(c) { + return !c.get('hiddenBySection') && c.get('isVisible'); + }); + return configs.length ? configs.everyProperty('isHiddenByFilter', true) : false; + }.property('[email protected]'), /** * @type {boolean} */ - someConfigIsVisible: Em.computed.gt('visibleProperties.length', 0), + someConfigIsVisible: Em.computed.someBy('configs', 'isVisible', true), /** * Determines if subsection is visible
