How to Contribute to Hadoop Common

This page describes the mechanics of how to contribute software to Hadoop Common. For ideas about what you might contribute, please see the ProjectSuggestions page.

Dev Environment Setup

Here are some things you will need to build and test Hadoop. Be prepared to invest some time to set up a working Hadoop dev environment. Try getting the project to build and test locally first before you start writing code.

Get the source code

First of all, you need the Hadoop source code. The official location for Hadoop is the Apache Git repository. See GitAndHadoop

Read BUILDING.txt

Once you have the source code, we strongly recommend reading BUILDING.txt located in the root of the source tree. It has up to date information on how to build Hadoop on various platforms along with some workarounds for platform-specific quirks. The latest BUILDING.txt for the current trunk can also be viewed on the web.

Integrated Development Environment (IDE)

You are free to use whatever IDE you prefer or your favorite text editor. Note that:

Build Tools

Ensure these are installed by executing mvn, git and javac respectively.

As the Hadoop builds use the external Maven repository to download artifacts, Maven needs to be set up with the proxy settings needed to make external HTTP requests. The first build of every Hadoop project needs internet connectivity to download Maven dependencies.

  1. Be online for that first build, on a good network
  2. To set the Maven proxy setttings, see http://maven.apache.org/guides/mini/guide-proxies.html

  3. Because Maven doesn't pass proxy settings down to the Ant tasks it runs HDFS-2381 some parts of the Hadoop build may fail. The fix for this is to pass down the Ant proxy settings in the build Unix: mvn $ANT_OPTS; Windows: mvn %ANT_OPTS%.

  4. Tomcat is always downloaded, even when building offline. Setting -Dtomcat.download.url to a local copy and -Dtomcat.version to the version pointed to by the URL will avoid that download.

Native libraries

On Linux, you need the tools to create the native libraries: LZO headers,zlib headers, gcc, OpenSSL headers, cmake, protobuf dev tools, and libtool, and the GNU autotools (automake, autoconf, etc).

For RHEL (and hence also CentOS):

yum -y install  lzo-devel  zlib-devel  gcc autoconf automake libtool

For Debian and Ubuntu:

apt-get -y install maven build-essential autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev

Native libraries are mandatory for Windows. For instructions see Hadoop2OnWindows.

Hardware Setup

Making Changes

Before you start, send a message to the Hadoop developer mailing list, or file a bug report in Jira. Describe your proposed changes and check that they fit in with what others are doing and have planned for the project. Be patient, it may take folks a while to understand your requirements. If you want to start with pre-existing issues, look for Jiras labeled newbie.

Modify the source code and add some (very) nice features using your favorite IDE.

But take care about the following points

Generating a patch

Choosing a target branch

Except for the following situations it is recommended that all patches be based off trunk to take advantage of the Jenkins pre-commit build.

  1. The patch is targeting a release branch that is not based off trunk e.g. branch-1, branch-0.23 etc.
  2. The change is targeting a specific feature branch and is not yet ready for merging into trunk.

If you are unsure of the target branch then trunk is usually the best choice. Committers will usually merge the patch to downstream branches e.g. branch-2 as appropriate.

Unit Tests

Please make sure that all unit tests succeed before constructing your patch and that no new javac compiler warnings are introduced by your patch.

For building Hadoop with Maven, use the following to run all unit tests and build a distribution. The -Ptest-patch profile will check that no new compiler warnings have been introduced by your patch.

mvn clean install -Pdist -Dtar -Ptest-patch

Any test failures can be found in the target/surefire-reports directory of the relevant module. You can also run this command in one of the hadoop-common, hadoop-hdfs, or hadoop-mapreduce directories to just test a particular subproject.

Unit tests development guidelines HowToDevelopUnitTests

Javadoc

Please also check the javadoc.

mvn javadoc:javadoc
firefox target/site/api/index.html

Examine all public classes you've changed to see that documentation is complete, informative, and properly formatted. Your patch must not generate any javadoc warnings.

Creating a patch

Check to see what files you have modified with:

git status

Add any new files with:

git add src/.../MyNewClass.java
git add src/.../TestMyNewClass.java

In order to create a patch, type (from the base directory of hadoop):

git diff --no-prefix trunk > HADOOP-1234.patch

This will report all modifications done on Hadoop sources on your local disk and save them into the HADOOP-1234.patch file. Read the patch file. Make sure it includes ONLY the modifications required to fix a single issue.

Please do not:

Please do:

If you need to rename files in your patch:

  1. Write a shell script that uses 'git mv' to rename the original files.
  2. Edit files as needed (e.g., to change package names).
  3. Create a patch file with 'git diff --no-prefix trunk'.
  4. Submit both the shell script and the patch file.

This way other developers can preview your change by running the script and then applying the patch.

Naming your patch

Patches for trunk should be named according to the Jira: jira-xyz.patch, eg hdfs-1234.patch.

