ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-14399 Ranger error counter works wrong in some cases. (ababiichuk)
Date Wed, 16 Dec 2015 17:44:48 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk fa9997205 -> 0061301ef


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/0061301e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0061301e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0061301e

Branch: refs/heads/trunk
Commit: 0061301ef42e787a4b8941c2a6515d153b3e89e5
Parents: fa99972
Author: AndriyBabiychuk <babiychukandrey@gmail.com>
Authored: Wed Dec 16 19:44:41 2015 +0200
Committer: AndriyBabiychuk <babiychukandrey@gmail.com>
Committed: Wed Dec 16 19:44:41 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, 74 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0061301e/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 f031ae8..564306b 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -122,13 +122,9 @@ 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.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('selectedService.configs.@each.isValid', 'selectedService.configs.@each.isVisible',
'selectedService.configs.@each.overrideErrorTrigger'),
+  errorsCount: function() {
+    return this.get('selectedService.configsWithErrors').rejectProperty('widgetType').length;
+  }.property('selectedService.configsWithErrors'),
 
   /**
    * Determines if Save-button should be disabled

http://git-wip-us.apache.org/repos/asf/ambari/blob/0061301e/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 8877dbc..503bb62 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -132,13 +132,9 @@ 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.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('selectedService.configs.@each.isValid', 'selectedService.configs.@each.isVisible','selectedService.configs.@each.overrideErrorTrigger'),
+  errorsCount: function() {
+    return this.get('selectedService.configsWithErrors').rejectProperty('widgetType').length;
+  }.property('selectedService.configsWithErrors'),
 
   /**
    * Should Next-button be disabled
@@ -665,12 +661,7 @@ 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: [
-                  Em.Object.create({
-                    name: configCondition.get('configName'),
-                    fileName: configCondition.get('fileName')
-                  })
-                ]
+                configProperties: [App.config.configId(configCondition.get('configName'),
configCondition.get('fileName'))]
               });
             }
             if (themeResource) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0061301e/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 5d827b7..f5da880 100644
--- a/ambari-web/app/models/configs/objects/service_config.js
+++ b/ambari-web/app/models/configs/objects/service_config.js
@@ -21,24 +21,47 @@ var App = require('app');
 App.ServiceConfig = Ember.Object.extend({
   serviceName: '',
   configCategories: [],
-  configs: null,
+  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: [],
   restartRequired: false,
   restartRequiredMessage: '',
   restartRequiredHostsAndComponents: {},
   configGroups: [],
   dependentServiceNames: [],
   initConfigsLength: 0, // configs length after initialization in order to watch changes
-  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);
+
+  errorCount: Em.computed.alias('configsWithErrors.length'),
+
+  visibleProperties: function() {
+    return this.get('configs').filter(function(c) {
+      return c.get('isVisible') && !c.get('hiddenBySection');
+    });
+  }.property('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+
+  configsWithErrors: function() {
+    return this.get('visibleProperties').filter(function(c) {
+      return !c.get('isValid') || !c.get('isValidOverride');
     });
+  }.property('visibleProperties.@each.isValid', 'visibleProperties.@each.isValidOverride'),
+
+  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');
@@ -55,29 +78,7 @@ App.ServiceConfig = Ember.Object.extend({
         }
       }
     });
-    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('configs.@each.isValid', 'configs.@each.isVisible', 'configCategories.@each.slaveErrorCount',
'configs.@each.overrideErrorTrigger'),
-
+  }.observes('configs.@each.isVisible'),
   /**
    * 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
@@ -118,24 +119,6 @@ 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('properties.@each.isValid', 'properties.@each.isVisible')
-});
-
 App.ConfigSiteTag = Ember.Object.extend({
   site: DS.attr('string'),
   tag: DS.attr('string'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/0061301e/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 c351d97..26f46c9 100644
--- a/ambari-web/app/models/configs/objects/service_config_category.js
+++ b/ambari-web/app/models/configs/objects/service_config_category.js
@@ -24,7 +24,6 @@ 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
    */
@@ -40,38 +39,8 @@ 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'),
 
