Overview

One of the new features introduced in Ambari 2.1 is the theme framework. This new tool improves the visualization of services configuration for the components taking part on Ambari stack, providing enhanced configuration controls like Sliders, Spinners, Combos, Toggles, etc. (see image below). It also leverages the visualization of services configuration adding shortcuts to the most common configuration parameters.

 

Controls in themes

Ambari Open Source code from version 2.1.0 includes enhanced configurations for core Hadoop services (HDFS, YARN, MapReduce, Hive and HBase) based on the theme framework. The code for these new features can be seen inside respective service folders in the stacks definition.

How to use theme framework

In order to introduce theme features to an existing service, the following steps are required :

 1. Define themes property

A new themes property needs to be defined in metainfo.xml service file.
The new property needs to be declared inside the service definition to be able to import theme.json file as default theme.

[code language=”xml”] <service>
<themes>
<theme>
<fileName>theme.json</fileName>
<default>true</default>
</theme>
</themes>
<service>
[/code]

 

This is a complete example of HDFS metainfo.xml file.

 

2. Create theme json file

A new theme.json file has to be created inside themes folder in the stack service definition.

Theme directory structure

The theme.json file should have ‘configuration’ object including the properties: ‘layouts’, ‘placement’ and ‘widgets’, where:
‘layouts’ determines the tabs and sections/subsections within respective tabs. It set the general layout of the configurations.
‘placement’ determines which configurations go into what sub-sections.
‘widgets’ determines which UI widget to use for respective configurations. Also, UI specific metadata can be specified here, like what units the value should be shown in¬† MB, GB, days, etc.

 

This is a theme.json file skeleton for a TEST service. It introduces two sections and a couple of properties as example:

[code language=”xml”]

{
"name": "default",
"description": "Default theme for TEST service",
"configuration": {
"layouts": [
{
"name": "default",
"tabs": [
{
"name": "settings",
"display-name": "Settings",
"layout": {
"tab-columns": "3",
"tab-rows": "3",
"sections": [
{
"name": "section-test-config1",
"display-name": "Section1",
"row-index": "0",
"column-index": "0",
"row-span": "1",
"column-span": "2",
"section-columns": "2",
"section-rows": "1",
"subsections": [
{
"name": "subsection-test-config-col1",
"row-index": "0",
"column-index": "0",
"row-span": "1",
"column-span": "1"
},
{
"name": "subsection-test-config-col2",
"row-index": "0",
"column-index": "1",
"row-span": "1",
"column-span": "1"
}
] },
{
"name": "section-test-config2",
"display-name": "Section2",
"row-index": "0",
"column-index": "2",
"row-span": "1",
"column-span": "1",
"section-columns": "1",
"section-rows": "1",
"subsections": [
{
"name": "subsection-test-config-col1",
"row-index": "0",
"column-index": "0",
"row-span": "1",
"column-span": "1"
}
] }
] …….

}
}
] }
],
"placement": {
"configuration-layout": "default",
"configs": [
{
"config": "test-env/test_heapsize",
"subsection-name": "subsection-test-config-col1"
},

………

{
"config": "test-site/query.timeoutMs",
"subsection-name": "subsection-test-config-col2"
}
] },
"widgets": [
{
"config": "test-env/test_heapsize",
"widget": {
"type": "slider",
"units": [
{
"unit-name": "GB"
}
] }
},

……

{
"config": "test-site/query.timeoutMs",
"widget": {
"type": "time-interval-spinner",
"units": [
{
"unit-name": "minutes,seconds"
}
] }
}
] }
}
[/code]

 

The result of this basic theme example for a TEST service would be:

Theme example

For a complete functional example visit the theme.json file for any of the core Hadoop services supported in the Ambari code. For example HDFS.

3. Define non-UI metadata for configuration properties

Configuration properties displayed via theme framework need additional non-UI metadata in their definition. Commonly in the -env.xml or -site.xml files. For instance, fields like <display-name>, additional value attributes  like: <minimum>, <maximum>, <increment-step>, <unit> etc.  and dependencies <depends-on> if needed.

This is an example of definition for a configuration property used in the previous skeleton:

[code language=”xml”]

<property>
<name>test_heapsize</name>
<value>4096</value>
<description>Maximum amount of memory each Test Master can use.</description>
<display-name>TEST Maximum Memory</display-name>
<value-attributes>
<type>int</type>
<minimum>1024</minimum>
<maximum>16384</maximum>
<unit>MB</unit>
<increment-step>256</increment-step>
</value-attributes>
</property>

[/code]

 

Following these steps should allow you to introduce enhanced configurations for the services that are part of your BigInsights stack.

Join The Discussion

Your email address will not be published. Required fields are marked *