http://git-wip-us.apache.org/repos/asf/hbase/blob/1dba475d/src/main/asciidoc/_chapters/developer.adoc ---------------------------------------------------------------------- diff --git a/src/main/asciidoc/_chapters/developer.adoc b/src/main/asciidoc/_chapters/developer.adoc index c3ba0a2..8b74690 100644 --- a/src/main/asciidoc/_chapters/developer.adoc +++ b/src/main/asciidoc/_chapters/developer.adoc @@ -33,40 +33,124 @@ Being familiar with these guidelines will help the HBase committers to use your [[getting.involved]] == Getting Involved -Apache HBase gets better only when people contribute! If you are looking to contribute to Apache HBase, look for link:https://issues.apache.org/jira/issues/?jql=project%20%3D%20HBASE%20AND%20labels%20in%20(beginner)[issues in JIRA tagged with the label 'beginner']. +Apache HBase gets better only when people contribute! If you are looking to contribute to Apache HBase, look for link:https://issues.apache.org/jira/issues/?jql=project%20%3D%20HBASE%20AND%20labels%20in%20(beginner)%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)[issues in JIRA tagged with the label 'beginner']. These are issues HBase contributors have deemed worthy but not of immediate priority and a good way to ramp on HBase internals. See link:http://search-hadoop.com/m/DHED43re96[What label is used for issues that are good on ramps for new contributors?] from the dev mailing list for background. Before you get started submitting code to HBase, please refer to <<developing,developing>>. -As Apache HBase is an Apache Software Foundation project, see <<asf,asf>> for more information about how the ASF functions. +As Apache HBase is an Apache Software Foundation project, see <<asf,asf>> for more information about how the ASF functions. [[mailing.list]] === Mailing Lists Sign up for the dev-list and the user-list. -See the link:http://hbase.apache.org/mail-lists.html[mailing lists] page. -Posing questions - and helping to answer other people's questions - is encouraged! There are varying levels of experience on both lists so patience and politeness are encouraged (and please stay on topic.) +See the link:https://hbase.apache.org/mail-lists.html[mailing lists] page. +Posing questions - and helping to answer other people's questions - is encouraged! There are varying levels of experience on both lists so patience and politeness are encouraged (and please stay on topic.) + +[[slack]] +=== Slack +The Apache HBase project has its own link: http://apache-hbase.slack.com[Slack Channel] for real-time questions +and discussion. Mail d...@hbase.apache.org to request an invite. [[irc]] === Internet Relay Chat (IRC) +(NOTE: Our IRC channel seems to have been deprecated in favor of the above Slack channel) + For real-time questions and discussions, use the `#hbase` IRC channel on the link:https://freenode.net/[FreeNode] IRC network. FreeNode offers a web-based client, but most people prefer a native client, and several clients are available for each operating system. === Jira -Check for existing issues in link:https://issues.apache.org/jira/browse/HBASE[Jira]. -If it's either a new feature request, enhancement, or a bug, file a ticket. +Check for existing issues in link:https://issues.apache.org/jira/projects/HBASE/issues[Jira]. +If it's either a new feature request, enhancement, or a bug, file a ticket. + +We track multiple types of work in JIRA: + +- Bug: Something is broken in HBase itself. +- Test: A test is needed, or a test is broken. +- New feature: You have an idea for new functionality. It's often best to bring + these up on the mailing lists first, and then write up a design specification + that you add to the feature request JIRA. +- Improvement: A feature exists, but could be tweaked or augmented. It's often + best to bring these up on the mailing lists first and have a discussion, then + summarize or link to the discussion if others seem interested in the + improvement. +- Wish: This is like a new feature, but for something you may not have the + background to flesh out yourself. + +Bugs and tests have the highest priority and should be actionable. + +==== Guidelines for reporting effective issues + +- *Search for duplicates*: Your issue may have already been reported. Have a + look, realizing that someone else might have worded the summary differently. ++ +Also search the mailing lists, which may have information about your problem +and how to work around it. Don't file an issue for something that has already +been discussed and resolved on a mailing list, unless you strongly disagree +with the resolution *and* are willing to help take the issue forward. + +* *Discuss in public*: Use the mailing lists to discuss what you've discovered + and see if there is something you've missed. Avoid using back channels, so + that you benefit from the experience and expertise of the project as a whole. + +* *Don't file on behalf of others*: You might not have all the context, and you + don't have as much motivation to see it through as the person who is actually + experiencing the bug. It's more helpful in the long term to encourage others + to file their own issues. Point them to this material and offer to help out + the first time or two. + +* *Write a good summary*: A good summary includes information about the problem, + the impact on the user or developer, and the area of the code. +** Good: `Address new license dependencies from hadoop3-alpha4` +** Room for improvement: `Canary is broken` ++ +If you write a bad title, someone else will rewrite it for you. This is time +they could have spent working on the issue instead. + +* *Give context in the description*: It can be good to think of this in multiple + parts: +** What happens or doesn't happen? +** How does it impact you? +** How can someone else reproduce it? +** What would "fixed" look like? ++ +You don't need to know the answers for all of these, but give as much +information as you can. If you can provide technical information, such as a +Git commit SHA that you think might have caused the issue or a build failure +on builds.apache.org where you think the issue first showed up, share that +info. + +* *Fill in all relevant fields*: These fields help us filter, categorize, and + find things. + +* *One bug, one issue, one patch*: To help with back-porting, don't split issues + or fixes among multiple bugs. -To check for existing issues which you can tackle as a beginner, search for link:https://issues.apache.org/jira/issues/?jql=project%20%3D%20HBASE%20AND%20labels%20in%20(beginner)[issues in JIRA tagged with the label 'beginner']. +* *Add value if you can*: Filing issues is great, even if you don't know how to + fix them. But providing as much information as possible, being willing to + triage and answer questions, and being willing to test potential fixes is even + better! We want to fix your issue as quickly as you want it to be fixed. -* .JIRA PrioritiesBlocker: Should only be used if the issue WILL cause data loss or cluster instability reliably. -* Critical: The issue described can cause data loss or cluster instability in some cases. -* Major: Important but not tragic issues, like updates to the client API that will add a lot of much-needed functionality or significant bugs that need to be fixed but that don't cause data loss. -* Minor: Useful enhancements and annoying but not damaging bugs. -* Trivial: Useful enhancements but generally cosmetic. +* *Don't be upset if we don't fix it*: Time and resources are finite. In some + cases, we may not be able to (or might choose not to) fix an issue, especially + if it is an edge case or there is a workaround. Even if it doesn't get fixed, + the JIRA is a public record of it, and will help others out if they run into + a similar issue in the future. + +==== Working on an issue + +To check for existing issues which you can tackle as a beginner, search for link:https://issues.apache.org/jira/issues/?jql=project%20%3D%20HBASE%20AND%20labels%20in%20(beginner)%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)[issues in JIRA tagged with the label 'beginner']. + +.JIRA Priorites +* *Blocker*: Should only be used if the issue WILL cause data loss or cluster instability reliably. +* *Critical*: The issue described can cause data loss or cluster instability in some cases. +* *Major*: Important but not tragic issues, like updates to the client API that will add a lot of much-needed functionality or significant bugs that need to be fixed but that don't cause data loss. +* *Minor*: Useful enhancements and annoying but not damaging bugs. +* *Trivial*: Useful enhancements but generally cosmetic. .Code Blocks in Jira Comments ==== @@ -89,11 +173,12 @@ GIT is our repository of record for all but the Apache HBase website. We used to be on SVN. We migrated. See link:https://issues.apache.org/jira/browse/INFRA-7768[Migrate Apache HBase SVN Repos to Git]. -Updating hbase.apache.org still requires use of SVN (See <<hbase.org,hbase.org>>). See link:http://hbase.apache.org/source-repository.html[Source Code - Management] page for contributor and committer links or seach for HBase on the link:http://git.apache.org/[Apache Git] page. +See link:https://hbase.apache.org/source-repository.html[Source Code + Management] page for contributor and committer links or search for HBase on the link:https://git.apache.org/[Apache Git] page. == IDEs +[[eclipse]] === Eclipse [[eclipse.code.formatting]] @@ -102,27 +187,12 @@ Updating hbase.apache.org still requires use of SVN (See <<hbase.org,hbase.org>> Under the _dev-support/_ folder, you will find _hbase_eclipse_formatter.xml_. We encourage you to have this formatter in place in eclipse when editing HBase code. -.Procedure: Load the HBase Formatter Into Eclipse -. Open the menu item. -. In Preferences, click the menu item. -. Click btn:[Import] and browse to the location of the _hbase_eclipse_formatter.xml_ file, which is in the _dev-support/_ directory. - Click btn:[Apply]. -. Still in Preferences, click . - Be sure the following options are selected: -+ -* Perform the selected actions on save -* Format source code -* Format edited lines -+ -Click btn:[Apply]. -Close all dialog boxes and return to the main window. - +Go to `Preferences->Java->Code Style->Formatter->Import` to load the xml file. +Go to `Preferences->Java->Editor->Save Actions`, and make sure 'Format source code' and 'Format +edited lines' is selected. -In addition to the automatic formatting, make sure you follow the style guidelines explained in <<common.patch.feedback,common.patch.feedback>> - -Also, no `@author` tags - that's a rule. -Quality Javadoc comments are appreciated. -And include the Apache license. +In addition to the automatic formatting, make sure you follow the style guidelines explained in +<<common.patch.feedback,common.patch.feedback>>. [[eclipse.git.plugin]] ==== Eclipse Git Plugin @@ -133,30 +203,30 @@ If you cloned the project via git, download and install the Git plugin (EGit). A ==== HBase Project Setup in Eclipse using `m2eclipse` The easiest way is to use the +m2eclipse+ plugin for Eclipse. -Eclipse Indigo or newer includes +m2eclipse+, or you can download it from link:http://www.eclipse.org/m2e//. It provides Maven integration for Eclipse, and even lets you use the direct Maven commands from within Eclipse to compile and test your project. +Eclipse Indigo or newer includes +m2eclipse+, or you can download it from http://www.eclipse.org/m2e/. It provides Maven integration for Eclipse, and even lets you use the direct Maven commands from within Eclipse to compile and test your project. To import the project, click and select the HBase root directory. `m2eclipse` locates all the hbase modules for you. -If you install +m2eclipse+ and import HBase in your workspace, do the following to fix your eclipse Build Path. +If you install +m2eclipse+ and import HBase in your workspace, do the following to fix your eclipse Build Path. . Remove _target_ folder . Add _target/generated-jamon_ and _target/generated-sources/java_ folders. . Remove from your Build Path the exclusions on the _src/main/resources_ and _src/test/resources_ to avoid error message in the console, such as the following: + ---- -Failed to execute goal +Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project hbase: -'An Ant BuildException has occured: Replace: source file .../target/classes/hbase-default.xml +'An Ant BuildException has occurred: Replace: source file .../target/classes/hbase-default.xml doesn't exist ---- + -This will also reduce the eclipse build cycles and make your life easier when developing. +This will also reduce the eclipse build cycles and make your life easier when developing. [[eclipse.commandline]] ==== HBase Project Setup in Eclipse Using the Command Line -Instead of using `m2eclipse`, you can generate the Eclipse files from the command line. +Instead of using `m2eclipse`, you can generate the Eclipse files from the command line. . First, run the following command, which builds HBase. You only need to do this once. @@ -181,7 +251,7 @@ mvn eclipse:eclipse The `$M2_REPO` classpath variable needs to be set up for the project. This needs to be set to your local Maven repository, which is usually _~/.m2/repository_ -If this classpath variable is not configured, you will see compile errors in Eclipse like this: +If this classpath variable is not configured, you will see compile errors in Eclipse like this: ---- @@ -209,14 +279,14 @@ Access restriction: The method getLong(Object, long) from the type Unsafe is not [[eclipse.more]] ==== Eclipse - More Information -For additional information on setting up Eclipse for HBase development on Windows, see link:http://michaelmorello.blogspot.com/2011/09/hbase-subversion-eclipse-windows.html[Michael Morello's blog] on the topic. +For additional information on setting up Eclipse for HBase development on Windows, see link:http://michaelmorello.blogspot.com/2011/09/hbase-subversion-eclipse-windows.html[Michael Morello's blog] on the topic. === IntelliJ IDEA -You can set up IntelliJ IDEA for similar functinoality as Eclipse. +You can set up IntelliJ IDEA for similar functionality as Eclipse. Follow these steps. -. Select +. Select . You do not need to select a profile. Be sure [label]#Maven project required# is selected, and click btn:[Next]. @@ -227,7 +297,7 @@ Using the Eclipse Code Formatter plugin for IntelliJ IDEA, you can import the HB === Other IDEs -It would be userful to mirror the <<eclipse,eclipse>> set-up instructions for other IDEs. +It would be useful to mirror the <<eclipse,eclipse>> set-up instructions for other IDEs. If you would like to assist, please have a look at link:https://issues.apache.org/jira/browse/HBASE-11704[HBASE-11704]. [[build]] @@ -237,20 +307,20 @@ If you would like to assist, please have a look at link:https://issues.apache.or === Basic Compile HBase is compiled using Maven. -You must use Maven 3.x. +You must use at least Maven 3.0.4. To check your Maven version, run the command +mvn -version+. .JDK Version Requirements [NOTE] ==== Starting with HBase 1.0 you must use Java 7 or later to build from source code. -See <<java,java>> for more complete information about supported JDK versions. +See <<java,java>> for more complete information about supported JDK versions. ==== [[maven.build.commands]] ==== Maven Build Commands -All commands are executed from the local HBase project directory. +All commands are executed from the local HBase project directory. ===== Package @@ -269,7 +339,7 @@ mvn clean package -DskipTests ---- With Eclipse set up as explained above in <<eclipse,eclipse>>, you can also use the menu:Build[] command in Eclipse. -To create the full installable HBase package takes a little bit more work, so read on. +To create the full installable HBase package takes a little bit more work, so read on. [[maven.build.commands.compile]] ===== Compile @@ -313,38 +383,27 @@ See the <<hbase.unittests.cmds,hbase.unittests.cmds>> section in <<hbase.unittes [[maven.build.hadoop]] ==== Building against various hadoop versions. -As of 0.96, Apache HBase supports building against Apache Hadoop versions: 1.0.3, 2.0.0-alpha and 3.0.0-SNAPSHOT. -By default, in 0.96 and earlier, we will build with Hadoop-1.0.x. -As of 0.98, Hadoop 1.x is deprecated and Hadoop 2.x is the default. -To change the version to build against, add a hadoop.profile property when you invoke +mvn+: +HBase supports building against Apache Hadoop versions: 2.y and 3.y (early release artifacts). By default we build against Hadoop 2.x. + +To build against a specific release from the Hadoop 2.y line, set e.g. `-Dhadoop-two.version=2.7.4`. [source,bourne] ---- -mvn -Dhadoop.profile=1.0 ... +mvn -Dhadoop-two.version=2.7.4 ... ---- -The above will build against whatever explicit hadoop 1.x version we have in our _pom.xml_ as our '1.0' version. -Tests may not all pass so you may need to pass `-DskipTests` unless you are inclined to fix the failing tests. - -.'dependencyManagement.dependencies.dependency.artifactId' fororg.apache.hbase:${compat.module}:test-jar with value '${compat.module}'does not match a valid id pattern -[NOTE] -==== -You will see ERRORs like the above title if you pass the _default_ profile; e.g. -if you pass +hadoop.profile=1.1+ when building 0.96 or +hadoop.profile=2.0+ when building hadoop 0.98; just drop the hadoop.profile stipulation in this case to get your build to run again. -This seems to be a maven pecularity that is probably fixable but we've not spent the time trying to figure it. -==== - -Similarly, for 3.0, you would just replace the profile value. -Note that Hadoop-3.0.0-SNAPSHOT does not currently have a deployed maven artificat - you will need to build and install your own in your local maven repository if you want to run against this profile. - -In earilier versions of Apache HBase, you can build against older versions of Apache Hadoop, notably, Hadoop 0.22.x and 0.23.x. -If you are running, for example HBase-0.94 and wanted to build against Hadoop 0.23.x, you would run with: +To change the major release line of Hadoop we build against, add a hadoop.profile property when you invoke +mvn+: [source,bourne] ---- -mvn -Dhadoop.profile=22 ... +mvn -Dhadoop.profile=3.0 ... ---- +The above will build against whatever explicit hadoop 3.y version we have in our _pom.xml_ as our '3.0' version. +Tests may not all pass so you may need to pass `-DskipTests` unless you are inclined to fix the failing tests. + +To pick a particular Hadoop 3.y release, you'd set e.g. `-Dhadoop-three.version=3.0.0-alpha1`. + [[build.protobuf]] ==== Build Protobuf @@ -367,7 +426,7 @@ You may also want to define `protoc.path` for the protoc binary, using the follo mvn compile -Pcompile-protobuf -Dprotoc.path=/opt/local/bin/protoc ---- -Read the _hbase-protocol/README.txt_ for more details. +Read the _hbase-protocol/README.txt_ for more details. [[build.thrift]] ==== Build Thrift @@ -415,9 +474,8 @@ mvn -DskipTests package assembly:single deploy ==== Build Gotchas If you see `Unable to find resource 'VM_global_library.vm'`, ignore it. -Its not an error. -It is link:http://jira.codehaus.org/browse/MSITE-286[officially - ugly] though. +It's not an error. +It is link:https://issues.apache.org/jira/browse/MSITE-286[officially ugly] though. [[releasing]] == Releasing Apache HBase @@ -429,27 +487,7 @@ HBase 1.x requires Java 7 to build. See <<java,java>> for Java requirements per HBase release. ==== -=== Building against HBase 0.96-0.98 - -HBase 0.96.x will run on Hadoop 1.x or Hadoop 2.x. -HBase 0.98 still runs on both, but HBase 0.98 deprecates use of Hadoop 1. -HBase 1.x will _not_ run on Hadoop 1. -In the following procedures, we make a distinction between HBase 1.x builds and the awkward process involved building HBase 0.96/0.98 for either Hadoop 1 or Hadoop 2 targets. - -You must choose which Hadoop to build against. -It is not possible to build a single HBase binary that runs against both Hadoop 1 and Hadoop 2. -Hadoop is included in the build, because it is needed to run HBase in standalone mode. -Therefore, the set of modules included in the tarball changes, depending on the build target. -To determine which HBase you have, look at the HBase version. -The Hadoop version is embedded within it. - -Maven, our build system, natively does not allow a single product to be built against different dependencies. -Also, Maven cannot change the set of included modules and write out the correct _pom.xml_ files with appropriate dependencies, even using two build targets, one for Hadoop 1 and another for Hadoop 2. -A prerequisite step is required, which takes as input the current _pom.xml_s and generates Hadoop 1 or Hadoop 2 versions using a script in the _dev-tools/_ directory, called _generate-hadoopX-poms.sh_ where [replaceable]_X_ is either `1` or `2`. -You then reference these generated poms when you build. -For now, just be aware of the difference between HBase 1.x builds and those of HBase 0.96-0.98. -This difference is important to the build instructions. - +[[maven.settings.xml]] .Example _~/.m2/settings.xml_ File ==== Publishing to maven requires you sign the artifacts you want to upload. @@ -497,48 +535,53 @@ For the build to sign them for you, you a properly configured _settings.xml_ in [[maven.release]] === Making a Release Candidate - -NOTE: These instructions are for building HBase 1.0.x. -For building earlier versions, the process is different. -See this section under the respective release documentation folders. - -.Point Releases -If you are making a point release (for example to quickly address a critical incompatability or security problem) off of a release branch instead of a development branch, the tagging instructions are slightly different. -I'll prefix those special steps with _Point Release Only_. +Only committers may make releases of hbase artifacts. .Before You Begin -Before you make a release candidate, do a practice run by deploying a snapshot. -Before you start, check to be sure recent builds have been passing for the branch from where you are going to take your release. -You should also have tried recent branch tips out on a cluster under load, perhaps by running the `hbase-it` integration test suite for a few hours to 'burn in' the near-candidate bits. - -.Point Release Only +Make sure your environment is properly set up. Maven and Git are the main tooling +used in the below. You'll need a properly configured _settings.xml_ file in your +local _~/.m2_ maven repository with logins for apache repos (See <<maven.settings.xml>>). +You will also need to have a published signing key. Browse the Hadoop +link:http://wiki.apache.org/hadoop/HowToRelease[How To Release] wiki page on +how to release. It is a model for most of the instructions below. It often has more +detail on particular steps, for example, on adding your code signing key to the +project KEYS file up in Apache or on how to update JIRA in preparation for release. + +Before you make a release candidate, do a practice run by deploying a SNAPSHOT. +Check to be sure recent builds have been passing for the branch from where you +are going to take your release. You should also have tried recent branch tips +out on a cluster under load, perhaps by running the `hbase-it` integration test +suite for a few hours to 'burn in' the near-candidate bits. + + +.Specifying the Heap Space for Maven [NOTE] ==== -At this point you should tag the previous release branch (ex: 0.96.1) with the new point release tag (e.g. -0.96.1.1 tag). Any commits with changes for the point release should be appled to the new tag. -==== - -The Hadoop link:http://wiki.apache.org/hadoop/HowToRelease[How To - Release] wiki page is used as a model for most of the instructions below, and may have more detail on particular sections, so it is worth review. - -.Specifying the Heap Space for Maven on OSX -[NOTE] -==== -On OSX, you may need to specify the heap space for Maven commands, by setting the `MAVEN_OPTS` variable to `-Xmx3g`. +You may run into OutOfMemoryErrors building, particularly building the site and +documentation. Up the heap for Maven by setting the `MAVEN_OPTS` variable. You can prefix the variable to the Maven command, as in the following example: ---- -MAVEN_OPTS="-Xmx2g" mvn package +MAVEN_OPTS="-Xmx4g -XX:MaxPermSize=256m" mvn package ---- You could also set this in an environment variable or alias in your shell. ==== -NOTE: The script _dev-support/make_rc.sh_ automates many of these steps. -It does not do the modification of the _CHANGES.txt_ for the release, the close of the staging repository in Apache Maven (human intervention is needed here), the checking of the produced artifacts to ensure they are 'good' -- e.g. -extracting the produced tarballs, verifying that they look right, then starting HBase and checking that everything is running correctly, then the signing and pushing of the tarballs to link:http://people.apache.org[people.apache.org]. -The script handles everything else, and comes in handy. +[NOTE] +==== +The script _dev-support/make_rc.sh_ automates many of the below steps. +It will checkout a tag, clean the checkout, build src and bin tarballs, +and deploy the built jars to repository.apache.org. +It does NOT do the modification of the _CHANGES.txt_ for the release, +the checking of the produced artifacts to ensure they are 'good' -- +e.g. extracting the produced tarballs, verifying that they +look right, then starting HBase and checking that everything is running +correctly -- or the signing and pushing of the tarballs to +link:https://people.apache.org[people.apache.org]. +Take a look. Modify/improve as you see fit. +==== .Procedure: Release Procedure . Update the _CHANGES.txt_ file and the POM files. @@ -546,118 +589,188 @@ The script handles everything else, and comes in handy. Update _CHANGES.txt_ with the changes since the last release. Make sure the URL to the JIRA points to the proper location which lists fixes for this release. Adjust the version in all the POM files appropriately. -If you are making a release candidate, you must remove the `-SNAPSHOT` label from all versions. +If you are making a release candidate, you must remove the `-SNAPSHOT` label from all versions +in all pom.xml files. If you are running this receipe to publish a snapshot, you must keep the `-SNAPSHOT` suffix on the hbase version. -The link:http://mojo.codehaus.org/versions-maven-plugin/[Versions - Maven Plugin] can be of use here. +The link:http://www.mojohaus.org/versions-maven-plugin/[Versions Maven Plugin] can be of use here. To set a version in all the many poms of the hbase multi-module project, use a command like the following: + [source,bourne] ---- - -$ mvn clean org.codehaus.mojo:versions-maven-plugin:1.3.1:set -DnewVersion=0.96.0 +$ mvn clean org.codehaus.mojo:versions-maven-plugin:2.5:set -DnewVersion=1.5.0 ---- + -Checkin the _CHANGES.txt_ and any version changes. +Make sure all versions in poms are changed! Checkin the _CHANGES.txt_ and any maven version changes. . Update the documentation. + -Update the documentation under _src/main/docbkx_. -This usually involves copying the latest from trunk and making version-particular adjustments to suit this release candidate version. +Update the documentation under _src/main/asciidoc_. +This usually involves copying the latest from master branch and making version-particular +adjustments to suit this release candidate version. -. Build the source tarball. +. Clean the checkout dir + -Now, build the source tarball. -This tarball is Hadoop-version-independent. -It is just the pure source code and documentation without a particular hadoop taint, etc. -Add the `-Prelease` profile when building. -It checks files for licenses and will fail the build if unlicensed files are present. +[source,bourne] +---- + +$ mvn clean +$ git clean -f -x -d +---- + + +. Run Apache-Rat +Check licenses are good + [source,bourne] ---- -$ mvn clean install -DskipTests assembly:single -Dassembly.file=hbase-assembly/src/main/assembly/src.xml -Prelease +$ mvn apache-rat ---- + -Extract the tarball and make sure it looks good. -A good test for the src tarball being 'complete' is to see if you can build new tarballs from this source bundle. -If the source tarball is good, save it off to a _version directory_, a directory somewhere where you are collecting all of the tarballs you will publish as part of the release candidate. -For example if you were building a hbase-0.96.0 release candidate, you might call the directory _hbase-0.96.0RC0_. -Later you will publish this directory as our release candidate up on http://people.apache.org/~YOU. +If the above fails, check the rat log. -. Build the binary tarball. + -Next, build the binary tarball. -Add the `-Prelease` profile when building. -It checks files for licenses and will fail the build if unlicensed files are present. -Do it in two steps. +[source,bourne] +---- +$ grep 'Rat check' patchprocess/mvn_apache_rat.log +---- + -* First install into the local repository + +. Create a release tag. +Presuming you have run basic tests, the rat check, passes and all is +looking good, now is the time to tag the release candidate (You +always remove the tag if you need to redo). To tag, do +what follows substituting in the version appropriate to your build. +All tags should be signed tags; i.e. pass the _-s_ option (See +link:http://https://git-scm.com/book/id/v2/Git-Tools-Signing-Your-Work[Signing Your Work] +for how to set up your git environment for signing). + + [source,bourne] ---- -$ mvn clean install -DskipTests -Prelease +$ git tag -s 1.5.0-RC0 -m "Tagging the 1.5.0 first Releae Candidate (Candidates start at zero)" ---- -* Next, generate documentation and assemble the tarball. +Or, if you are making a release, tags should have a _rel/_ prefix to ensure +they are preserved in the Apache repo as in: + +[source,bourne] +---- ++$ git tag -s rel/1.5.0 -m "Tagging the 1.5.0 Release" +---- + +Push the (specific) tag (only) so others have access. + [source,bourne] ---- +$ git push origin 1.5.0-RC0 +---- ++ +For how to delete tags, see +link:http://www.manikrathee.com/how-to-delete-a-tag-in-git.html[How to Delete a Tag]. Covers +deleting tags that have not yet been pushed to the remote Apache +repo as well as delete of tags pushed to Apache. + + +. Build the source tarball. ++ +Now, build the source tarball. Lets presume we are building the source +tarball for the tag _1.5.0-RC0_ into _/tmp/hbase-1.5.0-RC0/_ +(This step requires that the mvn and git clean steps described above have just been done). ++ +[source,bourne] +---- +$ git archive --format=tar.gz --output="/tmp/hbase-1.5.0-RC0/hbase-1.5.0-src.tar.gz" --prefix="hbase-1.5.0/" $git_tag +---- + +Above we generate the hbase-1.5.0-src.tar.gz tarball into the +_/tmp/hbase-1.5.0-RC0_ build output directory (We don't want the _RC0_ in the name or prefix. +These bits are currently a release candidate but if the VOTE passes, they will become the release so we do not taint +the artifact names with _RCX_). + +. Build the binary tarball. +Next, build the binary tarball. Add the `-Prelease` profile when building. +It runs the license apache-rat check among other rules that help ensure +all is wholesome. Do it in two steps. + +First install into the local repository + +[source,bourne] +---- + +$ mvn clean install -DskipTests -Prelease +---- + +Next, generate documentation and assemble the tarball. Be warned, +this next step can take a good while, a couple of hours generating site +documentation. + +[source,bourne] +---- + $ mvn install -DskipTests site assembly:single -Prelease ---- + -Otherwise, the build complains that hbase modules are not in the maven repository when you try to do it at once, especially on fresh repository. +Otherwise, the build complains that hbase modules are not in the maven repository +when you try to do it all in one step, especially on a fresh repository. It seems that you need the install goal in both steps. + -Extract the generated tarball and check it out. +Extract the generated tarball -- you'll find it under +_hbase-assembly/target_ and check it out. Look at the documentation, see if it runs, etc. -If good, copy the tarball to the above mentioned _version directory_. +If good, copy the tarball beside the source tarball in the +build output directory. -. Create a new tag. -+ -.Point Release Only -[NOTE] -==== -The following step that creates a new tag can be skipped since you've already created the point release tag -==== -+ -Tag the release at this point since it looks good. -If you find an issue later, you can delete the tag and start over. -Release needs to be tagged for the next step. . Deploy to the Maven Repository. + -Next, deploy HBase to the Apache Maven repository, using the `apache-release` profile instead of the `release` profile when running the `mvn deploy` command. -This profile invokes the Apache pom referenced by our pom files, and also signs your artifacts published to Maven, as long as the _settings.xml_ is configured correctly, as described in <<mvn.settings.file,mvn.settings.file>>. +Next, deploy HBase to the Apache Maven repository. Add the +apache-release` profile when running the `mvn deploy` command. +This profile comes from the Apache parent pom referenced by our pom files. +It does signing of your artifacts published to Maven, as long as the +_settings.xml_ is configured correctly, as described in <<maven.settings.xml>>. +This step depends on the local repository having been populate +by the just-previous bin tarball build. + + [source,bourne] ---- -$ mvn deploy -DskipTests -Papache-release +$ mvn deploy -DskipTests -Papache-release -Prelease ---- + This command copies all artifacts up to a temporary staging Apache mvn repository in an 'open' state. -More work needs to be done on these maven artifacts to make them generally available. +More work needs to be done on these maven artifacts to make them generally available. + -We do not release HBase tarball to the Apache Maven repository. To avoid deploying the tarball, do not include the `assembly:single` goal in your `mvn deploy` command. Check the deployed artifacts as described in the next section. +We do not release HBase tarball to the Apache Maven repository. To avoid deploying the tarball, do not +include the `assembly:single` goal in your `mvn deploy` command. Check the deployed artifacts as described in the next section. + +.make_rc.sh +[NOTE] +==== +If you run the _dev-support/make_rc.sh_ script, this is as far as it takes you. +To finish the release, take up the script from here on out. +==== . Make the Release Candidate available. + The artifacts are in the maven repository in the staging area in the 'open' state. While in this 'open' state you can check out what you've published to make sure all is good. -To do this, login at link:http://repository.apache.org[repository.apache.org] using your Apache ID. -Find your artifacts in the staging repository. -Browse the content. -Make sure all artifacts made it up and that the poms look generally good. -If it checks out, 'close' the repo. -This will make the artifacts publically available. -You will receive an email with the URL to give out for the temporary staging repository for others to use trying out this new release candidate. -Include it in the email that announces the release candidate. -Folks will need to add this repo URL to their local poms or to their local _settings.xml_ file to pull the published release candidate artifacts. -If the published artifacts are incomplete or have problems, just delete the 'open' staged artifacts. +To do this, log in to Apache's Nexus at link:https://repository.apache.org[repository.apache.org] using your Apache ID. +Find your artifacts in the staging repository. Click on 'Staging Repositories' and look for a new one ending in "hbase" with a status of 'Open', select it. +Use the tree view to expand the list of repository contents and inspect if the artifacts you expect are present. Check the POMs. +As long as the staging repo is open you can re-upload if something is missing or built incorrectly. ++ +If something is seriously wrong and you would like to back out the upload, you can use the 'Drop' button to drop and delete the staging repository. +Sometimes the upload fails in the middle. This is another reason you might have to 'Drop' the upload from the staging repository. ++ +If it checks out, close the repo using the 'Close' button. The repository must be closed before a public URL to it becomes available. It may take a few minutes for the repository to close. Once complete you'll see a public URL to the repository in the Nexus UI. You may also receive an email with the URL. Provide the URL to the temporary staging repository in the email that announces the release candidate. +(Folks will need to add this repo URL to their local poms or to their local _settings.xml_ file to pull the published release candidate artifacts.) ++ +When the release vote concludes successfully, return here and click the 'Release' button to release the artifacts to central. The release process will automatically drop and delete the staging repository. + .hbase-downstreamer [NOTE] @@ -665,60 +778,57 @@ If the published artifacts are incomplete or have problems, just delete the 'ope See the link:https://github.com/saintstack/hbase-downstreamer[hbase-downstreamer] test for a simple example of a project that is downstream of HBase an depends on it. Check it out and run its simple test to make sure maven artifacts are properly deployed to the maven repository. Be sure to edit the pom to point to the proper staging repository. -Make sure you are pulling from the repository when tests run and that you are not getting from your local repository, by either passing the `-U` flag or deleting your local repo content and check maven is pulling from remote out of the staging repository. +Make sure you are pulling from the repository when tests run and that you are not getting from your local repository, by either passing the `-U` flag or deleting your local repo content and check maven is pulling from remote out of the staging repository. ==== -+ -See link:http://www.apache.org/dev/publishing-maven-artifacts.html[Publishing Maven Artifacts] for some pointers on this maven staging process. -+ -NOTE: We no longer publish using the maven release plugin. -Instead we do +mvn deploy+. -It seems to give us a backdoor to maven release publishing. -If there is no _-SNAPSHOT_ on the version string, then we are 'deployed' to the apache maven repository staging directory from which we can publish URLs for candidates and later, if they pass, publish as release (if a _-SNAPSHOT_ on the version string, deploy will put the artifacts up into apache snapshot repos). -+ + +See link:https://www.apache.org/dev/publishing-maven-artifacts.html[Publishing Maven Artifacts] for some pointers on this maven staging process. + If the HBase version ends in `-SNAPSHOT`, the artifacts go elsewhere. They are put into the Apache snapshots repository directly and are immediately available. Making a SNAPSHOT release, this is what you want to happen. -. If you used the _make_rc.sh_ script instead of doing - the above manually, do your sanity checks now. -+ -At this stage, you have two tarballs in your 'version directory' and a set of artifacts in a staging area of the maven repository, in the 'closed' state. -These are publicly accessible in a temporary staging repository whose URL you should have gotten in an email. -The above mentioned script, _make_rc.sh_ does all of the above for you minus the check of the artifacts built, the closing of the staging repository up in maven, and the tagging of the release. -If you run the script, do your checks at this stage verifying the src and bin tarballs and checking what is up in staging using hbase-downstreamer project. -Tag before you start the build. -You can always delete it if the build goes haywire. - -. Sign, upload, and 'stage' your version directory to link:http://people.apache.org[people.apache.org] (TODO: - There is a new location to stage releases using svnpubsub. See - (link:https://issues.apache.org/jira/browse/HBASE-10554[HBASE-10554 Please delete old releases from mirroring system]). -+ -If all checks out, next put the _version directory_ up on link:http://people.apache.org[people.apache.org]. -You will need to sign and fingerprint them before you push them up. -In the _version directory_ run the following commands: -+ +At this stage, you have two tarballs in your 'build output directory' and a set of artifacts in a staging area of the maven repository, in the 'closed' state. +Next sign, fingerprint and then 'stage' your release candiate build output directory via svnpubsub by committing +your directory to link:https://dist.apache.org/repos/dist/dev/hbase/[The 'dev' distribution directory] (See comments on link:https://issues.apache.org/jira/browse/HBASE-10554[HBASE-10554 Please delete old releases from mirroring system] but in essence it is an svn checkout of https://dist.apache.org/repos/dist/dev/hbase -- releases are at https://dist.apache.org/repos/dist/release/hbase). In the _version directory_ run the following commands: + [source,bourne] ---- -$ for i in *.tar.gz; do echo $i; gpg --print-mds $i > $i.mds ; done $ for i in *.tar.gz; do echo $i; gpg --print-md MD5 $i > $i.md5 ; done $ for i in *.tar.gz; do echo $i; gpg --print-md SHA512 $i > $i.sha ; done $ for i in *.tar.gz; do echo $i; gpg --armor --output $i.asc --detach-sig $i ; done $ cd .. -# Presuming our 'version directory' is named 0.96.0RC0, now copy it up to people.apache.org. -$ rsync -av 0.96.0RC0 people.apache.org:public_html +# Presuming our 'build output directory' is named 1.5.0RC0, copy it to the svn checkout of the dist dev dir +# in this case named hbase.dist.dev.svn +$ cd /Users/stack/checkouts/hbase.dist.dev.svn +$ svn info +Path: . +Working Copy Root Path: /Users/stack/checkouts/hbase.dist.dev.svn +URL: https://dist.apache.org/repos/dist/dev/hbase +Repository Root: https://dist.apache.org/repos/dist +Repository UUID: 0d268c88-bc11-4956-87df-91683dc98e59 +Revision: 15087 +Node Kind: directory +Schedule: normal +Last Changed Author: ndimiduk +Last Changed Rev: 15045 +Last Changed Date: 2016-08-28 11:13:36 -0700 (Sun, 28 Aug 2016) +$ mv 1.5.0RC0 /Users/stack/checkouts/hbase.dist.dev.svn +$ svn add 1.5.0RC0 +$ svn commit ... ---- + -Make sure the link:http://people.apache.org[people.apache.org] directory is showing and that the mvn repo URLs are good. -Announce the release candidate on the mailing list and call a vote. +Ensure it actually gets published by checking link:https://dist.apache.org/repos/dist/dev/hbase/[https://dist.apache.org/repos/dist/dev/hbase/]. + +Announce the release candidate on the mailing list and call a vote. [[maven.snapshot]] === Publishing a SNAPSHOT to maven -Make sure your _settings.xml_ is set up properly, as in <<mvn.settings.file,mvn.settings.file>>. +Make sure your _settings.xml_ is set up properly (see <<maven.settings.xml>>). Make sure the hbase version includes `-SNAPSHOT` as a suffix. -Following is an example of publishing SNAPSHOTS of a release that had an hbase version of 0.96.0 in its poms. +Following is an example of publishing SNAPSHOTS of a release that had an hbase version of 1.5.0 in its poms. [source,bourne] ---- @@ -729,7 +839,7 @@ Following is an example of publishing SNAPSHOTS of a release that had an hbase v The _make_rc.sh_ script mentioned above (see <<maven.release,maven.release>>) can help you publish `SNAPSHOTS`. Make sure your `hbase.version` has a `-SNAPSHOT` suffix before running the script. -It will put a snapshot up into the apache snapshot repository for you. +It will put a snapshot up into the apache snapshot repository for you. [[hbase.rc.voting]] == Voting on Release Candidates @@ -744,7 +854,7 @@ PMC members, please read this WIP doc on policy voting for a release candidate, requirements of the ASF policy on releases._ Regards the latter, run +mvn apache-rat:check+ to verify all files are suitably licensed. See link:http://search-hadoop.com/m/DHED4dhFaU[HBase, mail # dev - On recent discussion clarifying ASF release policy]. -for how we arrived at this process. +for how we arrived at this process. [[documentation]] == Generating the HBase Reference Guide @@ -752,10 +862,10 @@ for how we arrived at this process. The manual is marked up using Asciidoc. We then use the link:http://asciidoctor.org/docs/asciidoctor-maven-plugin/[Asciidoctor maven plugin] to transform the markup to html. This plugin is run when you specify the +site+ goal as in when you run +mvn site+. -See <<appendix_contributing_to_documentation,appendix contributing to documentation>> for more information on building the documentation. +See <<appendix_contributing_to_documentation,appendix contributing to documentation>> for more information on building the documentation. [[hbase.org]] -== Updating link:http://hbase.apache.org[hbase.apache.org] +== Updating link:https://hbase.apache.org[hbase.apache.org] [[hbase.org.site.contributing]] === Contributing to hbase.apache.org @@ -763,26 +873,9 @@ See <<appendix_contributing_to_documentation,appendix contributing to documentat See <<appendix_contributing_to_documentation,appendix contributing to documentation>> for more information on contributing to the documentation or website. [[hbase.org.site.publishing]] -=== Publishing link:http://hbase.apache.org[hbase.apache.org] +=== Publishing link:https://hbase.apache.org[hbase.apache.org] -As of link:https://issues.apache.org/jira/browse/INFRA-5680[INFRA-5680 Migrate apache hbase website], to publish the website, build it using Maven, and then deploy it over a checkout of _https://svn.apache.org/repos/asf/hbase/hbase.apache.org/trunk_ and check in your changes. -The script _dev-scripts/publish_hbase_website.sh_ is provided to automate this process and to be sure that stale files are removed from SVN. -Review the script even if you decide to publish the website manually. -Use the script as follows: - ----- -$ publish_hbase_website.sh -h -Usage: publish_hbase_website.sh [-i | -a] [-g <dir>] [-s <dir>] - -h Show this message - -i Prompts the user for input - -a Does not prompt the user. Potentially dangerous. - -g The local location of the HBase git repository - -s The local location of the HBase svn checkout - Either --interactive or --silent is required. - Edit the script to set default Git and SVN directories. ----- - -NOTE: The SVN commit takes a long time. +See <<website_publish>> for instructions on publishing the website and documentation. [[hbase.tests]] == Tests @@ -806,7 +899,7 @@ For any other module, for example `hbase-common`, the tests must be strict unit The HBase shell and its tests are predominantly written in jruby. In order to make these tests run as a part of the standard build, there is a single JUnit test, `TestShell`, that takes care of loading the jruby implemented tests and running them. -You can run all of these tests from the top level with: +You can run all of these tests from the top level with: [source,bourne] ---- @@ -816,7 +909,7 @@ You can run all of these tests from the top level with: Alternatively, you may limit the shell tests that run using the system variable `shell.test`. This value should specify the ruby literal equivalent of a particular test case by name. -For example, the tests that cover the shell commands for altering tables are contained in the test case `AdminAlterTableTest` and you can run them with: +For example, the tests that cover the shell commands for altering tables are contained in the test case `AdminAlterTableTest` and you can run them with: [source,bourne] ---- @@ -826,7 +919,7 @@ For example, the tests that cover the shell commands for altering tables are con You may also use a link:http://docs.ruby-doc.com/docs/ProgrammingRuby/html/language.html#UJ[Ruby Regular Expression literal] (in the `/pattern/` style) to select a set of test cases. -You can run all of the HBase admin related tests, including both the normal administration and the security administration, with the command: +You can run all of the HBase admin related tests, including both the normal administration and the security administration, with the command: [source,bourne] ---- @@ -834,7 +927,7 @@ You can run all of the HBase admin related tests, including both the normal admi mvn clean test -Dtest=TestShell -Dshell.test=/.*Admin.*Test/ ---- -In the event of a test failure, you can see details by examining the XML version of the surefire report results +In the event of a test failure, you can see details by examining the XML version of the surefire report results [source,bourne] ---- @@ -876,7 +969,8 @@ Also, keep in mind that if you are running tests in the `hbase-server` module yo [[hbase.unittests]] === Unit Tests -Apache HBase unit tests are subdivided into four categories: small, medium, large, and integration with corresponding JUnit link:http://www.junit.org/node/581[categories]: `SmallTests`, `MediumTests`, `LargeTests`, `IntegrationTests`. +Apache HBase test cases are subdivided into four categories: small, medium, large, and +integration with corresponding JUnit link:https://github.com/junit-team/junit4/wiki/Categories[categories]: `SmallTests`, `MediumTests`, `LargeTests`, `IntegrationTests`. JUnit categories are denoted using java annotations and look like this in your unit test code. [source,java] @@ -891,51 +985,53 @@ public class TestHRegionInfo { } ---- -The above example shows how to mark a unit test as belonging to the `small` category. -All unit tests in HBase have a categorization. +The above example shows how to mark a test case as belonging to the `small` category. +All test cases in HBase should have a categorization. -The first three categories, `small`, `medium`, and `large`, are for tests run when you type `$ mvn test`. +The first three categories, `small`, `medium`, and `large`, are for test cases which run when you +type `$ mvn test`. In other words, these three categorizations are for HBase unit tests. The `integration` category is not for unit tests, but for integration tests. These are run when you invoke `$ mvn verify`. Integration tests are described in <<integration.tests,integration.tests>>. -HBase uses a patched maven surefire plugin and maven profiles to implement its unit test characterizations. +HBase uses a patched maven surefire plugin and maven profiles to implement its unit test characterizations. -Keep reading to figure which annotation of the set small, medium, and large to put on your new HBase unit test. +Keep reading to figure which annotation of the set small, medium, and large to put on your new +HBase test case. .Categorizing Tests Small Tests (((SmallTests))):: - _Small_ tests are executed in a shared JVM. - We put in this category all the tests that can be executed quickly in a shared JVM. - The maximum execution time for a small test is 15 seconds, and small tests should not use a (mini)cluster. + _Small_ test cases are executed in a shared JVM and individual test cases should run in 15 seconds + or less; i.e. a link:https://en.wikipedia.org/wiki/JUnit[junit test fixture], a java object made + up of test methods, should finish in under 15 seconds. These test cases can not use mini cluster. + These are run as part of patch pre-commit. Medium Tests (((MediumTests))):: - _Medium_ tests represent tests that must be executed before proposing a patch. - They are designed to run in less than 30 minutes altogether, and are quite stable in their results. - They are designed to last less than 50 seconds individually. - They can use a cluster, and each of them is executed in a separate JVM. + _Medium_ test cases are executed in separate JVM and individual test case should run in 50 seconds + or less. Together, they should take less than 30 minutes, and are quite stable in their results. + These test cases can use a mini cluster. These are run as part of patch pre-commit. Large Tests (((LargeTests))):: - _Large_ tests are everything else. + _Large_ test cases are everything else. They are typically large-scale tests, regression tests for specific bugs, timeout tests, performance tests. They are executed before a commit on the pre-integration machines. - They can be run on the developer machine as well. + They can be run on the developer machine as well. Integration Tests (((IntegrationTests))):: _Integration_ tests are system level tests. - See <<integration.tests,integration.tests>> for more info. + See <<integration.tests,integration.tests>> for more info. [[hbase.unittests.cmds]] === Running tests [[hbase.unittests.cmds.test]] -==== Default: small and medium category tests +==== Default: small and medium category tests Running `mvn test` will execute all small tests in a single JVM (no fork) and then medium tests in a separate JVM for each test instance. Medium tests are NOT executed if there is an error in a small test. Large tests are NOT executed. -There is one report for small tests, and one report for medium tests if they are executed. +There is one report for small tests, and one report for medium tests if they are executed. [[hbase.unittests.cmds.test.runalltests]] ==== Running all tests @@ -943,38 +1039,38 @@ There is one report for small tests, and one report for medium tests if they are Running `mvn test -P runAllTests` will execute small tests in a single JVM then medium and large tests in a separate JVM for each test. Medium and large tests are NOT executed if there is an error in a small test. Large tests are NOT executed if there is an error in a small or medium test. -There is one report for small tests, and one report for medium and large tests if they are executed. +There is one report for small tests, and one report for medium and large tests if they are executed. [[hbase.unittests.cmds.test.localtests.mytest]] ==== Running a single test or all tests in a package -To run an individual test, e.g. `MyTest`, rum `mvn test -Dtest=MyTest` You can also pass multiple, individual tests as a comma-delimited list: +To run an individual test, e.g. `MyTest`, rum `mvn test -Dtest=MyTest` You can also pass multiple, individual tests as a comma-delimited list: [source,bash] ---- mvn test -Dtest=MyTest1,MyTest2,MyTest3 ---- -You can also pass a package, which will run all tests under the package: +You can also pass a package, which will run all tests under the package: [source,bash] ---- mvn test '-Dtest=org.apache.hadoop.hbase.client.*' ----- +---- When `-Dtest` is specified, the `localTests` profile will be used. It will use the official release of maven surefire, rather than our custom surefire plugin, and the old connector (The HBase build uses a patched version of the maven surefire plugin). Each junit test is executed in a separate JVM (A fork per test class). There is no parallelization when tests are running in this mode. You will see a new message at the end of the -report: `"[INFO] Tests are skipped"`. It's harmless. -However, you need to make sure the sum of `Tests run:` in the `Results:` section of test reports matching the number of tests you specified because no error will be reported when a non-existent test case is specified. +However, you need to make sure the sum of `Tests run:` in the `Results:` section of test reports matching the number of tests you specified because no error will be reported when a non-existent test case is specified. [[hbase.unittests.cmds.test.profiles]] ==== Other test invocation permutations -Running `mvn test -P runSmallTests` will execute "small" tests only, using a single JVM. +Running `mvn test -P runSmallTests` will execute "small" tests only, using a single JVM. -Running `mvn test -P runMediumTests` will execute "medium" tests only, launching a new JVM for each test-class. +Running `mvn test -P runMediumTests` will execute "medium" tests only, launching a new JVM for each test-class. -Running `mvn test -P runLargeTests` will execute "large" tests only, launching a new JVM for each test-class. +Running `mvn test -P runLargeTests` will execute "large" tests only, launching a new JVM for each test-class. -For convenience, you can run `mvn test -P runDevTests` to execute both small and medium tests, using a single JVM. +For convenience, you can run `mvn test -P runDevTests` to execute both small and medium tests, using a single JVM. [[hbase.unittests.test.faster]] ==== Running tests faster @@ -996,7 +1092,7 @@ $ sudo mkdir /ram2G sudo mount -t tmpfs -o size=2048M tmpfs /ram2G ---- -You can then use it to run all HBase tests on 2.0 with the command: +You can then use it to run all HBase tests on 2.0 with the command: ---- mvn test @@ -1004,7 +1100,7 @@ mvn test -Dtest.build.data.basedirectory=/ram2G ---- -On earlier versions, use: +On earlier versions, use: ---- mvn test @@ -1023,7 +1119,7 @@ It must be executed from the directory which contains the _pom.xml_. For example running +./dev-support/hbasetests.sh+ will execute small and medium tests. Running +./dev-support/hbasetests.sh runAllTests+ will execute all tests. -Running +./dev-support/hbasetests.sh replayFailed+ will rerun the failed tests a second time, in a separate jvm and without parallelisation. +Running +./dev-support/hbasetests.sh replayFailed+ will rerun the failed tests a second time, in a separate jvm and without parallelisation. [[hbase.unittests.resource.checker]] ==== Test Resource Checker(((Test ResourceChecker))) @@ -1033,7 +1129,7 @@ Check the _*-out.txt_ files). The resources counted are the number of threads, t If the number has increased, it adds a _LEAK?_ comment in the logs. As you can have an HBase instance running in the background, some threads can be deleted/created without any specific action in the test. However, if the test does not work as expected, or if the test should not impact these resources, it's worth checking these log lines [computeroutput]+...hbase.ResourceChecker(157): before...+ and [computeroutput]+...hbase.ResourceChecker(157): after...+. -For example: +For example: ---- 2012-09-26 09:22:15,315 INFO [pool-1-thread-1] @@ -1061,9 +1157,7 @@ ConnectionCount=1 (was 1) * All tests must be categorized, if not they could be skipped. * All tests should be written to be as fast as possible. -* Small category tests should last less than 15 seconds, and must not have any side effect. -* Medium category tests should last less than 50 seconds. -* Large category tests should last less than 3 minutes. +* See <<hbase.unittests,hbase.unittests> for test case categories and corresponding timeouts. This should ensure a good parallelization for people using it, and ease the analysis when the test fails. [[hbase.tests.sleeps]] @@ -1076,10 +1170,10 @@ This allows understanding what the test is waiting for. Moreover, the test will work whatever the machine performance is. Sleep should be minimal to be as fast as possible. Waiting for a variable should be done in a 40ms sleep loop. -Waiting for a socket operation should be done in a 200 ms sleep loop. +Waiting for a socket operation should be done in a 200 ms sleep loop. [[hbase.tests.cluster]] -==== Tests using a cluster +==== Tests using a cluster Tests using a HRegion do not have to start a cluster: A region can use the local file system. Start/stopping a cluster cost around 10 seconds. @@ -1087,7 +1181,50 @@ They should not be started per test method but per test class. Started cluster must be shutdown using [method]+HBaseTestingUtility#shutdownMiniCluster+, which cleans the directories. As most as possible, tests should use the default settings for the cluster. When they don't, they should document it. -This will allow to share the cluster later. +This will allow to share the cluster later. + +[[hbase.tests.example.code]] +==== Tests Skeleton Code + +Here is a test skeleton code with Categorization and a Category-based timeout rule to copy and paste and use as basis for test contribution. +[source,java] +---- +/** + * Describe what this testcase tests. Talk about resources initialized in @BeforeClass (before + * any test is run) and before each test is run, etc. + */ +// Specify the category as explained in <<hbase.unittests,hbase.unittests>>. +@Category(SmallTests.class) +public class TestExample { + // Replace the TestExample.class in the below with the name of your test fixture class. + private static final Log LOG = LogFactory.getLog(TestExample.class); + + // Handy test rule that allows you subsequently get the name of the current method. See + // down in 'testExampleFoo()' where we use it to log current test's name. + @Rule public TestName testName = new TestName(); + + // The below rule does two things. It decides the timeout based on the category + // (small/medium/large) of the testcase. This @Rule requires that the full testcase runs + // within this timeout irrespective of individual test methods' times. The second + // feature is we'll dump in the log when the test is done a count of threads still + // running. + @Rule public static TestRule timeout = CategoryBasedTimeout.builder(). + withTimeout(this.getClass()).withLookingForStuckThread(true).build(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testExampleFoo() { + LOG.info("Running test " + testName.getMethodName()); + } +} +---- [[integration.tests]] === Integration Tests @@ -1095,16 +1232,16 @@ This will allow to share the cluster later. HBase integration/system tests are tests that are beyond HBase unit tests. They are generally long-lasting, sizeable (the test can be asked to 1M rows or 1B rows), targetable (they can take configuration that will point them at the ready-made cluster they are to run against; integration tests do not include cluster start/stop code), and verifying success, integration tests rely on public APIs only; they do not attempt to examine server internals asserting success/fail. Integration tests are what you would run when you need to more elaborate proofing of a release candidate beyond what unit tests can do. -They are not generally run on the Apache Continuous Integration build server, however, some sites opt to run integration tests as a part of their continuous testing on an actual cluster. +They are not generally run on the Apache Continuous Integration build server, however, some sites opt to run integration tests as a part of their continuous testing on an actual cluster. Integration tests currently live under the _src/test_ directory in the hbase-it submodule and will match the regex: _**/IntegrationTest*.java_. -All integration tests are also annotated with `@Category(IntegrationTests.class)`. +All integration tests are also annotated with `@Category(IntegrationTests.class)`. Integration tests can be run in two modes: using a mini cluster, or against an actual distributed cluster. Maven failsafe is used to run the tests using the mini cluster. IntegrationTestsDriver class is used for executing the tests against a distributed cluster. Integration tests SHOULD NOT assume that they are running against a mini cluster, and SHOULD NOT use private API's to access cluster state. -To interact with the distributed or mini cluster uniformly, `IntegrationTestingUtility`, and `HBaseCluster` classes, and public client API's can be used. +To interact with the distributed or mini cluster uniformly, `IntegrationTestingUtility`, and `HBaseCluster` classes, and public client API's can be used. On a distributed cluster, integration tests that use ChaosMonkey or otherwise manipulate services thru cluster manager (e.g. restart regionservers) use SSH to do it. @@ -1118,15 +1255,15 @@ The argument 1 (%1$s) is SSH options set the via opts setting or via environment ---- /usr/bin/ssh %1$s %2$s%3$s%4$s "su hbase - -c \"%5$s\"" ---- -That way, to kill RS (for example) integration tests may run: +That way, to kill RS (for example) integration tests may run: [source,bash] ---- {/usr/bin/ssh some-hostname "su hbase - -c \"ps aux | ... | kill ...\""} ---- -The command is logged in the test logs, so you can verify it is correct for your environment. +The command is logged in the test logs, so you can verify it is correct for your environment. To disable the running of Integration Tests, pass the following profile on the command line `-PskipIntegrationTests`. -For example, +For example, [source] ---- $ mvn clean install test -Dtest=TestZooKeeper -PskipIntegrationTests @@ -1136,7 +1273,7 @@ $ mvn clean install test -Dtest=TestZooKeeper -PskipIntegrationTests ==== Running integration tests against mini cluster HBase 0.92 added a `verify` maven target. -Invoking it, for example by doing `mvn verify`, will run all the phases up to and including the verify phase via the maven link:http://maven.apache.org/plugins/maven-failsafe-plugin/[failsafe +Invoking it, for example by doing `mvn verify`, will run all the phases up to and including the verify phase via the maven link:https://maven.apache.org/plugins/maven-failsafe-plugin/[failsafe plugin], running all the above mentioned HBase unit tests as well as tests that are in the HBase integration test group. After you have completed +mvn install -DskipTests+ You can run just the integration tests by invoking: @@ -1148,9 +1285,9 @@ mvn verify ---- If you just want to run the integration tests in top-level, you need to run two commands. -First: +mvn failsafe:integration-test+ This actually runs ALL the integration tests. +First: +mvn failsafe:integration-test+ This actually runs ALL the integration tests. -NOTE: This command will always output `BUILD SUCCESS` even if there are test failures. +NOTE: This command will always output `BUILD SUCCESS` even if there are test failures. At this point, you could grep the output by hand looking for failed tests. However, maven will do this for us; just use: +mvn @@ -1161,19 +1298,19 @@ However, maven will do this for us; just use: +mvn This is very similar to how you specify running a subset of unit tests (see above), but use the property `it.test` instead of `test`. To just run `IntegrationTestClassXYZ.java`, use: +mvn - failsafe:integration-test -Dit.test=IntegrationTestClassXYZ+ The next thing you might want to do is run groups of integration tests, say all integration tests that are named IntegrationTestClassX*.java: +mvn failsafe:integration-test -Dit.test=*ClassX*+ This runs everything that is an integration test that matches *ClassX*. This means anything matching: "**/IntegrationTest*ClassX*". You can also run multiple groups of integration tests using comma-delimited lists (similar to unit tests). Using a list of matches still supports full regex matching for each of the groups.This would look something like: +mvn - failsafe:integration-test -Dit.test=*ClassX*, *ClassY+ + failsafe:integration-test -Dit.test=IntegrationTestClassXYZ+ The next thing you might want to do is run groups of integration tests, say all integration tests that are named IntegrationTestClassX*.java: +mvn failsafe:integration-test -Dit.test=*ClassX*+ This runs everything that is an integration test that matches *ClassX*. This means anything matching: "**/IntegrationTest*ClassX*". You can also run multiple groups of integration tests using comma-delimited lists (similar to unit tests). Using a list of matches still supports full regex matching for each of the groups. This would look something like: +mvn + failsafe:integration-test -Dit.test=*ClassX*, *ClassY+ [[maven.build.commands.integration.tests.distributed]] ==== Running integration tests against distributed cluster If you have an already-setup HBase cluster, you can launch the integration tests by invoking the class `IntegrationTestsDriver`. You may have to run test-compile first. -The configuration will be picked by the bin/hbase script. +The configuration will be picked by the bin/hbase script. [source,bourne] ---- mvn test-compile ----- +---- Then launch the tests with: [source,bourne] @@ -1186,26 +1323,30 @@ Running the IntegrationTestsDriver without any argument will launch tests found See the usage, by passing -h, to see how to filter test classes. You can pass a regex which is checked against the full class name; so, part of class name can be used. IntegrationTestsDriver uses Junit to run the tests. -Currently there is no support for running integration tests against a distributed cluster using maven (see link:https://issues.apache.org/jira/browse/HBASE-6201[HBASE-6201]). +Currently there is no support for running integration tests against a distributed cluster using maven (see link:https://issues.apache.org/jira/browse/HBASE-6201[HBASE-6201]). The tests interact with the distributed cluster by using the methods in the `DistributedHBaseCluster` (implementing `HBaseCluster`) class, which in turn uses a pluggable `ClusterManager`. Concrete implementations provide actual functionality for carrying out deployment-specific and environment-dependent tasks (SSH, etc). The default `ClusterManager` is `HBaseClusterManager`, which uses SSH to remotely execute start/stop/kill/signal commands, and assumes some posix commands (ps, etc). Also assumes the user running the test has enough "power" to start/stop servers on the remote machines. By default, it picks up `HBASE_SSH_OPTS`, `HBASE_HOME`, `HBASE_CONF_DIR` from the env, and uses `bin/hbase-daemon.sh` to carry out the actions. -Currently tarball deployments, deployments which uses _hbase-daemons.sh_, and link:http://incubator.apache.org/ambari/[Apache Ambari] deployments are supported. +Currently tarball deployments, deployments which uses _hbase-daemons.sh_, and link:https://incubator.apache.org/ambari/[Apache Ambari] deployments are supported. _/etc/init.d/_ scripts are not supported for now, but it can be easily added. -For other deployment options, a ClusterManager can be implemented and plugged in. +For other deployment options, a ClusterManager can be implemented and plugged in. [[maven.build.commands.integration.tests.destructive]] -==== Destructive integration / system tests +==== Destructive integration / system tests (ChaosMonkey) + +HBase 0.96 introduced a tool named `ChaosMonkey`, modeled after +link:https://netflix.github.io/chaosmonkey/[same-named tool by Netflix's Chaos Monkey tool]. +ChaosMonkey simulates real-world +faults in a running cluster by killing or disconnecting random servers, or injecting +other failures into the environment. You can use ChaosMonkey as a stand-alone tool +to run a policy while other tests are running. In some environments, ChaosMonkey is +always running, in order to constantly check that high availability and fault tolerance +are working as expected. -In 0.96, a tool named `ChaosMonkey` has been introduced. -It is modeled after the link:http://techblog.netflix.com/2012/07/chaos-monkey-released-into-wild.html[same-named tool by Netflix]. -Some of the tests use ChaosMonkey to simulate faults in the running cluster in the way of killing random servers, disconnecting servers, etc. -ChaosMonkey can also be used as a stand-alone tool to run a (misbehaving) policy while you are running other tests. +ChaosMonkey defines *Actions* and *Policies*. -ChaosMonkey defines Action's and Policy's. -Actions are sequences of events. -We have at least the following actions: +Actions:: Actions are predefined sequences of events, such as the following: * Restart active master (sleep 5 sec) * Restart random regionserver (sleep 5 sec) @@ -1215,23 +1356,17 @@ We have at least the following actions: * Batch restart of 50% of regionservers (sleep 5 sec) * Rolling restart of 100% of regionservers (sleep 5 sec) -Policies on the other hand are responsible for executing the actions based on a strategy. -The default policy is to execute a random action every minute based on predefined action weights. -ChaosMonkey executes predefined named policies until it is stopped. -More than one policy can be active at any time. +Policies:: A policy is a strategy for executing one or more actions. The default policy +executes a random action every minute based on predefined action weights. +A given policy will be executed until ChaosMonkey is interrupted. -To run ChaosMonkey as a standalone tool deploy your HBase cluster as usual. -ChaosMonkey uses the configuration from the bin/hbase script, thus no extra configuration needs to be done. -You can invoke the ChaosMonkey by running: - -[source,bourne] ----- -bin/hbase org.apache.hadoop.hbase.util.ChaosMonkey ----- - -This will output smt like: +Most ChaosMonkey actions are configured to have reasonable defaults, so you can run +ChaosMonkey against an existing cluster without any additional configuration. The +following example runs ChaosMonkey with the default configuration: +[source,bash] ---- +$ bin/hbase org.apache.hadoop.hbase.util.ChaosMonkey 12/11/19 23:21:57 INFO util.ChaosMonkey: Using ChaosMonkey Policy: class org.apache.hadoop.hbase.util.ChaosMonkey$PeriodicRandomActionPolicy, period:60000 12/11/19 23:21:57 INFO util.ChaosMonkey: Sleeping for 26953 to add jitter @@ -1270,31 +1405,38 @@ This will output smt like: 12/11/19 23:24:27 INFO util.ChaosMonkey: Started region server:rs3.example.com,60020,1353367027826. Reported num of rs:6 ---- -As you can see from the log, ChaosMonkey started the default PeriodicRandomActionPolicy, which is configured with all the available actions, and ran RestartActiveMaster and RestartRandomRs actions. -ChaosMonkey tool, if run from command line, will keep on running until the process is killed. +The output indicates that ChaosMonkey started the default `PeriodicRandomActionPolicy` +policy, which is configured with all the available actions. It chose to run `RestartActiveMaster` and `RestartRandomRs` actions. + +==== Available Policies +HBase ships with several ChaosMonkey policies, available in the +`hbase/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/policies/` directory. [[chaos.monkey.properties]] -==== Passing individual Chaos Monkey per-test Settings/Properties +==== Configuring Individual ChaosMonkey Actions -Since HBase version 1.0.0 (link:https://issues.apache.org/jira/browse/HBASE-11348[HBASE-11348]), the chaos monkeys is used to run integration tests can be configured per test run. -Users can create a java properties file and and pass this to the chaos monkey with timing configurations. -The properties file needs to be in the HBase classpath. -The various properties that can be configured and their default values can be found listed in the `org.apache.hadoop.hbase.chaos.factories.MonkeyConstants` class. -If any chaos monkey configuration is missing from the property file, then the default values are assumed. -For example: +Since HBase version 1.0.0 (link:https://issues.apache.org/jira/browse/HBASE-11348[HBASE-11348]), +ChaosMonkey integration tests can be configured per test run. +Create a Java properties file in the HBase classpath and pass it to ChaosMonkey using +the `-monkeyProps` configuration flag. Configurable properties, along with their default +values if applicable, are listed in the `org.apache.hadoop.hbase.chaos.factories.MonkeyConstants` +class. For properties that have defaults, you can override them by including them +in your properties file. + +The following example uses a properties file called <<monkey.properties,monkey.properties>>. [source,bourne] ---- - -$bin/hbase org.apache.hadoop.hbase.IntegrationTestIngest -m slowDeterministic -monkeyProps monkey.properties +$ bin/hbase org.apache.hadoop.hbase.IntegrationTestIngest -m slowDeterministic -monkeyProps monkey.properties ---- The above command will start the integration tests and chaos monkey passing the properties file _monkey.properties_. Here is an example chaos monkey file: +[[monkey.properties]] +.Example ChaosMonkey Properties File [source] ---- - sdm.action1.period=120000 sdm.action2.period=40000 move.regions.sleep.time=80000 @@ -1303,14 +1445,43 @@ move.regions.sleep.time=80000 batch.restart.rs.ratio=0.4f ---- +HBase 1.0.2 and newer adds the ability to restart HBase's underlying ZooKeeper quorum or +HDFS nodes. To use these actions, you need to configure some new properties, which +have no reasonable defaults because they are deployment-specific, in your ChaosMonkey +properties file, which may be `hbase-site.xml` or a different properties file. + +[source,xml] +---- +<property> + <name>hbase.it.clustermanager.hadoop.home</name> + <value>$HADOOP_HOME</value> +</property> +<property> + <name>hbase.it.clustermanager.zookeeper.home</name> + <value>$ZOOKEEPER_HOME</value> +</property> +<property> + <name>hbase.it.clustermanager.hbase.user</name> + <value>hbase</value> +</property> +<property> + <name>hbase.it.clustermanager.hadoop.hdfs.user</name> + <value>hdfs</value> +</property> +<property> + <name>hbase.it.clustermanager.zookeeper.user</name> + <value>zookeeper</value> +</property> +---- + [[developing]] == Developer Guidelines -=== Codelines +=== Branches -Most development is done on the master branch, which is named `master` in the Git repository. -Previously, HBase used Subversion, in which the master branch was called `TRUNK`. -Branches exist for minor releases, and important features and bug fixes are often back-ported. +We use Git for source code management and latest development happens on `master` branch. There are +branches for past major/minor/maintenance releases and important features and bug fixes are often + back-ported to them. === Release Managers @@ -1326,25 +1497,29 @@ NOTE: End-of-life releases are not included in this list. |=== | Release | Release Manager -| 0.98 -| Andrew Purtell -| 1.0 -| Enis Soztutar +| 1.1 +| Nick Dimiduk + +| 1.2 +| Sean Busbey + +| 1.3 +| Mikhail Antonov + |=== [[code.standards]] === Code Standards -See <<eclipse.code.formatting,eclipse.code.formatting>> and <<common.patch.feedback,common.patch.feedback>>. ==== Interface Classifications Interfaces are classified both by audience and by stability level. These labels appear at the head of a class. -The conventions followed by HBase are inherited by its parent project, Hadoop. +The conventions followed by HBase are inherited by its parent project, Hadoop. -The following interface classifications are commonly used: +The following interface classifications are commonly used: .InterfaceAudience `@InterfaceAudience.Public`:: @@ -1358,8 +1533,6 @@ The following interface classifications are commonly used: `@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)`:: APIs for HBase coprocessor writers. - As of HBase 0.92/0.94/0.96/0.98 this api is still unstable. - No guarantees on compatibility with future versions. No `@InterfaceAudience` Classification:: Packages without an `@InterfaceAudience` label are considered private. @@ -1368,7 +1541,7 @@ No `@InterfaceAudience` Classification:: .Excluding Non-Public Interfaces from API Documentation [NOTE] ==== -Only interfaces classified `@InterfaceAudience.Public` should be included in API documentation (Javadoc). Committers must add new package excludes `ExcludePackageNames` section of the _pom.xml_ for new packages which do not contain public classes. +Only interfaces classified `@InterfaceAudience.Public` should be included in API documentation (Javadoc). Committers must add new package excludes `ExcludePackageNames` section of the _pom.xml_ for new packages which do not contain public classes. ==== .@InterfaceStability @@ -1386,7 +1559,7 @@ Only interfaces classified `@InterfaceAudience.Public` should be included in API No `@InterfaceStability` Label:: Public classes with no `@InterfaceStability` label are discouraged, and should be considered implicitly unstable. -If you are unclear about how to mark packages, ask on the development list. +If you are unclear about how to mark packages, ask on the development list. [[common.patch.feedback]] ==== Code Formatting Conventions @@ -1396,6 +1569,8 @@ These guidelines have been developed based upon common feedback on patches from See the link:http://www.oracle.com/technetwork/java/index-135089.html[Code Conventions for the Java Programming Language] for more information on coding conventions in Java. +See <<eclipse.code.formatting,eclipse.code.formatting>> to setup Eclipse to check for some of +these guidelines automatically. [[common.patch.feedback.space.invaders]] ===== Space Invaders @@ -1470,7 +1645,6 @@ Bar bar = foo.veryLongMethodWithManyArguments( [[common.patch.feedback.trailingspaces]] ===== Trailing Spaces -Trailing spaces are a common problem. Be sure there is a line break after the end of your code, and avoid lines with nothing but whitespace. This makes diffs more meaningful. You can configure your IDE to help with this. @@ -1484,21 +1658,22 @@ Bar bar = foo.getBar(); <--- imagine there is an extra space(s) after the se [[common.patch.feedback.javadoc]] ===== API Documentation (Javadoc) -This is also a very common feedback item. Don't forget Javadoc! Javadoc warnings are checked during precommit. If the precommit tool gives you a '-1', please fix the javadoc issue. -Your patch won't be committed if it adds such warnings. +Your patch won't be committed if it adds such warnings. + +Also, no `@author` tags - that's a rule. [[common.patch.feedback.findbugs]] ===== Findbugs `Findbugs` is used to detect common bugs pattern. -It is checked during the precommit build by Apache's Jenkins. +It is checked during the precommit build. If errors are found, please fix them. -You can run findbugs locally with +mvn - findbugs:findbugs+, which will generate the `findbugs` files locally. +You can run findbugs locally with `mvn + findbugs:findbugs`, which will generate the `findbugs` files locally. Sometimes, you may have to write code smarter than `findbugs`. You can annotate your code to tell `findbugs` you know what you're doing, by annotating your class with the following annotation: @@ -1509,38 +1684,42 @@ value="HE_EQUALS_USE_HASHCODE", justification="I know what I'm doing") ---- -It is important to use the Apache-licensed version of the annotations. +It is important to use the Apache-licensed version of the annotations. That generally means using +annotations in the `edu.umd.cs.findbugs.annotations` package so that we can rely on the cleanroom +reimplementation rather than annotations in the `javax.annotations` package. [[common.patch.feedback.javadoc.defaults]] ===== Javadoc - Useless Defaults -Don't just leave the @param arguments the way your IDE generated them.: +Don't just leave javadoc tags the way IDE generates them, or fill redundant information in them. [source,java] ---- /** - * - * @param bar <---- don't do this!!!! - * @return <---- or this!!!! + * @param table <---- don't leave them empty! + * @param region An HRegion object. <---- don't fill redundant information! + * @return Foo Object foo just created. <---- Not useful information + * @throws SomeException <---- Not useful. Function declarations already tell that! + * @throws BarException when something went wrong <---- really? */ - public Foo getFoo(Bar bar); + public Foo createFoo(Bar bar); ---- -Either add something descriptive to the @`param` and @`return` lines, or just remove them. +Either add something descriptive to the tags, or just remove them. The preference is to add something descriptive and useful. [[common.patch.feedback.onething]] ===== One Thing At A Time, Folks -If you submit a patch for one thing, don't do auto-reformatting or unrelated reformatting of code on a completely different area of code. +If you submit a patch for one thing, don't do auto-reformatting or unrelated reformatting of code on a completely different area of code. -Likewise, don't add unrelated cleanup or refactorings outside the scope of your Jira. +Likewise, don't add unrelated cleanup or refactorings outside the scope of your Jira. [[common.patch.feedback.tests]] ===== Ambigious Unit Tests -Make sure that you're clear about what you are testing in your unit tests and why. +Make sure that you're clear about what you are testing in your unit tests and why. [[common.patch.feedback.writable]] ===== Implementing Writable @@ -1548,24 +1727,38 @@ Make sure that you're clear about what you are testing in your unit tests and wh .Applies pre-0.96 only [NOTE] ==== -In 0.96, HBase moved to protocol buffers (protobufs). The below section on Writables applies to 0.94.x and previous, not to 0.96 and beyond. +In 0.96, HBase moved to protocol buffers (protobufs). The below section on Writables applies to 0.94.x and previous, not to 0.96 and beyond. ==== Every class returned by RegionServers must implement the `Writable` interface. -If you are creating a new class that needs to implement this interface, do not forget the default constructor. +If you are creating a new class that needs to implement this interface, do not forget the default constructor. + +==== Garbage-Collection Conserving Guidelines + +The following guidelines were borrowed from http://engineering.linkedin.com/performance/linkedin-feed-faster-less-jvm-garbage. +Keep them in mind to keep preventable garbage collection to a minimum. Have a look +at the blog post for some great examples of how to refactor your code according to +these guidelines. + +- Be careful with Iterators +- Estimate the size of a collection when initializing +- Defer expression evaluation +- Compile the regex patterns in advance +- Cache it if you can +- String Interns are useful but dangerous [[design.invariants]] === Invariants We don't have many but what we have we list below. -All are subject to challenge of course but until then, please hold to the rules of the road. +All are subject to challenge of course but until then, please hold to the rules of the road. [[design.invariants.zk.data]] ==== No permanent state in ZooKeeper ZooKeeper state should transient (treat it like memory). If ZooKeeper state is deleted, hbase should be able to recover and essentially be in the same state. -* .ExceptionsThere are currently a few exceptions that we need to fix around whether a table is enabled or disabled. +* .Exceptions: There are currently a few exceptions that we need to fix around whether a table is enabled or disabled. * Replication data is currently stored only in ZooKeeper. Deleting ZooKeeper data related to replication may cause replication to be disabled. Do not delete the replication tree, _/hbase/replication/_. @@ -1579,14 +1772,14 @@ Follow progress on this issue at link:https://issues.apache.org/jira/browse/HBAS If you are developing Apache HBase, frequently it is useful to test your changes against a more-real cluster than what you find in unit tests. In this case, HBase can be run directly from the source in local-mode. -All you need to do is run: +All you need to do is run: [source,bourne] ---- ${HBASE_HOME}/bin/start-hbase.sh ---- -This will spin up a full local-cluster, just as if you had packaged up HBase and installed it on your machine. +This will spin up a full local-cluster, just as if you had packaged up HBase and installed it on your machine. Keep in mind that you will need to have installed HBase into your local maven repository for the in-situ cluster to work properly. That is, you will need to run: @@ -1607,27 +1800,25 @@ HBase exposes metrics using the Hadoop Metrics 2 system, so adding a new metric Unfortunately the API of metri
<TRUNCATED>