You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

Background

The Stack definitions can be found in the source tree at /ambari-server/src/main/resources/stacks. After you install the Ambari Server, the Stack definitions can be found at /var/lib/ambari-server/resources/stacks

The structure of a Stack definition is as follows:

|_ stacks
   |_ <stack_name>
      |_ <stack_version>
         metainfo.xml
         |_ hooks
         |_ repos
            repoinfo.xml
         |_ services
            |_ <service_name>
               metainfo.xml
               metrics.json
               |_ configuration
                  {configuration files}
               |_ package
                  {files, scripts, templates}

Defining a Service and Components

The metainfo.xml file in a Service describes the service, the components of the service and the management scripts to use for executing commands. A component of a service can be either a MASTER, SLAVE or CLIENT category. The <category> tells Ambari what default commands should be available to manage and monitor the component.

For each Component you specify the <commandScript> to use when executing commands. There is a defined set of default commands the component must support.

Component CategoryDefault Commands
MASTERinstall, start, stop, configure, status
SLAVEinstall, start, stop, configure, status
CLIENTinstall, configure, status

Ambari supports different types of commands scripts, for example PYTHON and PUPPET. The type is used to know how to execute the command scripts. You can also create custom commands if there are other commands beyond the default your component needs to support.

For example, in the YARN Service describes the ResourceManager component as follows in metainfo.xml:

        <component>
          <name>RESOURCEMANAGER</name>
          <category>MASTER</category>
          <commandScript>
            <script>scripts/resourcemanager.py</script>
            <scriptType>PYTHON</scriptType>
            <timeout>600</timeout>
          </commandScript>
          <customCommands>
            <customCommand>
              <name>DECOMMISSION</name>
              <commandScript>
                <script>scripts/resourcemanager.py</script>
                <scriptType>PYTHON</scriptType>
                <timeout>600</timeout>
              </commandScript>
            </customCommand>
          </customCommands>
        </component>

The ResourceManager is a MASTER component, and the command script is scripts/resourcemanager.py, which can be found in the services/YARN/package directory. That command script is PYTHON and that script implements the default commands as python methods. This is the install method for the default INSTALL command:

class Resourcemanager(Script):
  def install(self, env):
    self.install_packages(env)
    self.configure(env)

You can also see a custom command is defined DECOMMISSION, which means there is also a decommission method in that python command script:

  def decommission(self, env):
    import params

    ...

    Execute(yarn_refresh_cmd,
            user=yarn_user
    )
    pass

Using Stack Inheritance

Stacks can extend other Stacks in order to share command scripts and configurations. This reduces duplication of code across Stacks with the following:

  • define repositories for the child Stack
  • add new Services in the child Stack (not in the parent Stack)
  • override command scripts of the parent Services
  • override configurations of the parent Services

For example, the HDP 2.1.1 Stack extends HDP 2.0.6 Stack so only the changes applicable to HDP 2.1.1 Stack are present in that Stack definition. This extension is defined in the metainfo.xml for HDP 2.1.1 Stack:

<metainfo>
  <versions>
    <active>true</active>
  </versions>
  <extends>2.0.6</extends>
</metainfo>
  • No labels