ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-14788. Alerts: Ability to customize timeout for WEB alerts in Ambari Web (onechiporenko)
Date Thu, 28 Jan 2016 10:55:00 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 778580b4f -> 22d12b877


AMBARI-14788. Alerts: Ability to customize timeout for WEB alerts in Ambari Web (onechiporenko)


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

Branch: refs/heads/branch-2.2
Commit: 22d12b877c54a799492550eaa859d21c86e3f252
Parents: 778580b
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Mon Jan 25 17:47:15 2016 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Thu Jan 28 12:51:37 2016 +0200

----------------------------------------------------------------------
 .../alerts/definition_configs_controller.js     | 12 +++++---
 .../app/mappers/alert_definitions_mapper.js     | 24 +++++++++++++--
 ambari-web/app/models/alerts/alert_config.js    | 20 +++++++++---
 .../app/models/alerts/alert_definition.js       | 32 ++++++++++++++------
 .../definitions_configs_controller_test.js      |  4 +--
 5 files changed, 69 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/22d12b87/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
index 326a900..38f3fa0 100644
--- a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
+++ b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
@@ -289,6 +289,9 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
         showInputForValue: false,
         text: isWizard ? '' : this.getThresholdsProperty('critical', 'text'),
         value: isWizard ? '' : this.getThresholdsProperty('critical', 'value')
+      }),
+      App.AlertConfigProperties.ConnectionTimeout.create({
+        value: alertDefinition.get('uri.connectionTimeout')
       })
     ]);
 
