Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
outlinetrue

A stack is a distribution collection of a set of services. Multiple versions of a stack can be defined, each with its own set of services. Stacks in Ambari are defined in  ambari-server/src/main/resources/stacks folder, which can be found at /var/lib/ambari-server/resources/stacks folder after install.

...

 Question: When do I define service in common-services vs. stacks folders?

One would define services in the common-services folder if there is possibility of the service being used in multiple stacks. For example, almost all stacks would need the HDFS service - so instead of redefining HDFS in each stack, the one defined in common-services is referenced from multiple stack-versionsLikewise, if a service is going to be contained in only one stack and never going to be shared, it can be defined in the stacks folder. Basically services defined in stacks folder are by used containment, whereas the ones defined in common-services are used by reference. 

...

metainfo.xml

In the metainfo.xml file service descriptor, one can first define the service and its components.

Complete reference can be found in the Writing metainfo.xml page.
A good reference implementation is the HDFS metainfo.xml.

 

Question: Is it possible to define multiple services in the same metainfo.xml?

Yes. Though it is possible, it is discouraged to define multiple services in the same service folder.

YARN and MapReduce2 are services that are defined together in the YARN folder.  Its metainfo.xml defines both services.

...

If the service is supported on multiple OSes which requires separate scripts, the base resource_management.Script class can be extended with different @OsFamilyImpl() annotations. 
This allows for ability to extend only those the separation of only OS specific methods of the component management.
Example: NameNode default script,  NameNode Windows script. 

Examples

NameNode Start, Stop.

DataNode Start and Stop.

HDFS configurations persistence

...

As an example, we show the Rebalance HDFS custom action implemented by HDFS.

Stack Changes

  1. Define custom command inside the customCommands section of the component in metainfo.xml.
  2. Implement method with same name as custom command in script referenced from metainfo.xml.
    1. If custom command does not have OS variants, it can be implemented in the same class that extends resource_management.Script
    2. If there are OS variants, different methods can be implemented in each class annotated by @OsFamilyImpl(os_family=...). Default rebalancehdfs, Windows rebalancehdfs.

This will provide ability by the backend to run the script on all managed hosts where the service is installed.

...

Question: How do I provide my own label and icon for the custom action in UI?

In Ambari UI, add your component action to the App.HostComponentActionMap object with custom icon and name. Ex: REBALANCEHDFS.

Configuration

Configuration files for a service should be placed by default in the configuration folder.
If a different named folder has to be used, the <configuration-dir> element can be used in metainfo.xml to point to that folder.

...