-
-  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('slaveConfigs.groups.@each.errorCount'),
-
-  errorCount: Em.computed.sumProperties('slaveErrorCount', 'nonSlaveErrorCount'),
+  errorCount: 0,
 
   isAdvanced : function(){
     var name = this.get('name');

http://git-wip-us.apache.org/repos/asf/ambari/blob/0061301e/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 feeb976..5e24448 100644
--- a/ambari-web/app/models/configs/objects/service_config_property.js
+++ b/ambari-web/app/models/configs/objects/service_config_property.js
@@ -169,9 +169,8 @@ App.ServiceConfigProperty = Em.Object.extend({
       }
     });
     return originalSCPIssued || overridesIssue;
-  }.property('errorMessage', 'warnMessage', 'overrideErrorTrigger'),
+  }.property('errorMessage', 'warnMessage', 'overrides.@each.warnMessage', 'overrides.@each.errorMessage'),
 
-  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
@@ -202,11 +201,13 @@ App.ServiceConfigProperty = Em.Object.extend({
   additionalView: null,
 
   /**
-   * On Overridable property error message, change overrideErrorTrigger value to recount
number of errors service have
+   * Is property has active override with error
    */
-  observeErrors: function () {
-    this.set("overrideErrorTrigger", this.get("overrideErrorTrigger") + 1);
-  }.observes("overrides.@each.errorMessage"),
+  isValidOverride: function () {
+    return this.get('overrides.length') ? !this.get('overrides').find(function(o) {
+     return o.get('isEditable') && o.get('errorMessage');
+    }) : true;
+  }.property("overrides.@each.errorMessage"),
   /**
    * 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/0061301e/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 c89500d..7274569 100644
--- a/ambari-web/app/models/configs/theme/sub_section.js
+++ b/ambari-web/app/models/configs/theme/sub_section.js
@@ -94,17 +94,25 @@ 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('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+
+  visibleTabs: Em.computed.filterBy('subSectionTabs', 'isVisible', true),
+
   /**
    * Number of the errors in all configs
    * @type {number}
    */
   errorsCount: function () {
-    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));
+    var propertiesWithErrors = this.get('visibleProperties').filter(function(c) {
+      return !c.get('isValid') || !c.get('isValidOverride');
     }).length;
-  }.property('configs.@each.isValid', 'configs.@each.isVisible', 'configs.@each.overrideErrorTrigger',
'subSectionTabs.@each.isVisible', 'subSectionTabs.@each.errorsCount'),
+    var tabsWithErrors = this.get('visibleTabs').mapProperty('errorsCount').reduce(Em.sum,
0);
+    return propertiesWithErrors + tabsWithErrors;
+  }.property('visibleProperties.@each.isValid', 'visibleProperties.@each.isValidOverride',
'visibleTabs.@each.errorsCount'),
 
   /**
    * @type {boolean}

http://git-wip-us.apache.org/repos/asf/ambari/blob/0061301e/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 7550f23..2262882 100644
--- a/ambari-web/app/models/configs/theme/sub_section_tab.js
+++ b/ambari-web/app/models/configs/theme/sub_section_tab.js
@@ -55,15 +55,21 @@ 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('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+
   /**
    * Number of the errors in all configs
    * @type {number}
    */
   errorsCount: function () {
-    return this.get('configs').filter(function(config) {
-      return config.get('isVisible') && (!config.get('isValid') || (config.get('overrides')
|| []).someProperty('isValid', false));
+    return this.get('visibleProperties').filter(function(config) {
+      return !config.get('isValid') || !config.get('isValidOverride');
     }).length;
-  }.property('configs.@each.isVisible', 'configs.@each.isValid', 'configs.@each.overrideErrorTrigger'),
+  }.property('visibleProperties.@each.isValid', 'visibleProperties.@each.isValidOverride'),
 
   /**
    * If the visibility of subsection is dependent on a value of some config
@@ -75,17 +81,12 @@ App.SubSectionTab = DS.Model.extend({
    * If there is no configs, subsection can't be hidden
    * @type {boolean}
    */
-  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('configs.@each.isHiddenByFilter'),
+  isHiddenByFilter: Em.computed.everyBy('visibleProperties', 'isHiddenByFilter', true),
 
   /**
    * @type {boolean}
    */
-  someConfigIsVisible: Em.computed.someBy('configs', 'isVisible', true),
+  someConfigIsVisible: Em.computed.gt('visibleProperties.length', 0),
 
   /**
    * Determines if subsection is visible


Mime
View raw message