You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by Juanjo Marron <ju...@yahoo.com.INVALID> on 2016/02/09 03:06:01 UTC

Redefine Themes and Themes inheritance

Hi all,

Couple of questions related with themes inheritance and redefinition: 

1. Is there any way to add a new section and configurations to display on an existing themes file? 

For HBASE in HDP stack I saw initial themes is defined in 2.2 stack and in 2.3 some configuration/widgets are removed (pointed to null).

For RANGER, two theme files are defined with different name for HDP 2.2 (theme_version_1.json) and HDP 2.3 (theme_version_2,.json). New section, properties and widget are added in version_2 compared with version_1.

My doubt is, is it possible to overwrite theme.json file to add new subsection similar to the merge process .xml files are doing or it needs to be complete redefined?



2. How is the design for merging theme.json file?

In case a service has some theme.json file inherited from the previous stack (stack inheritance) and the new stack version also extends a common-service definition with themes on it (service inheritance). Are they merged? Does the new one defined in common services overwrite the stack inherited one?

A good example could be if HBASE in HDP 2.3 extends a new common-service definition (lets say 1.2.0.2.3) with a new theme definition, and HDP 2.3 receives also a theme file from previous HDP 2.2 stack inheritance.

I'm facing java errors when trying to merge theme.json files with a scenario similar to the one  detailed below. Im not sure if the java code (org.apache.ambari.server.state.theme.Section.mergeWithParent) is supporting this double inheritance stack& service for theme .json files.

Does anyone have some insight on it?

Thanks for your help


Re: Redefine Themes and Themes inheritance

Posted by Juanjo Marron <ju...@yahoo.com.INVALID>.
Missing the json files in previous email. Sorry for that.

Once again thank for your time and I really appreciate your help Srimanth

Best regards
 

    On Tuesday, February 9, 2016 5:54 PM, Juanjo Marron <ju...@yahoo.com> wrote:
 

 Hi Srimanth,

Sure it helps. Thanks for your prompt reply and the details provided.

My goal might sound familiar, Im just trying to add PHOENIX support for HBASE in a new stack definition since I was not present in my previous one. 
So I need to add on themes a couple of Phoenix widgets, their placements, one new Phoenix SQL section and its subsection.

Based on your answer, and after several tries I made some progress and now I'm able to merge both theme.json files and add the new widgets and its placement on the child theme (I can see them when querying the restAPI for my new version of themes), but the new widgets  never get displayed on the UI.
I'm still having issues to merge the new section for the configuration:layout property and it never makes it to the restAPI call.

The original themes is attached with name original_theme.jsonThe new themes is attached with name V1_new_theme.json. It is mainly:

{
  "configuration" : {
    "layouts": [
      {
        "name": "default",
        "tabs": [
          {
            "name": "settings",
              "sections": [
                {
                  "name": "section-hbase-phoenix",
                  "display-name": "Phoenix SQL",
                  ......

With this V1_new_theme.json, tabs return empty on the rest call

         "layouts" : [
            {
              "name" : "default",
              "tabs" : [ ]
            }
          ]
        }
      }

Do I need to maintaing tabs:[], sections: [], layout: [] design or just declaring the name?

If I try to just declare the names as shown in attached V2_new_theme.json:

{
  "configuration" : {
    "layouts": [
      {
        "name": "default",
            "name": "settings",
                  "name": "section-hbase-phoenix",
                  "display-name": "Phoenix SQL",
                  "row-index": "2",
                  "column-index": "2",
                  .....

The layout is similar to the parent but it is missing the new section                  
                  

      
Addtionally if I try to overwrite the whole layouts property instead (complete_layout_theme.json) , ambari-server is not able to start showing  NPE. The issue is merging section inside layouts

1 error
        at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013)
        at org.apache.ambari.server.controller.AmbariServer.main(AmbariServer.java:812)
Caused by: java.lang.NullPointerException
        at org.apache.ambari.server.state.theme.Section.mergeWithParent(Section.java:157)
        at org.apache.ambari.server.state.theme.TabLayout.mergedSections(TabLayout.java:95)
        at org.apache.ambari.server.state.theme.TabLayout.mergeWithParent(TabLayout.java:79)
        at org.apache.ambari.server.state.theme.Tab.mergeWithParent(Tab.java:71)
        at org.apache.ambari.server.state.theme.Layout.mergeTabs(Layout.java:75)
        at org.apache.ambari.server.state.theme.Layout.mergeWithParent(Layout.java:60)
        at org.apache.ambari.server.state.theme.ThemeConfiguration.mergeLayouts(ThemeConfiguration.java:105)

  

Re: Redefine Themes and Themes inheritance

Posted by Juanjo Marron <ju...@yahoo.com.INVALID>.
Hi Srimanth,

Sure it helps. Thanks for your prompt reply and the details provided.

My goal might sound familiar, Im just trying to add PHOENIX support for HBASE in a new stack definition since I was not present in my previous one. 
So I need to add on themes a couple of Phoenix widgets, their placements, one new Phoenix SQL section and its subsection.

Based on your answer, and after several tries I made some progress and now I'm able to merge both theme.json files and add the new widgets and its placement on the child theme (I can see them when querying the restAPI for my new version of themes), but the new widgets  never get displayed on the UI.
I'm still having issues to merge the new section for the configuration:layout property and it never makes it to the restAPI call.

The original themes is attached with name original_theme.jsonThe new themes is attached with name V1_new_theme.json. It is mainly:

{
  "configuration" : {
    "layouts": [
      {
        "name": "default",
        "tabs": [
          {
            "name": "settings",
              "sections": [
                {
                  "name": "section-hbase-phoenix",
                  "display-name": "Phoenix SQL",
                  ......

With this V1_new_theme.json, tabs return empty on the rest call

         "layouts" : [
            {
              "name" : "default",
              "tabs" : [ ]
            }
          ]
        }
      }

Do I need to maintaing tabs:[], sections: [], layout: [] design or just declaring the name?

If I try to just declare the names as shown in attached V2_new_theme.json:

{
  "configuration" : {
    "layouts": [
      {
        "name": "default",
            "name": "settings",
                  "name": "section-hbase-phoenix",
                  "display-name": "Phoenix SQL",
                  "row-index": "2",
                  "column-index": "2",
                  .....

The layout is similar to the parent but it is missing the new section                  
                  

      
Addtionally if I try to overwrite the whole layouts property instead (complete_layout_theme.json) , ambari-server is not able to start showing  NPE. The issue is merging section inside layouts

1 error
        at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013)
        at org.apache.ambari.server.controller.AmbariServer.main(AmbariServer.java:812)
Caused by: java.lang.NullPointerException
        at org.apache.ambari.server.state.theme.Section.mergeWithParent(Section.java:157)
        at org.apache.ambari.server.state.theme.TabLayout.mergedSections(TabLayout.java:95)
        at org.apache.ambari.server.state.theme.TabLayout.mergeWithParent(TabLayout.java:79)
        at org.apache.ambari.server.state.theme.Tab.mergeWithParent(Tab.java:71)
        at org.apache.ambari.server.state.theme.Layout.mergeTabs(Layout.java:75)
        at org.apache.ambari.server.state.theme.Layout.mergeWithParent(Layout.java:60)
        at org.apache.ambari.server.state.theme.ThemeConfiguration.mergeLayouts(ThemeConfiguration.java:105)

Re: Redefine Themes and Themes inheritance

Posted by Srimanth Gunturi <sg...@hortonworks.com>.
Hello,
The way merging with parent themes happens is by the 'name' property for layouts, and 'config' property for placements and widgets.
Which means that you can override in a child the entire layout, tab, section, sub-section defined in the parent. 
You can also change and delete the placements of configs.
You can also change the type of widgets for a config.

So getting back to your questions:
> 1. Is there any way to add a new section and configurations to display on an existing themes file?

Yes - can you please try in your child theme to define a layout and tab with the same 'name' as parent, and then add a section with a new 'name'.
If you want to remove a section, subsection, etc. from the parent, just define it in the child with same name, but with empty values.

> Does the new one defined in common services overwrite the stack inherited one?
Themes are only defined in the stacks/ folder - not in common-services... so you would not hit this situation.

If you are still unable to get it to work, maybe you can share the exception, and maybe the parent and child themes.
Hope this helps.
Regards,
Srimanth




________________________________________
From: Juanjo Marron <ju...@yahoo.com.INVALID>
Sent: Monday, February 08, 2016 6:06 PM
To: Ambari
Subject: Redefine Themes and Themes inheritance

Hi all,

Couple of questions related with themes inheritance and redefinition:

1. Is there any way to add a new section and configurations to display on an existing themes file?

For HBASE in HDP stack I saw initial themes is defined in 2.2 stack and in 2.3 some configuration/widgets are removed (pointed to null).

For RANGER, two theme files are defined with different name for HDP 2.2 (theme_version_1.json) and HDP 2.3 (theme_version_2,.json). New section, properties and widget are added in version_2 compared with version_1.

My doubt is, is it possible to overwrite theme.json file to add new subsection similar to the merge process .xml files are doing or it needs to be complete redefined?



2. How is the design for merging theme.json file?

In case a service has some theme.json file inherited from the previous stack (stack inheritance) and the new stack version also extends a common-service definition with themes on it (service inheritance). Are they merged? Does the new one defined in common services overwrite the stack inherited one?

A good example could be if HBASE in HDP 2.3 extends a new common-service definition (lets say 1.2.0.2.3) with a new theme definition, and HDP 2.3 receives also a theme file from previous HDP 2.2 stack inheritance.

I'm facing java errors when trying to merge theme.json files with a scenario similar to the one  detailed below. Im not sure if the java code (org.apache.ambari.server.state.theme.Section.mergeWithParent) is supporting this double inheritance stack& service for theme .json files.

Does anyone have some insight on it?

Thanks for your help