You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2015/04/06 20:54:31 UTC
ambari git commit: AMBARI-10371. Create HBase theme based enhanced
configs
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 <sg...@hortonworks.com>
Authored: Mon Apr 6 11:12:56 2015 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
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 @@
<unit>milliseconds</unit>
</value-attributes>
</property>
-
+
<property>
<name>hbase.regionserver.global.memstore.lowerLimit</name>
<value>0.38</value>
@@ -145,9 +145,17 @@
<display-name>Per-Column Family Memstore Block Multiplier</display-name>
<value-attributes>
<type>value-list</type>
- <entries>2</entries>
- <entries>4</entries>
- <entries>8</entries>
+ <entries>
+ <entry>
+ <value>2</value>
+ </entry>
+ <entry>
+ <value>4</value>
+ </entry>
+ <entry>
+ <value>8</value>
+ </entry>
+ </entries>
<selection_cardinality>1</selection_cardinality>
</value-attributes>
</property>
@@ -162,10 +170,10 @@
<display-name>Per-Column Family Memstore Flush Size</display-name>
<value-attributes>
<type>int</type>
- <minimum>32</minimum>
- <maximum>256</maximum>
- <step-increment>1</step-increment>
- <unit>MB</unit>
+ <minimum>33554432</minimum>
+ <maximum>268435456</maximum>
+ <step-increment>1048576</step-increment>
+ <unit>B</unit>
</value-attributes>
</property>
<property>
@@ -263,9 +271,17 @@
<display-name>Maximum Files in a Store before Compaction</display-name>
<value-attributes>
<type>int</type>
- <entries>2</entries>
- <entries>3</entries>
- <entries>4</entries>
+ <entries>
+ <entry>
+ <value>2</value>
+ </entry>
+ <entry>
+ <value>3</value>
+ </entry>
+ <entry>
+ <value>4</value>
+ </entry>
+ </entries>
</value-attributes>
</property>
<property>
@@ -275,7 +291,7 @@
The number of times the region flush operation will be retried.
</description>
</property>
-
+
<property>
<name>hbase.hstore.blockingStoreFiles</name>
<value>10</value>
@@ -321,8 +337,14 @@
<display-name>Enable Authentication</display-name>
<value-attributes>
<type>value-list</type>
- <entries>true</entries>
- <entries>false</entries>
+ <entries>
+ <entry>
+ <value>true</value>
+ </entry>
+ <entry>
+ <value>false</value>
+ </entry>
+ </entries>
<selection_cardinality>1</selection_cardinality>
</value-attributes>
</property>
@@ -335,8 +357,14 @@
<display-name>Enable Authorization</display-name>
<value-attributes>
<type>value-list</type>
- <entries>true</entries>
- <entries>false</entries>
+ <entries>
+ <entry>
+ <value>true</value>
+ </entry>
+ <entry>
+ <value>false</value>
+ </entry>
+ </entries>
<selection_cardinality>1</selection_cardinality>
</value-attributes>
</property>
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 @@
<description>Pid Directory for HBase.</description>
</property>
<property>
- <name>hbase_regionserver_heapsize</name>
- <value>1024</value>
- <description>HBase RegionServer Heap Size.</description>
- </property>
- <property>
<name>hbase_regionserver_xmn_max</name>
<value>512</value>
<description>
@@ -51,11 +46,6 @@ and the -Xmn ratio (hbase_regionserver_xmn_ratio) exceeds this value.
<description>Percentage of max heap size (-Xmx) which used for young generation heap (-Xmn).</description>
</property>
<property>
- <name>hbase_master_heapsize</name>
- <value>1024</value>
- <description>HBase Master Heap Size</description>
- </property>
- <property>
<name>hbase_user</name>
<value>hbase</value>
<property-type>USER</property-type>
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.
</description>
</property>
-
+
<property>
<name>hbase.hregion.majorcompaction</name>
<value>604800000</value>
@@ -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.</description>
+ <value-attributes>
+ <type>int</type>
+ <minimum>0</minimum>
+ <maximum>2592000000</maximum>
+ <unit>milliseconds</unit>
+ </value-attributes>
</property>
<property>
<name>hbase.hregion.majorcompaction.jitter</name>
@@ -60,6 +66,20 @@
resultant flush files take a long time to compact or split, or
worse, we OOME.
</description>
+ <value-attributes>
+ <type>value-list</type>
+ <entries>
+ <entry>
+ <value>2</value>
+ </entry>
+ <entry>
+ <value>4</value>
+ </entry>
+ <entry>
+ <value>8</value>
+ </entry>
+ </entries>
+ </value-attributes>
</property>
<property>
<name>hbase.bucketcache.ioengine</name>
@@ -86,4 +106,21 @@
in a region server hits hbase.regionserver.global.memstore.size.lower.limit.
</description>
</property>
+ <property>
+ <name>hbase.regionserver.wal.codec</name>
+ <display-name>Phoenix SQL</display-name>
+ <value>false</value>
+ <value-attributes>
+ <type>value-list</type>
+ <entries>
+ <entry>
+ <value>true</value>
+ </entry>
+ <entry>
+ <value>false</value>
+ </entry>
+ </entries>
+ </value-attributes>
+ <description>Phoenix SQL</description>
+ </property>
</configuration>
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 @@
</osSpecific>
</osSpecifics>
+ <themes>
+ <theme>
+ <fileName>theme.json</fileName>
+ <default>true</default>
+ </theme>
+ </themes>
+
</service>
</services>
</metainfo>
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}}
<div {{bindAttr class="view.isOriginalSCP:original-widget :ui-slider-wrapper"}}>
<div class="pull-left ui-slider-wrapper-inner">{{view Ember.TextField valueBinding="view.config.value" class="input-mini slider-input"}}</div>
- <div class="pull-right ui-slider-label">{{view.mirrorValue}} {{view.config.stackConfigProperty.valueAttributes.unit}}</div>
+ <div class="pull-right ui-slider-label">{{view.mirrorValue}} {{view.unitLabel}}</div>
</div>
<div {{bindAttr class="view.isHover:show:not-show :clearfix"}}>
{{#if view.isOriginalSCP}}
@@ -65,4 +65,4 @@
{{#if view.isComparison}}
{{view App.ConfigWidgetComparisonView serviceConfigPropertyBinding="view.config"}}
{{/if}}
-</div>
\ No newline at end of file
+</div>
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 <code>config.stackConfigProperty.valueAttributes.type</code>)
* 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 <code>mirrorValue</code> 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
+});