Patches for a non-trunk branch should be named jira-xyz-branch.patch, eg hdfs-1234-branch-0.23.patch. The branch name suffix should be the exact name of a Subversion branch under hadoop/common/branches/, such as "branch-0.23". Please note that the Jenkins pre-commit build is only run against trunk.

It's OK to upload a new patch to Jira with the same name as an existing patch. If you select the "Activity>All" tab then the different versions are linked in the comment stream, providing context. However many contributors find it convenient to add a numeric suffix to the patch indicating the patch revision. e.g. hdfs-1234.01.patch, hdfs-1234.02.patch etc.

Testing your patch

Before submitting your patch, you are encouraged to run the same tools that the automated Jenkins patch test system will run on your patch. This enables you to fix problems with your patch before you submit it. The dev-support/test-patch.sh script in the trunk directory will run your patch through the same checks that Hudson currently does except for executing the unit tests.

Run this command from a clean workspace (ie git status shows no modifications or additions) as follows:

dev-support/test-patch.sh /path/to/my.patch

At the end, you should get a message on your console that is similar to the comment added to Jira by Jenkins's automated patch test system, listing +1 and -1 results. For non-trunk patches (prior to HADOOP-7435 being implemented), please copy this results summary into the Jira as a comment. Generally you should expect a +1 overall in order to have your patch committed; exceptions will be made for false positives that are unrelated to your patch. The scratch directory (which defaults to the value of ${user.home}/tmp) will contain some output files that will be useful in determining cause if issues were found in the patch.

Some things to note:

Run the same command with no arguments to see the usage options.

Applying a patch

To apply a patch either you generated or found from JIRA, you can issue

git apply -p0 cool_patch.patch

If you are an Eclipse user, you can apply a patch by : 1. Right click project name in Package Explorer , 2. Team -> Apply Patch

Changes that span projects

You may find that you need to modify both the common project and MapReduce or HDFS. Or perhaps you have changed something in common, and need to verify that these changes do not break the existing unit tests for HDFS and MapReduce. Hadoop's build system integrates with a local maven repository to support cross-project development. Use this general workflow for your development:

Contributing your work

  1. Finally, patches should be attached to an issue report in Jira via the Attach File link on the issue's Jira. Please add a comment that asks for a code review following our code review checklist. Please note that the attachment should be granted license to ASF for inclusion in ASF works (as per the Apache License ยง5).

  2. When you believe that your patch is ready to be committed, select the Submit Patch link on the issue's Jira. Submitted patches will be automatically tested against "trunk" by Hudson, the project's continuous integration engine. Upon test completion, Hudson will add a success ("+1") message or failure ("-1") to your issue report in Jira. If your issue contains multiple patch versions, Hudson tests the last patch uploaded.

  3. Folks should run mvn clean install javadoc:javadoc checkstyle:checkstyle before selecting Submit Patch.

    1. Tests must all pass.
    2. Javadoc should report no warnings or errors.

    3. Checkstyle's error count should not exceed that listed at Checkstyle Errors

  4. Hudson's tests are meant to double-check things, and not be used as a primary patch tester, which would create too much noise on the mailing list and in Jira. Submitting patches that fail Hudson testing is frowned on, (unless the failure is not actually due to the patch).
  5. If your patch involves performance optimizations, they should be validated by benchmarks that demonstrate an improvement.
  6. If your patch creates an incompatibility with the latest major release, then you must set the Incompatible change flag on the issue's Jira 'and' fill in the Release Note field with an explanation of the impact of the incompatibility and the necessary steps users must take.

  7. If your patch implements a major feature or improvement, then you must fill in the Release Note field on the issue's Jira with an explanation of the feature that will be comprehensible by the end user.

Once a "+1" comment is received from the automated patch testing system and a code reviewer has set the Reviewed flag on the issue's Jira, a committer should then evaluate it within a few days and either: commit it; or reject it with an explanation.

Please be patient. Committers are busy people too. If no one responds to your patch after a few days, please make friendly reminders. Please incorporate other's suggestions into your patch if you think they're reasonable. Finally, remember that even a patch that is not committed is useful to the community.

Should your patch receive a "-1" from the Hudson testing, select the Cancel Patch on the issue's Jira, upload a new patch with necessary fixes, and then select the Submit Patch link again.

Jira Guidelines

Please comment on issues in Jira, making their concerns known. Please also vote for issues that are a high priority for you.

Please refrain from editing descriptions and comments if possible, as edits spam the mailing list and clutter Jira's "All" display, which is otherwise very useful. Instead, preview descriptions and comments using the preview button (on the right) before posting them. Keep descriptions brief and save more elaborate proposals for comments, since descriptions are included in Jira's automatically sent messages. If you change your mind, note this in a new comment, rather than editing an older comment. The issue should preserve this history of the discussion.

Stay involved

Contributors should join the Hadoop mailing lists. In particular, the commit list (to see changes as they are made), the dev list (to join discussions of changes) and the user list (to help others).

See Also

HowToContribute (last edited 2014-09-04 22:21:12 by ArpitAgarwal)