Ambari code checkout and build instructions are available in Ambari Development page.
Ambari design and architecture is detailed in Ambari Design page.
Understanding the architecture of Ambari is helpful in navigating code easily.
Ambari's source has the following layout
ambari/ ambari-agent/ ambari-common/ ambari-project/ ambari-server/ ambari-views/ ambari-web/ contrib/ docs/
Major components of Ambari reside in their own sub-folders under the root folder, to maintain clean separation of code.
Folder | Component or purpose |
---|---|
| Code for the main Ambari server which manages Hadoop through the agents installed on each node. |
| Code for the Ambari agents which run on each node that the server above manages. |
| Code for Ambari Web UI which interacts with the Ambari server above. |
| Code for Ambari Views, the framework for extending the Ambari Web UI. |
| Any common code between Ambari Server and Agents. |
| Code for any custom contributions Ambari makes to other third party software or libraries. |
| Basic Ambari documentation, including the Ambari REST API. |
Ambari Server and Agents interact with each other via an internal JSON protocol.
Ambari Web UI interacts with Ambari Server through the documented Ambari REST APIs.
Ambari-Server
Ambari-Agent
Ambari-Views
Ambari-Web
The Ambari Web UI is a purely browser side JavaScript application based on the Ember JavaScript framework. A good understanding of Ember is necessary to easily understand the code and its layout.
Being a pure JavaScript application, all UI is rendered locally in browser; with data coming from the Ambari REST APIs provided by the Ambari Server.
ambari-web/ app/ config.coffee package.json pom.xml test/ vendor/
Folder or File | Description |
---|---|
| The main application code. This contains Ember's views, templates, controllers, models, routes, etc. for rendering Ambari UI |
| Brunch application builder configuration file |
| npm package manager configuration file |
| Javascript test files testing functionality written in |
| Third party javascript libraries and stylesheets used. Full list of third party libraries is documented in |
Developers mainly work on javascript and other files in the app/
folder. Once that is done, the final javascript is built using Brunch (a HTML5 application assembler based on node.js) into the /ambari/ambari-web/public/
folder. This folder contains the index.html
which bootstraps the Ambari web application.
Developers while working should use the
brunch w
command to launch Brunch in watch mode where it re-generates the final application on any change. Similarly
brunch watch --server (or use the shorthand: brunch w -s)
launches a HTTP server at http://localhost:3333 serving the final application. This is helpful in seeing UI with mock data, without the entire Ambari server deployed.
Note: see "Coding Guidelines for Ambari" for more details on building and running Ambari Web locally.
ambari-web/app/
Since ambari-web/app/
folder is where developers spend a majority of time, the major files and their purpose is listed below.
Folder or File | Description |
---|---|
| Mock data under |
| The C in MVC. Ember controllers for the main application |
| Meta data for the application (UI metadata, server data metadata, etc.) |
| Classes which map server side JSON data structures into client side Ember models. |
| The M in MVC. Ember Data models used. Clusters, Services, Hosts, Alerts, etc. models are defined here |
| Ember routes defining the various page redirections in the application. |
| CSS stylesheets represented in the less format. This is compiled by Brunch into the |
| The V in MVC. Contains all the Ember views of the application. Main application views under |
| The HTML templates used by the views above. Generally a view will have a template file. Sometimes views define the template content in themselves as strings |
| The main Ember application |
| Main configuration file for the javascript application. Developer can keep application in test mode using the |
If a developer adds, removes, or renames a model, view, controller, template, route, they should update the corresponding entry in models.js, views.js, controllers.js, templates.js, routes.js
files.