Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 657C718217 for ; Tue, 26 Jan 2016 21:45:08 +0000 (UTC) Received: (qmail 62060 invoked by uid 500); 26 Jan 2016 21:45:06 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 61919 invoked by uid 500); 26 Jan 2016 21:45:06 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 60123 invoked by uid 99); 26 Jan 2016 21:45:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jan 2016 21:45:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 08276E0BB2; Tue, 26 Jan 2016 21:45:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ncole@apache.org To: commits@ambari.apache.org Date: Tue, 26 Jan 2016 21:45:35 -0000 Message-Id: In-Reply-To: <8ba71937e62d427d95e867ff1fdeaf74@git.apache.org> References: <8ba71937e62d427d95e867ff1fdeaf74@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [32/50] ambari git commit: AMBARI-14788. Alerts: Ability to customize timeout for WEB alerts in Ambari Web (onechiporenko) 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/746bc1e8 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/746bc1e8 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/746bc1e8 Branch: refs/heads/branch-dev-patch-upgrade Commit: 746bc1e828f1948c695eab5c351953f8053c1e3e Parents: 150eb0e Author: Oleg Nechiporenko Authored: Mon Jan 25 17:47:15 2016 +0200 Committer: Oleg Nechiporenko Committed: Mon Jan 25 18:30:26 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 | 7 +++-- 5 files changed, 71 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/746bc1e8/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 36fefbf..1b66f60 100644 --- a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js +++ b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js @@ -288,6 +288,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') }) ]); @@ -541,13 +544,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/746bc1e8/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 5bacceb..b027d67 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 = existingAlertDefinitions.toArray().toMapByProperty('id'), alertDefinitionsToDelete = existingAlertDefinitions.mapProperty('id'), @@ -88,7 +106,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/746bc1e8/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 0143a38..4ef3edd 100644 --- a/ambari-web/app/models/alerts/alert_config.js +++ b/ambari-web/app/models/alerts/alert_config.js @@ -340,8 +340,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'), /** @@ -431,6 +431,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', @@ -562,7 +574,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; }, /** @@ -571,7 +583,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/746bc1e8/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 4e81f7a..b33cc91 100644 --- a/ambari-web/app/models/alerts/alert_definition.js +++ b/ambari-web/app/models/alerts/alert_definition.js @@ -40,6 +40,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'), @@ -162,7 +163,7 @@ App.AlertDefinition = DS.Model.extend({ ' ' + shortState + ' (' + summary[state].maintenanceCount + ')' : ''; 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]; @@ -173,7 +174,7 @@ App.AlertDefinition = DS.Model.extend({ ' ' + shortState + '' : ''; return result; }).without('').join(' '); - } else if (hostCnt == 0) { + } else if (!hostCnt) { // none return 'NONE'; } @@ -293,14 +294,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; } @@ -311,6 +312,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'), @@ -326,7 +337,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/746bc1e8/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 8cf61f2..ae25d2d 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 @@ -219,7 +219,8 @@ describe('App.MainAlertDefinitionConfigsController', function () { "https": "{{mapred-site/mapreduce.jobhistory.webapp.https.address}}", "https_property": "{{mapred-site/mapreduce.jobhistory.http.policy}}", "https_property_value": "HTTPS_ONLY", - "default_port": 0.0 + "default_port": 0.0, + "connection_timeout": 123 } })); }); @@ -227,13 +228,13 @@ describe('App.MainAlertDefinitionConfigsController', function () { it('isWizard = true', function () { controller.set('isWizard', true); var result = controller.renderWebConfigs(); - expect(result.length).to.equal(11); + expect(result.length).to.equal(12); }); it('isWizard = false', function () { controller.set('isWizard', false); var result = controller.renderWebConfigs(); - expect(result.length).to.equal(5); + expect(result.length).to.equal(6); }); });