Checking out Ambari source
The following uses the Ambari git repository for the development process. Please keep in mind that the git repository is read only and patches will have to be uploaded and committed via svn.
git clone git://git.apache.org/ambari.git cd ambari
We'll refer to the top-level "ambari" directory as AMBARI_DIR
in this document.
Tools needed to build Ambari
- JDK 1.6.0
- Apache Maven
- Python 2.6
- Python setuptools - Download and run:
sh setuptools-0.6c11-py2.6.egg
- NodeJS
- Brunch 1.4.4 (to install it, run the following command after NodeJS is installed):
npm install -g brunch@1.4.4
Building Ambari
To build Ambari RPMs, run:
RHEL/CentOS 5:
mvn -X -B -e clean install package rpm:rpm -DskipTests -Pcentos5 -Dpython.ver="python26"
RHEL/CentOS 6:
mvn -X -B -e clean install package rpm:rpm -DskipTests -Dpython.ver="python >= 2.6"
SUSE/SLES 11:
mvn -X -B -e clean install package rpm:rpm -DskipTests -Psuse11 -Dpython.ver="python >= 2.6"
Ambari Server RPM will be created under AMBARI_DIR
/ambari-server/target/rpm/ambari-server/RPMS/noarch.
Ambari Agent RPM will be created under AMBARI_DIR
/ambari-agent/target/rpm/ambari-agent/RPMS/x86_64.
NOTE: Run everything as root
below.
Running the Ambari Server
First, install the Ambari Server RPM.
On RHEL/CentOS:
yum install ambari-server-*.rpm
On SUSE/SLES:
zypper install ambari-server-*.rpm
Initialize Ambari Server:
ambari-server setup
Start up Ambari Server:
ambari-server start
See Ambari Server log:
tail -f /var/log/ambari-server/ambari-server.log
To access Ambari, go to
http://{ambari-server-hostname}:8080
from your web browser and log in with username admin and password admin.
Install and Start the Ambari Agent Manually on Each Host in the Cluster
Install the Ambari Agent RPM.
On RHEL/CentOS:
yum install ambari-agent-*.rpm
SUSE/SLES:
zypper install ambari-agent-*.rpm
Edit the location of Ambari Server in /etc/ambari-agent/conf/ambari-agent.ini by editing the hostname line.
Start Ambari Agent:
ambari-agent start
See Ambari Agent log:
tail -f /var/log/ambari-agent/ambari-agent.log
Setting up Ambari in Eclipse
$ mvn clean eclipse:eclipse
After doing the above you should be able to import the project via Eclipse "Import > Maven > Existing Maven Project". Choose the root directory where you cloned the git repository. You should be able to see the following projects on eclipse:
ambari | |- ambari-project |- ambari-server |- ambari-agent |- ambari-web
Select the top-level "ambari pom.xml" and click Finish.
Coding Guidelines for Ambari.
Ambari Web Frontend Development Environment
Application Assembler: Brunch
We use Brunch as the client-side application assembler: http://brunch.io/
Brunch can:
Generate an application skeleton that is well structured with common client-side libraries (Backbone.js/Ember.js, jQuery, JavaScript/CoffeeScript, Stylus/LESS, etc)
Build and deploy automatically in the background as you modify the source files.
This lets you break up the application into a number of JS files for code organization and reuse without worrying about runtime load performance.
For QA/production deployment, we can turn on JavaScript/CSS minification for fast application loading.
Run automated tests.
Run a Node.js-based web server with a single command so that you can easily run the application from the application root directory without any special configuration.
Install Node.js from http://nodejs.org/.
We have created a Brunch-based application and checked it into Github. To check out the project from the Github repository, run:
git clone git@github.com:hortonworks/ambari
cd ambari-web
sudo npm install -g brunch
npm install
To run the web server (and to enable continuous build/deploy), run:
brunch watch --server
Or use the shorthand: brunch w --s
IDE: PhpStorm
All front-end developers should use PhpStorm by JetBrains.
JetBrains has granted all contributors of Apache Ambari a free license for PhpStorm and IntelliJ (if you also need to do Java development - IntelliJ is a superset of PhpStorm, but PhpStorm is lighter so it is recommended if you are not modifying Java code).
IDE Plugins
Go to Preferences->Plugins->Browse repositories and install “Node.js” and “Handlebars” plugins.
Coding Conventions
Before checking in any HTML/JavaScript/CSS files, they must be formatted with the IDE to maintain consistency.
Also, the IDE will give warnings in the editor about implicit globals, etc. Fix these warnings before checking in code.
IDE Code Formatting Customization
We will use all default settings for Code Style in the IDE, except for the following:
Go to Preferences
Code Style->General
Line separator (for new files): Unix
Make sure “Use tab character” is NOT checked
Tab size: 2
Indent: 2
Continuation indent: 2
Code Style->JavaScript:
Tabs and Indents
Make sure “use tab character” is NOT checked
Set Tab size, Indent, and Continuation indent to “2”.
Spaces->Other
Turn on “After name-value property separator ‘:’
In general, the following conventions should be followed for all JavaScript code: http://javascript.crockford.com/code.html
Exceptions to the rule from the above:
We use 2 spaces instead of 4.
Variable Declarations:
“It is preferred that each variable be given its own line and comment. They should be listed in alphabetical order.”
Comment only where it makes sense. No need to do alphabetical sorting.
“JavaScript does not have block scope, so defining variables in blocks can confuse programmers who are experienced with other C family languages. Define all variables at the top of the function.”
This does not need to be followed.
Unit Testing
Unit tests are written using Mocha.
Run unit tests via
brunch test