@@ -542,13 +545,14 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
    * @type {Boolean}
    */
   hasThresholdsError: function () {
+    var smallValue, smallValid, largeValue, largeValid;
     if (this.get('configs').findProperty('name', 'warning_threshold')) {
-      var smallValue = Em.get(this.get('configs').findProperty('name', 'warning_threshold'),
'value');
-      var smallValid = Em.get(this.get('configs').findProperty('name', 'warning_threshold'),
'isValid');
+      smallValue = Em.get(this.get('configs').findProperty('name', 'warning_threshold'),
'value');
+      smallValid = Em.get(this.get('configs').findProperty('name', 'warning_threshold'),
'isValid');
     }
     if (this.get('configs').findProperty('name', 'critical_threshold')) {
-      var largeValue = Em.get(this.get('configs').findProperty('name', 'critical_threshold'),
'value');
-      var largeValid = Em.get(this.get('configs').findProperty('name', 'critical_threshold'),
'isValid');
+      largeValue = Em.get(this.get('configs').findProperty('name', 'critical_threshold'),
'value');
+      largeValid = Em.get(this.get('configs').findProperty('name', 'critical_threshold'),
'isValid');
     }
     return smallValid && largeValid ? Number(smallValue) > Number(largeValue)
: false;
   }.property('configs.@each.value'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/22d12b87/ambari-web/app/mappers/alert_definitions_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/alert_definitions_mapper.js b/ambari-web/app/mappers/alert_definitions_mapper.js
index 976f7e1..b79a90c 100644
--- a/ambari-web/app/mappers/alert_definitions_mapper.js
+++ b/ambari-web/app/mappers/alert_definitions_mapper.js
@@ -25,6 +25,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
   reportModel: App.AlertReportDefinition,
   metricsSourceModel: App.AlertMetricsSourceDefinition,
   metricsUriModel: App.AlertMetricsUriDefinition,
+  parameterModel: App.AlertDefinitionParameter,
 
   config: {
     id: 'AlertDefinition.id',
@@ -42,6 +43,11 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
     reporting_type: 'array',
     reporting: {
       item: 'id'
+    },
+    parameters_key: 'reporting',
+    parameters_type: 'array',
+    parameters: {
+      item: 'id'
     }
   },
 
@@ -66,7 +72,19 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
     http: 'AlertDefinition.source.uri.http',
     https: 'AlertDefinition.source.uri.https',
     https_property: 'AlertDefinition.source.uri.https_property',
-    https_property_value: 'AlertDefinition.source.uri.https_property_value'
+    https_property_value: 'AlertDefinition.source.uri.https_property_value',
+    connection_timeout: 'AlertDefinition.source.uri.connection_timeout'
+  },
+
+  parameterConfig: {
+    id: 'AlertDefinition.source.parameters.id',
+    name: 'AlertDefinition.source.parameters.name',
+    display_name: 'AlertDefinition.source.parameters.display_name',
+    units: 'AlertDefinition.source.parameters.units',
+    value: 'AlertDefinition.source.parameters.value',
+    description: 'AlertDefinition.source.parameters.description',
+    type: 'AlertDefinition.source.parameters.type',
+    threshold: 'AlertDefinition.source.parameters.threshold'
   },
 
   map: function (json) {
@@ -77,7 +95,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
           alertReportDefinitions = [],
           alertMetricsSourceDefinitions = [],
           alertMetricsUriDefinitions = [],
-          alertGroupsMap = App.cache['previousAlertGroupsMap'],
+          alertGroupsMap = App.cache.previousAlertGroupsMap,
           existingAlertDefinitions = App.AlertDefinition.find(),
           existingAlertDefinitionsMap = {},
           alertDefinitionsToDelete = existingAlertDefinitions.mapProperty('id'),
@@ -92,7 +110,7 @@ App.alertDefinitionsMapper = App.QuickDataMapper.create({
         var reporting = item.AlertDefinition.source.reporting;
         for (var report in reporting) {
           if (reporting.hasOwnProperty(report)) {
-            if (report == "units") {
+            if (report === "units") {
               convertedReportDefinitions.push({
                 id: item.AlertDefinition.id + report,
                 type: report,

http://git-wip-us.apache.org/repos/asf/ambari/blob/22d12b87/ambari-web/app/models/alerts/alert_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_config.js b/ambari-web/app/models/alerts/alert_config.js
index df2e579..b910339 100644
--- a/ambari-web/app/models/alerts/alert_config.js
+++ b/ambari-web/app/models/alerts/alert_config.js
@@ -346,8 +346,8 @@ App.AlertConfigProperties = {
      * @type {bool}
      */
     wasChanged: function () {
-      return (this.get('previousValue') !== null && this.get('value') !== this.get('previousValue'))
||
-      (this.get('previousText') !== null && this.get('text') !== this.get('previousText'));
+      return this.get('previousValue') !== null && this.get('value') !== this.get('previousValue')
||
+      this.get('previousText') !== null && this.get('text') !== this.get('previousText');
     }.property('value', 'text', 'previousValue', 'previousText'),
 
     /**
@@ -437,6 +437,18 @@ App.AlertConfigProperties = {
     }.property('value')
   }),
 
+  ConnectionTimeout: App.AlertConfigProperty.extend({
+    name: 'connection_timeout',
+    label: 'Connection Timeout',
+    displayType: 'textField',
+    classNames: 'alert-connection-timeout',
+    apiProperty: 'source.uri.connection_timeout',
+    isValid: function () {
+      var value = this.get('value');
+      return numericUtils.isPositiveNumber(value);
+    }.property('value')
+  }),
+
   DefaultPort: App.AlertConfigProperty.extend({
     name: 'default_port',
     label: 'Default Port',
@@ -572,7 +584,7 @@ App.AlertConfigProperties.Thresholds = {
      */
     getNewValue: function () {
       var value = this.get('value');
-      return (value && !isNaN(value)) ? (Number(value) * 100) + '' : value;
+      return value && !isNaN(value) ? Number(value) * 100 + '' : value;
     },
 
     /**
@@ -581,7 +593,7 @@ App.AlertConfigProperties.Thresholds = {
      */
     getNewDisplayValue: function () {
       var displayValue = this.get('displayValue');
-      return (displayValue && !isNaN(displayValue)) ? (Number(displayValue) / 100)
+ '' : displayValue;
+      return displayValue && !isNaN(displayValue) ? Number(displayValue) / 100 +
'' : displayValue;
     }
 
   }),

http://git-wip-us.apache.org/repos/asf/ambari/blob/22d12b87/ambari-web/app/models/alerts/alert_definition.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_definition.js b/ambari-web/app/models/alerts/alert_definition.js
index 1ea6411..0b92429 100644
--- a/ambari-web/app/models/alerts/alert_definition.js
+++ b/ambari-web/app/models/alerts/alert_definition.js
@@ -33,6 +33,7 @@ App.AlertDefinition = DS.Model.extend({
   type: DS.attr('string'),
   groups: DS.hasMany('App.AlertGroup'),
   reporting: DS.hasMany('App.AlertReportDefinition'),
+  parameters: DS.hasMany('App.AlertDefinitionParameter'),
   lastTriggered: DS.attr('number'),
   lastTriggeredRaw: DS.attr('number'),
 
@@ -157,7 +158,7 @@ App.AlertDefinition = DS.Model.extend({
         '<span class="alert-state-single-host label alert-state-PENDING"><span class="icon-medkit"></span>
' + shortState + ' (' + summary[state].maintenanceCount + ')</span>' : '';
         return result;
       }).without('').join(' ');
-    } else if (hostCnt == 1) {
+    } else if (hostCnt === 1) {
       // single host, single status
       return order.map(function (state) {
         var shortState = self.get('shortState')[state];
@@ -168,7 +169,7 @@ App.AlertDefinition = DS.Model.extend({
         '<span class="alert-state-single-host label alert-state-PENDING"><span class="icon-medkit"></span>
' + shortState + '</span>' : '';
         return result;
       }).without('').join(' ');
-    } else if (hostCnt == 0) {
+    } else if (!hostCnt) {
       // none
       return '<span class="alert-state-single-host label alert-state-PENDING">NONE</span>';
     }
@@ -304,14 +305,14 @@ App.AlertDefinition.reopenClass({
    */
   getSortDefinitionsByStatus: function (order) {
     return function (a, b) {
-      var a_summary = a.get('summary'),
-        b_summary = b.get('summary'),
-        st_order = a.get('severityOrder'),
+      var aSummary = a.get('summary'),
+        bSummary = b.get('summary'),
+        stOrder = a.get('severityOrder'),
         ret = 0;
-      for (var i = 0; i < st_order.length; i++) {
-        var a_v = Em.isNone(a_summary[st_order[i]]) ? 0 : a_summary[st_order[i]].count +
a_summary[st_order[i]].maintenanceCount,
-          b_v = Em.isNone(b_summary[st_order[i]]) ? 0 : b_summary[st_order[i]].count + b_summary[st_order[i]].maintenanceCount;
-        ret = b_v - a_v;
+      for (var i = 0; i < stOrder.length; i++) {
+        var aV = Em.isNone(aSummary[stOrder[i]]) ? 0 : aSummary[stOrder[i]].count + aSummary[stOrder[i]].maintenanceCount,
+          bV = Em.isNone(bSummary[stOrder[i]]) ? 0 : bSummary[stOrder[i]].count + bSummary[stOrder[i]].maintenanceCount;
+        ret = bV - aV;
         if (ret !== 0) {
           break;
         }
@@ -322,6 +323,16 @@ App.AlertDefinition.reopenClass({
 
 });
 
+App.AlertDefinitionParameter = DS.Model.extend({
+  name: DS.attr('string'),
+  displayName: DS.attr('string'),
+  unit: DS.attr('string'),
+  value: DS.attr('number'),
+  description: DS.attr('string'),
+  type: DS.attr('string'),
+  threshold: DS.attr('string')
+});
+
 App.AlertReportDefinition = DS.Model.extend({
   type: DS.attr('string'),
   text: DS.attr('string'),
@@ -337,7 +348,8 @@ App.AlertMetricsUriDefinition = DS.Model.extend({
   http: DS.attr('string'),
   https: DS.attr('string'),
   httpsProperty: DS.attr('string'),
-  httpsPropertyValue: DS.attr('string')
+  httpsPropertyValue: DS.attr('string'),
+  connectionTimeout: DS.attr('number')
 });
 
 App.AlertDefinition.FIXTURES = [];

http://git-wip-us.apache.org/repos/asf/ambari/blob/22d12b87/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
b/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
index ac06de7..dce3935 100644
--- a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
@@ -225,12 +225,12 @@ describe('App.MainAlertDefinitionConfigsController', function () {
       controller.set('isWizard', true);
       var result = controller.renderWebConfigs();
 
-      expect(result.length).to.equal(11);
+      expect(result.length).to.equal(12);
 
       controller.set('isWizard', false);
       result = controller.renderWebConfigs();
 
-      expect(result.length).to.equal(5);
+      expect(result.length).to.equal(6);
     });
 
   });


Mime
View raw message