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 C6D5A174D1 for ; Mon, 6 Apr 2015 18:54:31 +0000 (UTC) Received: (qmail 60806 invoked by uid 500); 6 Apr 2015 18:54:31 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 60744 invoked by uid 500); 6 Apr 2015 18:54:31 -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 60729 invoked by uid 99); 6 Apr 2015 18:54:31 -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; Mon, 06 Apr 2015 18:54:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 85A72E10A9; Mon, 6 Apr 2015 18:54:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: srimanth@apache.org To: commits@ambari.apache.org Message-Id: <7890c76490b24200abfdc1352f09df2d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-10371. Create HBase theme based enhanced configs Date: Mon, 6 Apr 2015 18:54:31 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/trunk 5c030d431 -> 2bb9aa2de AMBARI-10371. Create HBase theme based enhanced configs Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2bb9aa2d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2bb9aa2d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2bb9aa2d Branch: refs/heads/trunk Commit: 2bb9aa2de6f675626b0acf63a02d14ab9286f4f3 Parents: 5c030d4 Author: Srimanth Gunturi Authored: Mon Apr 6 11:12:56 2015 -0700 Committer: Srimanth Gunturi Committed: Mon Apr 6 11:40:04 2015 -0700 ---------------------------------------------------------------------- .../0.96.0.2.0/configuration/hbase-site.xml | 60 ++- .../services/HBASE/configuration/hbase-env.xml | 10 - .../services/HBASE/configuration/hbase-site.xml | 39 +- .../stacks/HDP/2.2/services/HBASE/metainfo.xml | 7 + .../HDP/2.2/services/HBASE/themes/theme.json | 427 +++++++++++++++++++ ambari-web/app/config.js | 2 +- .../unit_convert/base_unit_convert_mixin.js | 42 +- .../convert_unit_widget_view_mixin.js | 10 +- ambari-web/app/styles/application.less | 2 +- .../configs/widgets/slider_config_widget.hbs | 4 +- .../configs/widgets/combo_config_widget_view.js | 6 +- .../widgets/slider_config_widget_view.js | 53 ++- .../base_unit_convert_mixin_test.js | 46 ++ .../widgets/combo_config_widget_view_test.js | 12 +- .../widgets/slider_config_widget_view_test.js | 65 ++- 15 files changed, 717 insertions(+), 68 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-site.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-site.xml b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-site.xml index 206ac81..7fb979e 100644 --- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-site.xml +++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-site.xml @@ -121,7 +121,7 @@ milliseconds - + hbase.regionserver.global.memstore.lowerLimit 0.38 @@ -145,9 +145,17 @@ Per-Column Family Memstore Block Multiplier value-list - 2 - 4 - 8 + + + 2 + + + 4 + + + 8 + + 1 @@ -162,10 +170,10 @@ Per-Column Family Memstore Flush Size int - 32 - 256 - 1 - MB + 33554432 + 268435456 + 1048576 + B @@ -263,9 +271,17 @@ Maximum Files in a Store before Compaction int - 2 - 3 - 4 + + + 2 + + + 3 + + + 4 + + @@ -275,7 +291,7 @@ The number of times the region flush operation will be retried. - + hbase.hstore.blockingStoreFiles 10 @@ -321,8 +337,14 @@ Enable Authentication value-list - true - false + + + true + + + false + + 1 @@ -335,8 +357,14 @@ Enable Authorization value-list - true - false + + + true + + + false + + 1 http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml index 5390998..27270a0 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml @@ -32,11 +32,6 @@ Pid Directory for HBase. - hbase_regionserver_heapsize - 1024 - HBase RegionServer Heap Size. - - hbase_regionserver_xmn_max 512 @@ -51,11 +46,6 @@ and the -Xmn ratio (hbase_regionserver_xmn_ratio) exceeds this value. Percentage of max heap size (-Xmx) which used for young generation heap (-Xmn). - hbase_master_heapsize - 1024 - HBase Master Heap Size - - hbase_user hbase USER http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-site.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-site.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-site.xml index e3f9219..6ed1715 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-site.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-site.xml @@ -28,7 +28,7 @@ The number of times the region flush operation will be retried. - + hbase.hregion.majorcompaction 604800000 @@ -40,6 +40,12 @@ environment, you can configure them to run at off-peak times for your deployment, or disable time-based major compactions by setting this parameter to 0, and run major compactions in a cron job or by another external mechanism. + + int + 0 + 2592000000 + milliseconds + hbase.hregion.majorcompaction.jitter @@ -60,6 +66,20 @@ resultant flush files take a long time to compact or split, or worse, we OOME. + + value-list + + + 2 + + + 4 + + + 8 + + + hbase.bucketcache.ioengine @@ -86,4 +106,21 @@ in a region server hits hbase.regionserver.global.memstore.size.lower.limit. + + hbase.regionserver.wal.codec + Phoenix SQL + false + + value-list + + + true + + + false + + + + Phoenix SQL + http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/metainfo.xml index fffb3dd..7584924 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/metainfo.xml @@ -48,6 +48,13 @@ + + + theme.json + true + + + http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/themes/theme.json ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/themes/theme.json b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/themes/theme.json new file mode 100644 index 0000000..c684e5c --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/themes/theme.json @@ -0,0 +1,427 @@ +{ + "Theme": { + "name": "default", + "description": "Default theme for HBASE service", + "configuration": { + "layouts": [ + { + "name": "default", + "tabs": [ + { + "name": "settings", + "display-name": "Settings", + "layout": { + "tab-columns": "3", + "tab-rows": "3", + "sections": [ + { + "name": "section-hbase-memory", + "display-name": "Memory", + "row-index": "0", + "column-index": "0", + "row-span": "1", + "column-span": "2", + "section-columns": "2", + "section-rows": "1", + "subsections": [ + { + "name": "subsection-hbase-memory-col1", + "row-index": "0", + "column-index": "0", + "row-span": "1", + "column-span": "1" + }, + { + "name": "subsection-hbase-memory-col2", + "row-index": "0", + "column-index": "1", + "row-span": "1", + "column-span": "1" + } + ] + }, + { + "name": "section-hbase-client", + "display-name": "Client", + "row-index": "0", + "column-index": "1", + "row-span": "1", + "column-span": "1", + "section-columns": "1", + "section-rows": "1", + "subsections": [ + { + "name": "subsection-hbase-client-col1", + "row-index": "0", + "column-index": "0", + "row-span": "1", + "column-span": "1" + } + ] + }, + { + "name": "section-hbase-disk", + "display-name": "Disk", + "row-index": "1", + "column-index": "0", + "row-span": "1", + "column-span": "3", + "section-columns": "3", + "section-rows": "1", + "subsections": [ + { + "name": "subsection-hbase-disk-col1", + "row-index": "0", + "column-index": "0", + "row-span": "1", + "column-span": "1" + }, + { + "name": "subsection-hbase-disk-col2", + "row-index": "0", + "column-index": "1", + "row-span": "1", + "column-span": "1" + }, + { + "name": "subsection-hbase-disk-col3", + "row-index": "0", + "column-index": "1", + "row-span": "1", + "column-span": "1" + } + ] + }, + { + "name": "section-hbase-timeouts", + "display-name": "Timeouts", + "row-index": "2", + "column-index": "0", + "row-span": "1", + "column-span": "1", + "section-columns": "1", + "section-rows": "1", + "subsections": [ + { + "name": "subsection-hbase-timeouts-col1", + "row-index": "0", + "column-index": "0", + "row-span": "1", + "column-span": "1" + } + ] + }, + { + "name": "section-hbase-security", + "display-name": "Security", + "row-index": "2", + "column-index": "1", + "row-span": "1", + "column-span": "1", + "section-columns": "1", + "section-rows": "1", + "subsections": [ + { + "name": "subsection-hbase-security-col1", + "row-index": "0", + "column-index": "0", + "row-span": "1", + "column-span": "1" + } + ] + }, + { + "name": "section-hbase-phoenix", + "display-name": "Phoenix", + "row-index": "2", + "column-index": "2", + "row-span": "1", + "column-span": "1", + "section-columns": "1", + "section-rows": "1", + "subsections": [ + { + "name": "subsection-hbase-phoenix-col1", + "row-index": "0", + "column-index": "0", + "row-span": "1", + "column-span": "1" + } + ] + } + ] + } + } + ] + } + ] + }, + "placement": { + "configuration-layout": "default", + "configs": [ + { + "config": "hbase-env/hbase_master_heapsize", + "subsection-name": "subsection-hbase-memory-col1" + }, + { + "config": "hbase-env/hbase_regionserver_heapsize", + "subsection-name": "subsection-hbase-memory-col1" + }, + { + "config": "hbase-site/hfile.block.cache.size", + "subsection-name": "subsection-hbase-memory-col1" + }, + { + "config": "hbase-site/hbase.regionserver.global.memstore.upperLimit", + "subsection-name": "subsection-hbase-memory-col2" + }, + { + "config": "hbase-site/hbase.hregion.memstore.flush.size", + "subsection-name": "subsection-hbase-memory-col2" + }, + { + "config": "hbase-site/hbase.hregion.memstore.block.multiplier", + "subsection-name": "subsection-hbase-memory-col2" + }, + { + "config": "hbase-site/hbase.regionserver.handler.count", + "subsection-name": "subsection-hbase-client-col1" + }, + { + "config": "hbase-site/hbase.client.scanner.caching", + "subsection-name": "subsection-hbase-client-col1" + }, + { + "config": "hbase-site/hbase.client.retries.number", + "subsection-name": "subsection-hbase-client-col1" + }, + { + "config": "hbase-site/hbase.client.keyvalue.maxsize", + "subsection-name": "subsection-hbase-client-col1" + }, + { + "config": "hbase-site/hbase.hregion.max.filesize", + "subsection-name": "subsection-hbase-disk-col1" + }, + { + "config": "hbase-site/hbase.hregion.majorcompaction", + "subsection-name": "subsection-hbase-disk-col2" + }, + { + "config": "hbase-site/hbase.hstore.compactionThreshold", + "subsection-name": "subsection-hbase-disk-col3" + }, + { + "config": "hbase-site/zookeeper.session.timeout", + "subsection-name": "subsection-hbase-timeouts-col1" + }, + { + "config": "hbase-site/hbase.rpc.timeout", + "subsection-name": "subsection-hbase-timeouts-col1" + }, + { + "config": "hbase-site/hbase.security.authentication", + "subsection-name": "subsection-hbase-security-col1" + }, + { + "config": "hbase-site/hbase.security.authorization", + "subsection-name": "subsection-hbase-security-col1" + }, + { + "config": "hbase-site/hbase.regionserver.wal.codec", + "subsection-name": "subsection-hbase-phoenix-col1" + }, + { + "config": "hbase-site/phoenix.query.timeoutMs", + "subsection-name": "subsection-hbase-phoenix-col1" + } + ] + }, + "widgets":[ + { + "config":"hbase-env/hbase_master_heapsize", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"GB" + } + ] + } + }, + { + "config":"hbase-env/hbase_regionserver_heapsize", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"GB" + } + ] + } + }, + { + "config":"hbase-site/hfile.block.cache.size", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"percent" + } + ] + } + }, + { + "config":"hbase-site/hbase.regionserver.global.memstore.upperLimit", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"percent" + } + ] + } + }, + { + "config":"hbase-site/hbase.hregion.memstore.flush.size", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"MB" + } + ] + } + }, + { + "config":"hbase-site/hbase.hregion.memstore.block.multiplier", + "widget":{ + "type":"combo" + } + }, + { + "config":"hbase-site/hbase.regionserver.handler.count", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"int" + } + ] + } + }, + { + "config":"hbase-site/hbase.client.scanner.caching", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"int" + } + ] + } + }, + { + "config":"hbase-site/hbase.client.retries.number", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"int" + } + ] + } + }, + { + "config":"hbase-site/hbase.client.keyvalue.maxsize", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"MB" + } + ] + } + }, + { + "config":"hbase-site/hbase.hregion.max.filesize", + "widget":{ + "type":"slider", + "units":[ + { + "unit-name":"GB" + } + ] + } + }, + { + "config":"hbase-site/hbase.hregion.majorcompaction", + "widget":{ + "type":"time-interval-spinner", + "units":[ + { + "unit-name":"days,hours" + } + ] + } + }, + { + "config":"hbase-site/hbase.hstore.compactionThreshold", + "widget":{ + "type":"combo" + } + }, + { + "config":"hbase-site/zookeeper.session.timeout", + "widget":{ + "type":"time-interval-spinner", + "units":[ + { + "unit-name":"minutes,seconds" + } + ] + } + }, + { + "config":"hbase-site/hbase.rpc.timeout", + "widget":{ + "type":"time-interval-spinner", + "units":[ + { + "unit-name":"minutes,seconds" + } + ] + } + }, + { + "config":"hbase-site/hbase.security.authentication", + "widget":{ + "type":"checkbox" + } + }, + { + "config":"hbase-site/hbase.security.authorization", + "widget":{ + "type":"checkbox" + } + }, + { + "config":"hbase-site/hbase.regionserver.wal.codec", + "widget":{ + "type":"checkbox" + } + }, + { + "config":"hbase-site/phoenix.query.timeoutMs", + "widget":{ + "type":"time-interval-spinner", + "units": [ + { + "unit-name": "minutes,seconds" + } + ] + } + } + ] + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/app/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js index 6e06e59..e97e315 100644 --- a/ambari-web/app/config.js +++ b/ambari-web/app/config.js @@ -73,7 +73,7 @@ App.supports = { installGanglia: false, opsDuringRollingUpgrade: false, customizedWidgets: false, - enhancedConfigs: false, + enhancedConfigs: true, setRackId: false }; http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js b/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js index 2f09c18..4ba70a3 100644 --- a/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js +++ b/ambari-web/app/mixins/unit_convert/base_unit_convert_mixin.js @@ -25,12 +25,24 @@ App.BaseUnitConvertMixin = Em.Mixin.create({ * For more info regarding dimension table @see convertMapTable property. * * This property can be used in mixed object to specify which dimension table map will - * be used for conversion. + * be used for conversion. If type is not specified we try to find correct table by input unit type. + * + * Note: You should specify dimension for `percentage` conversion with specified property unit type. + * * @property currentDimensionType * @type {String} */ currentDimensionType: null, + /** + * Labels related to units. Specify desired display names here that not much actual unit name. + */ + unitLabelMap: { + percent: '%', + int: '', + float: '' + }, + convertMapTable: Em.Object.create({ size: { b: 1024, @@ -46,6 +58,22 @@ App.BaseUnitConvertMixin = Em.Mixin.create({ minutes: 60, hours: 60, days: 24 + }, + /** + * Percent dimension type should be specified directly through `currentDimensionType` property. + * For example: + * 'percent.percent_int' if widget `unit-name` is "percent" and config property `type` is "int" + * 'percent.percent_float' if widget `unit-name` is "percent" and config property `type` is "float" + */ + percent: { + percent_int: { + int: 1, + percent: 1 + }, + percent_float: { + float: 1, + percent: 0.01 + } } }), @@ -70,7 +98,7 @@ App.BaseUnitConvertMixin = Em.Mixin.create({ * @param {String|String[]} fromUnit - specified value unit type(s) e.g. "mb" * Form multi dimensional format pass units separated with "," or list of unit types * e.g. "gb,mb", ['gb', 'mb'] - * @param {Boolean} [isObjectOutput] - returned value should be object this option usefull for widgets where its + * @param {Boolean} [isObjectOutput=false] - 'returned' value should be object this option usefull for widgets where its * value should be an Object * @param {String|String[]} toUnit - desired unit(s) to convert specified value. Same format as for `fromUnit` * @returns {Number|Object[]} returns single value or array of objects according to multi unit format @@ -137,7 +165,7 @@ App.BaseUnitConvertMixin = Em.Mixin.create({ } else { unitType = Em.keys(this.get('convertMapTable')).filter(function(item) { - return Em.keys(this.get('convertMapTable.' + item)).contains(Em.isArray(unit) ? unit[0] : unit); + return Em.keys(this.get('convertMapTable.' + item)).contains(Em.isArray(unit) ? unit[0].toLowerCase() : unit.toLowerCase()); }, this)[0]; } return this.get('convertMapTable.' + unitType); @@ -156,6 +184,9 @@ App.BaseUnitConvertMixin = Em.Mixin.create({ var units = Em.keys(convertTable); var fromUnitIndex = units.indexOf(fromUnit.toLowerCase()); var toUnitIndex = units.indexOf(toUnit.toLowerCase()); + var isInt = function(val) { + return parseInt(val) === val; + }; Em.assert("Invalid value unit type " + fromUnit, fromUnitIndex > -1); Em.assert("Invalid desired unit type " + toUnit, toUnitIndex > -1); if (fromUnitIndex == toUnitIndex) { @@ -167,10 +198,11 @@ App.BaseUnitConvertMixin = Em.Mixin.create({ return Em.get(convertTable, unit); }, this).reduce(function(p,c) { return p*c; }); if (range[0] < range[1]) { - return value / factor; + value /= factor; } else { - return value * factor; + value *= factor; } + return isInt(value) ? value : parseFloat(value.toFixed(2)); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/app/mixins/unit_convert/convert_unit_widget_view_mixin.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/unit_convert/convert_unit_widget_view_mixin.js b/ambari-web/app/mixins/unit_convert/convert_unit_widget_view_mixin.js index 864ca45..2910a78 100644 --- a/ambari-web/app/mixins/unit_convert/convert_unit_widget_view_mixin.js +++ b/ambari-web/app/mixins/unit_convert/convert_unit_widget_view_mixin.js @@ -25,8 +25,8 @@ App.ConvertUnitWidgetViewMixin = Em.Mixin.create(App.BaseUnitConvertMixin, { /** * Get converted value according to widget value format from specified config property value. * - * @param {String|Number} value - value to convert - * @param {Boolean} returnObject - returned value should be an array of objects + * @param {String|Number} value - config property value to convert + * @param {Boolean} [returnObject=false] - returned value should be an array of objects * @returns {Number|Object[]} */ widgetValueByConfigAttributes: function(value, returnObject) { @@ -36,7 +36,7 @@ App.ConvertUnitWidgetViewMixin = Em.Mixin.create(App.BaseUnitConvertMixin, { /** * Get converted value according to config property unit format from specified widget value. * - * @param {String|Number|Object[]} value - value to convert + * @param {String|Number|Object[]} value - widget value to convert * @param {Boolean} returnObject - returned value should be an array of objects * @returns {Number} */ @@ -65,8 +65,8 @@ App.ConvertUnitWidgetViewMixin = Em.Mixin.create(App.BaseUnitConvertMixin, { */ _converterGetPropertyAttributes: function() { var propertyAttributes = this.get('config.stackConfigProperty.valueAttributes'); - var propertyUnits = Em.getWithDefault(propertyAttributes, 'unit', false); - Em.assert('Invalid property unit type for ' + this.get('config.name') + ' valueAttributes: ' + propertyAttributes, propertyUnits); + var propertyUnits = Em.getWithDefault(propertyAttributes, 'unit', false) || Em.getWithDefault(propertyAttributes, 'type', false); + Em.assert('Invalid property unit type for ' + this.get('config.name') + ' valueAttributes: ' + JSON.stringify(propertyAttributes), propertyUnits); return propertyUnits; } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/app/styles/application.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index 4e986a8..3c82dfa 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -5618,7 +5618,7 @@ input[type="checkbox"].align-checkbox { } .config-subsection-table { width: 100%; - height: 100%; + height: 90%; border-spacing: 5px; border-collapse: separate; table-layout: fixed; http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs b/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs index 554c706..e983ec8 100644 --- a/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs +++ b/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs @@ -23,7 +23,7 @@ {{/if}}
{{view Ember.TextField valueBinding="view.config.value" class="input-mini slider-input"}}
-
{{view.mirrorValue}} {{view.config.stackConfigProperty.valueAttributes.unit}}
+
{{view.mirrorValue}} {{view.unitLabel}}
{{#if view.isOriginalSCP}} @@ -65,4 +65,4 @@ {{#if view.isComparison}} {{view App.ConfigWidgetComparisonView serviceConfigPropertyBinding="view.config"}} {{/if}} -
\ No newline at end of file + http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/app/views/common/configs/widgets/combo_config_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/combo_config_widget_view.js b/ambari-web/app/views/common/configs/widgets/combo_config_widget_view.js index 921e3e9..2997248 100644 --- a/ambari-web/app/views/common/configs/widgets/combo_config_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/combo_config_widget_view.js @@ -61,10 +61,10 @@ App.ComboConfigWidgetView = App.ConfigWidgetView.extend({ * @returns {Object[]} - values list map @see content.valuesList */ convertToWidgetUnits: function(valueAttributes) { - return Em.get(valueAttributes, 'entries').map(function(item, index) { + return Em.get(valueAttributes, 'entries').map(function(item) { return Em.Object.create({ - configValue: item, - widgetValue: Em.get(valueAttributes, 'entry_labels.' + index) + configValue: item.value, + widgetValue: Em.getWithDefault(item, 'label', item.value) }); }); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js index 59074c2..7dc0c13 100644 --- a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js @@ -55,6 +55,12 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ isMirrorValueValid: true, /** + * Unit label to display. + * @type {String} + */ + unitLabel: '', + + /** * Function used to parse config value (based on config.stackConfigProperty.valueAttributes.type) * For integer - parseInt, for float - parseFloat * @type {Function} @@ -84,12 +90,13 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ willInsertElement: function () { this._super(); + this.prepareValueConverter(); this.addObserver('mirrorValue', this, this.mirrorValueObs); }, didInsertElement: function () { this._super(); - this.set('mirrorValue', this.get('config.value')); + this.set('mirrorValue', this.widgetValueByConfigAttributes(this.get('config.value'))); this.prepareValueAttributes(); this.initSlider(); this.toggleWidgetState(); @@ -114,6 +121,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ this.get('parentView').sendRequestRorDependentConfigs(this.get('parentView.config')); } }), + /** * Check if mirrorValue was updated by user * Validate it. If value is correct, set it to slider and config.value @@ -122,8 +130,8 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ mirrorValueObs: function () { var mirrorValue = this.get('mirrorValue'), slider = this.get('slider'), - min = this.get('config.stackConfigProperty.valueAttributes.minimum'), - max = this.get('config.stackConfigProperty.valueAttributes.maximum'), + min = this.widgetValueByConfigAttributes(this.get('config.stackConfigProperty.valueAttributes.minimum')), + max = this.widgetValueByConfigAttributes(this.get('config.stackConfigProperty.valueAttributes.maximum')), validationFunction = this.get('validateFunction'), parseFunction = this.get('parseFunction'); if (validationFunction(mirrorValue)) { @@ -131,7 +139,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ if (parsed >= min && parsed <= max) { this.set('isMirrorValueValid', true); this.set('config.errorMessage', ''); - this.set('config.value', '' + parsed); + this.set('config.value', '' + this.configValueByWidget(parsed)); if (slider) { slider.setValue(parsed); } @@ -154,7 +162,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ */ setValue: function() { var parseFunction = this.get('parseFunction'); - this.set('mirrorValue', parseFunction(this.get('config.value'))); + this.set('mirrorValue', this.widgetValueByConfigAttributes(parseFunction(this.get('config.value')))); }, /** @@ -171,6 +179,18 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ }, /** + * Setup convert table according to widget unit-name and property type. + * Set label for unit to display. + */ + prepareValueConverter: function() { + var widgetUnit = this._converterGetWidgetUnits(); + if (['int', 'float'].contains(this._converterGetPropertyAttributes()) && widgetUnit == 'percent') { + this.set('currentDimensionType', 'percent.percent_' + this._converterGetPropertyAttributes()); + } + this.set('unitLabel', Em.getWithDefault(this.get('unitLabelMap'), widgetUnit, widgetUnit)); + }, + + /** * Draw slider for current config * @method initSlider */ @@ -178,23 +198,22 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ var self = this, config = this.get('config'), valueAttributes = config.get('stackConfigProperty.valueAttributes'), - unit = Em.getWithDefault(valueAttributes, 'unit', ''), parseFunction = this.get('parseFunction'), - ticks = [valueAttributes.minimum], + ticks = [this.widgetValueByConfigAttributes(valueAttributes.minimum)], ticksLabels = [], - defaultValue = this.valueForTick(+config.get('defaultValue')), + defaultValue = this.widgetValueByConfigAttributes(this.valueForTick(+config.get('defaultValue'))), defaultValueMirroredId, defaultValueId; // ticks and labels for (var i = 1; i <= 3; i++) { - var val = (valueAttributes.minimum + valueAttributes.maximum) / 4 * i; + var val = this.widgetValueByConfigAttributes((valueAttributes.minimum + valueAttributes.maximum)) / 4 * i; // if value's type is float, ticks may be float too ticks.push(this.valueForTick(val)); } - ticks.push(valueAttributes.maximum); + ticks.push(this.widgetValueByConfigAttributes(valueAttributes.maximum)); ticks.forEach(function (tick, index) { - ticksLabels.push(index % 2 === 0 ? tick + ' ' + unit : ''); + ticksLabels.push(index % 2 === 0 ? tick + ' ' + self.get('unitLabel') : ''); }); // process additional tick for default value if it not defined in previous computation if (!ticks.contains(defaultValue)) { @@ -219,7 +238,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ } var slider = new Slider(this.$('input.slider-input')[0], { - value: parseFunction(this.get('config.value')), + value: this.widgetValueByConfigAttributes(parseFunction(this.get('config.value'))), ticks: ticks, tooltip: 'hide', ticks_labels: ticksLabels, @@ -229,7 +248,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ slider.on('change', function (obj) { var val = parseFunction(obj.newValue); - self.set('config.value', '' + val); + self.set('config.value', '' + self.configValueByWidget(val)); self.set('mirrorValue', val); }).on('slideStop', function() { /** @@ -270,7 +289,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ * @returns {Number} */ valueForTick: function(val) { - return this.get('config.stackConfigProperty.valueAttributes').type === 'int' ? Math.round(val) : parseFloat(val.toFixed(1)); + return this.get('config.stackConfigProperty.valueAttributes').type === 'int' ? Math.round(val) : parseFloat(val.toFixed(2)); }, /** @@ -281,7 +300,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ restoreValue: function () { this._super(); var parseFunction = this.get('parseFunction'), - val = parseFunction(this.get('config.value')); + val = this.widgetValueByConfigAttributes(parseFunction(this.get('config.value'))); this.get('slider').setValue(val); this.set('mirrorValue', val); }, @@ -311,10 +330,10 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({ self.get('slider').destroy(); self.initSlider(); if (self.get('config.value') > Em.get(valueAttributes, 'maximum')) { - self.set('mirrorValue', Em.get(valueAttributes, 'maximum')) + self.set('mirrorValue', this.widgetValueByConfigAttributes(Em.get(valueAttributes, 'maximum'))); } if (self.get('config.value') < Em.get(valueAttributes, 'minimum')) { - self.set('mirrorValue', Em.get(valueAttributes, 'minimum')) + self.set('mirrorValue', this.widgetValueByConfigAttributes(Em.get(valueAttributes, 'minimum'))); } self.toggleWidgetState(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/test/mixins/unit_convert/base_unit_convert_mixin_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/unit_convert/base_unit_convert_mixin_test.js b/ambari-web/test/mixins/unit_convert/base_unit_convert_mixin_test.js index 4dee612..9f07581 100644 --- a/ambari-web/test/mixins/unit_convert/base_unit_convert_mixin_test.js +++ b/ambari-web/test/mixins/unit_convert/base_unit_convert_mixin_test.js @@ -98,10 +98,56 @@ describe('App.BaseUnitConvertMixin', function() { { type: 'minutes', value: 1} ] }, + { + value: 80, + fromUnit: 'percent', + toUnit: 'int', + currentDimensionType: 'percent.percent_int', + e: 80 + }, + { + value: 80, + fromUnit: 'int', + toUnit: 'percent', + currentDimensionType: 'percent.percent_int', + e: 80 + }, + { + value: 0.89, + fromUnit: 'float', + toUnit: 'percent', + currentDimensionType: 'percent.percent_float', + e: 89 + }, + { + value: 89, + fromUnit: 'percent', + toUnit: 'float', + currentDimensionType: 'percent.percent_float', + e: 0.89 + }, + { + value: 100, + fromUnit: 'percent', + toUnit: 'float', + currentDimensionType: 'percent.percent_float', + e: 1 + }, + { + value: 1, + fromUnit: 'float', + toUnit: 'percent', + currentDimensionType: 'percent.percent_float', + e: 100 + } ]; tests.forEach(function(test) { it('should convert {0} {1} to {2} {3}'.format(JSON.stringify(test.value), test.fromUnit, JSON.stringify(test.e), test.toUnit), function() { + if (test.currentDimensionType) { + this.mixin.set('currentDimensionType', test.currentDimensionType); + } + var result = this.mixin.convertValue(test.value, test.fromUnit, test.toUnit); if (Em.isArray(result)) { result = result.map(function(item) { http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/test/views/common/configs/widgets/combo_config_widget_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/widgets/combo_config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/combo_config_widget_view_test.js index 6c0eb55..7e8a768 100644 --- a/ambari-web/test/views/common/configs/widgets/combo_config_widget_view_test.js +++ b/ambari-web/test/views/common/configs/widgets/combo_config_widget_view_test.js @@ -35,8 +35,16 @@ describe('App.ComboConfigWidgetView', function() { var tests = [ { valueAttributes: { - entry_labels: ["Item A", "Item B"], - entries: ["a", "b"] + entries: [ + { + label: "Item A", + value: "a" + }, + { + label: "Item B", + value: "b" + }, + ] }, e: [ { http://git-wip-us.apache.org/repos/asf/ambari/blob/2bb9aa2d/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js index 25346b2..8d04325 100644 --- a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js +++ b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js @@ -18,7 +18,7 @@ var App = require('app'); -var viewInt, viewFloat; +var viewInt, viewFloat, viewPercent; describe('App.SliderConfigWidgetView', function () { @@ -42,12 +42,17 @@ describe('App.SliderConfigWidgetView', function () { minimum: '0', maximum: '2096', unit: 'MB' + }), + widget: Em.Object.create({ + type: 'slider', + units: [{ 'unit-name': 'MB'}] }) }) }) }); viewInt.willInsertElement(); viewInt.didInsertElement(); + viewFloat = App.SliderConfigWidgetView.create({ initSlider: Em.K, initPopover: Em.K, @@ -66,26 +71,65 @@ describe('App.SliderConfigWidgetView', function () { type: 'float', minimum: '0', maximum: '100', - unit: '%' + }), + widget: Em.Object.create({ + type: 'slider', + units: [{ 'unit-name': 'float'}] }) }) }) }); viewFloat.willInsertElement(); viewFloat.didInsertElement(); + + viewPercent = App.SliderConfigWidgetView.create({ + initSlider: Em.K, + initPopover: Em.K, + slider: { + enable: Em.K, + disable: Em.K, + setValue: Em.K + }, + config: Em.Object.create({ + name: 'a.b.c3', + description: 'A B C 3', + value: '0.22', + defaultValue: '0.22', + stackConfigProperty: Em.Object.create({ + valueAttributes: Em.Object.create({ + type: 'float', + minimum: '0', + maximum: '0.8', + }), + widget: Em.Object.create({ + type: 'slider', + units: [{ 'unit-name': 'percent'}] + }) + }) + }) + }); + viewPercent.willInsertElement(); + viewPercent.didInsertElement(); + sinon.stub(viewInt, 'changeBoundaries', Em.K); sinon.stub(viewFloat, 'changeBoundaries', Em.K); + sinon.stub(viewPercent, 'changeBoundaries', Em.K); }); afterEach(function() { viewInt.changeBoundaries.restore(); viewFloat.changeBoundaries.restore(); + viewPercent.changeBoundaries.restore(); }); describe('#mirrorValue', function () { it('should be equal to config.value after init', function () { - expect(viewInt.get('mirrorValue')).to.equal('' + viewInt.get('config.value')); - expect(viewFloat.get('mirrorValue')).to.equal('' + viewFloat.get('config.value')); + expect('' + viewInt.get('mirrorValue')).to.equal(viewInt.get('config.value')); + expect('' + viewFloat.get('mirrorValue')).to.equal(viewFloat.get('config.value')); + }); + + it('should be converted according to widget format', function() { + expect(viewPercent.get('mirrorValue')).to.equal(22); }); }); @@ -115,6 +159,17 @@ describe('App.SliderConfigWidgetView', function () { expect(viewFloat.get('config.errorMessage')).to.have.property('length').that.is.least(1); }); + it('check percent', function () { + viewPercent.set('mirrorValue', 32); + expect(viewPercent.get('isMirrorValueValid')).to.be.true; + expect(viewPercent.get('config.value')).to.equal('0.32'); + expect(viewPercent.get('config.errorMessage')).to.equal(''); + + viewPercent.set('mirrorValue', 100500.5); + expect(viewPercent.get('isMirrorValueValid')).to.be.false; + expect(viewPercent.get('config.value')).to.equal('0.32'); + expect(viewPercent.get('config.errorMessage')).to.have.property('length').that.is.least(1); + }); }); describe('#prepareValueAttributes', function () { @@ -145,4 +200,4 @@ describe('App.SliderConfigWidgetView', function () { }); -}); \ No newline at end of file +});