4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 = Building and Developing Apache HBase
30 This chapter contains information and guidelines for building and releasing HBase code and documentation.
31 Being familiar with these guidelines will help the HBase committers to use your contributions more easily.
36 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'].
37 These are issues HBase contributors have deemed worthy but not of immediate priority and a good way to ramp on HBase internals.
38 See link:http://search-hadoop.com/m/DHED43re96[What label
39 is used for issues that are good on ramps for new contributors?] from the dev mailing list for background.
41 Before you get started submitting code to HBase, please refer to <<developing,developing>>.
43 As Apache HBase is an Apache Software Foundation project, see <<asf,asf>> for more information about how the ASF functions.
48 Sign up for the dev-list and the user-list.
49 See the link:https://hbase.apache.org/mail-lists.html[mailing lists] page.
50 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.)
54 The Apache HBase project has its own link: http://apache-hbase.slack.com[Slack Channel] for real-time questions
55 and discussion. Mail dev@hbase.apache.org to request an invite.
58 === Internet Relay Chat (IRC)
60 (NOTE: Our IRC channel seems to have been deprecated in favor of the above Slack channel)
62 For real-time questions and discussions, use the `#hbase` IRC channel on the link:https://freenode.net/[FreeNode] IRC network.
63 FreeNode offers a web-based client, but most people prefer a native client, and several clients are available for each operating system.
67 Check for existing issues in link:https://issues.apache.org/jira/projects/HBASE/issues[Jira].
68 If it's either a new feature request, enhancement, or a bug, file a ticket.
70 We track multiple types of work in JIRA:
72 - Bug: Something is broken in HBase itself.
73 - Test: A test is needed, or a test is broken.
74 - New feature: You have an idea for new functionality. It's often best to bring
75 these up on the mailing lists first, and then write up a design specification
76 that you add to the feature request JIRA.
77 - Improvement: A feature exists, but could be tweaked or augmented. It's often
78 best to bring these up on the mailing lists first and have a discussion, then
79 summarize or link to the discussion if others seem interested in the
81 - Wish: This is like a new feature, but for something you may not have the
82 background to flesh out yourself.
84 Bugs and tests have the highest priority and should be actionable.
86 ==== Guidelines for reporting effective issues
88 - *Search for duplicates*: Your issue may have already been reported. Have a
89 look, realizing that someone else might have worded the summary differently.
91 Also search the mailing lists, which may have information about your problem
92 and how to work around it. Don't file an issue for something that has already
93 been discussed and resolved on a mailing list, unless you strongly disagree
94 with the resolution *and* are willing to help take the issue forward.
96 * *Discuss in public*: Use the mailing lists to discuss what you've discovered
97 and see if there is something you've missed. Avoid using back channels, so
98 that you benefit from the experience and expertise of the project as a whole.
100 * *Don't file on behalf of others*: You might not have all the context, and you
101 don't have as much motivation to see it through as the person who is actually
102 experiencing the bug. It's more helpful in the long term to encourage others
103 to file their own issues. Point them to this material and offer to help out
104 the first time or two.
106 * *Write a good summary*: A good summary includes information about the problem,
107 the impact on the user or developer, and the area of the code.
108 ** Good: `Address new license dependencies from hadoop3-alpha4`
109 ** Room for improvement: `Canary is broken`
111 If you write a bad title, someone else will rewrite it for you. This is time
112 they could have spent working on the issue instead.
114 * *Give context in the description*: It can be good to think of this in multiple
116 ** What happens or doesn't happen?
117 ** How does it impact you?
118 ** How can someone else reproduce it?
119 ** What would "fixed" look like?
121 You don't need to know the answers for all of these, but give as much
122 information as you can. If you can provide technical information, such as a
123 Git commit SHA that you think might have caused the issue or a build failure
124 on builds.apache.org where you think the issue first showed up, share that
127 * *Fill in all relevant fields*: These fields help us filter, categorize, and
130 * *One bug, one issue, one patch*: To help with back-porting, don't split issues
131 or fixes among multiple bugs.
133 * *Add value if you can*: Filing issues is great, even if you don't know how to
134 fix them. But providing as much information as possible, being willing to
135 triage and answer questions, and being willing to test potential fixes is even
136 better! We want to fix your issue as quickly as you want it to be fixed.
138 * *Don't be upset if we don't fix it*: Time and resources are finite. In some
139 cases, we may not be able to (or might choose not to) fix an issue, especially
140 if it is an edge case or there is a workaround. Even if it doesn't get fixed,
141 the JIRA is a public record of it, and will help others out if they run into
142 a similar issue in the future.
144 ==== Working on an issue
146 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'].
149 * *Blocker*: Should only be used if the issue WILL cause data loss or cluster instability reliably.
150 * *Critical*: The issue described can cause data loss or cluster instability in some cases.
151 * *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.
152 * *Minor*: Useful enhancements and annoying but not damaging bugs.
153 * *Trivial*: Useful enhancements but generally cosmetic.
155 .Code Blocks in Jira Comments
157 A commonly used macro in Jira is {code}. Everything inside the tags is preformatted, as in this example.
169 == Apache HBase Repositories
171 Apache HBase consists of multiple repositories which are hosted on https://gitbox.apache.org/[Apache GitBox].
172 These are the following:
174 * https://gitbox.apache.org/repos/asf?p=hbase.git[hbase] - main Apache HBase repository
175 * https://gitbox.apache.org/repos/asf?p=hbase-connectors.git[hbase-connectors] - connectors to Apache Kafka and Apache Spark
176 * https://gitbox.apache.org/repos/asf?p=hbase-operator-tools.git[hbase-operator-tools] - operability and supportability tools, such as <<HBCK2>>
177 * https://gitbox.apache.org/repos/asf?p=hbase-site.git[hbase-site] - hbase.apache.org website
178 * https://gitbox.apache.org/repos/asf?p=hbase-thirdparty.git[hbase-thirdparty] - relocated versions of popular third-party libraries
185 [[eclipse.code.formatting]]
188 Under the _dev-support/_ folder, you will find _hbase_eclipse_formatter.xml_.
189 We encourage you to have this formatter in place in eclipse when editing HBase code.
191 Go to `Preferences->Java->Code Style->Formatter->Import` to load the xml file.
192 Go to `Preferences->Java->Editor->Save Actions`, and make sure 'Format source code' and 'Format
193 edited lines' is selected.
195 In addition to the automatic formatting, make sure you follow the style guidelines explained in
196 <<common.patch.feedback,common.patch.feedback>>.
198 [[eclipse.git.plugin]]
199 ==== Eclipse Git Plugin
201 If you cloned the project via git, download and install the Git plugin (EGit). Attach to your local git repo (via the [label]#Git Repositories# window) and you'll be able to see file revision history, generate patches, etc.
203 [[eclipse.maven.setup]]
204 ==== HBase Project Setup in Eclipse using `m2eclipse`
206 The easiest way is to use the +m2eclipse+ plugin for Eclipse.
207 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.
209 To import the project, click and select the HBase root directory. `m2eclipse` locates all the hbase modules for you.
211 If you install +m2eclipse+ and import HBase in your workspace, do the following to fix your eclipse Build Path.
213 . Remove _target_ folder
214 . Add _target/generated-jamon_ and _target/generated-sources/java_ folders.
215 . 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:
218 Failed to execute goal
219 org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project hbase:
220 'An Ant BuildException has occurred: Replace: source file .../target/classes/hbase-default.xml
224 This will also reduce the eclipse build cycles and make your life easier when developing.
227 [[eclipse.commandline]]
228 ==== HBase Project Setup in Eclipse Using the Command Line
230 Instead of using `m2eclipse`, you can generate the Eclipse files from the command line.
232 . First, run the following command, which builds HBase.
233 You only need to do this once.
237 mvn clean install -DskipTests
240 . Close Eclipse, and execute the following command from the terminal, in your local HBase project directory, to generate new _.project_ and _.classpath_ files.
247 . Reopen Eclipse and import the _.project_ file in the HBase directory to a workspace.
249 [[eclipse.maven.class]]
250 ==== Maven Classpath Variable
252 The `$M2_REPO` classpath variable needs to be set up for the project.
253 This needs to be set to your local Maven repository, which is usually _~/.m2/repository_
255 If this classpath variable is not configured, you will see compile errors in Eclipse like this:
259 Description Resource Path Location Type
260 The project cannot be built until build path errors are resolved hbase Unknown Java Problem
261 Unbound classpath variable: 'M2_REPO/asm/asm/3.1/asm-3.1.jar' in project 'hbase' hbase Build path Build Path Problem
262 Unbound classpath variable: 'M2_REPO/com/google/guava/guava/r09/guava-r09.jar' in project 'hbase' hbase Build path Build Path Problem
263 Unbound classpath variable: 'M2_REPO/com/google/protobuf/protobuf-java/2.3.0/protobuf-java-2.3.0.jar' in project 'hbase' hbase Build path Build Path Problem Unbound classpath variable:
267 ==== Eclipse Known Issues
269 Eclipse will currently complain about _Bytes.java_.
270 It is not possible to turn these errors off.
274 Description Resource Path Location Type
275 Access restriction: The method arrayBaseOffset(Class) from the type Unsafe is not accessible due to restriction on required library /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar Bytes.java /hbase/src/main/java/org/apache/hadoop/hbase/util line 1061 Java Problem
276 Access restriction: The method arrayIndexScale(Class) from the type Unsafe is not accessible due to restriction on required library /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar Bytes.java /hbase/src/main/java/org/apache/hadoop/hbase/util line 1064 Java Problem
277 Access restriction: The method getLong(Object, long) from the type Unsafe is not accessible due to restriction on required library /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar Bytes.java /hbase/src/main/java/org/apache/hadoop/hbase/util line 1111 Java Problem
281 ==== Eclipse - More Information
283 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.
287 A functional development environment can be setup around an IntelliJ IDEA installation that has the
288 plugins necessary for building Java projects with Maven.
290 . Use either File > New > "Project from Existing Sources..." or "Project From Version Control.."
291 . Depending on your version of IntelliJ, you may need to choose Maven as the "project" or "model"
294 The following plugins are recommended:
296 . Maven, bundled. This allows IntelliJ to resolve dependencies and recognize the project structure.
297 . EditorConfig, bundled. This will apply project whitespace settings found in the the
298 `.editorconfig` file available on branches with
299 link:https://issues.apache.org/jira/browse/HBASE-23234[HBASE-23234] or later.
300 . link:https://plugins.jetbrains.com/plugin/1065-checkstyle-idea/[Checkstyle-IDEA]. Configure this
301 against the configuration file found under `hbase-checkstyle/src/main/resources/hbase/checkstyle.xml`
302 (If the Intellij checkstyle plugin complains parsing the volunteered hbase `checkstyle.xml`, make
303 sure the plugin's `version` popup menu matches the hbase checkstyle version -- see
304 link:https://issues.apache.org/jira/browse/HBASE-23242[HBASE-23242] for more).
305 This plugin will highlight style errors in the IDE, so you can fix them before they get flagged during the
307 . link:https://plugins.jetbrains.com/plugin/8277-protobuf-support/[Protobuf Support]. HBase uses
308 link:https://developers.google.com/protocol-buffers/[Protocol Buffers] in a number of places where
309 serialization is required. This plugin is helpful when editing these object definitions.
310 . link:https://plugins.jetbrains.com/plugin/7391-asciidoc/[AsciiDoc]. HBase uses
311 link:http://asciidoc.org[AsciiDoc] for building it's project documentation. This plugin is helpful
312 when editing this book.
316 If you'd have another environment with which you'd like to develop on HBase, please consider
317 documenting your setup process here.
320 == Building Apache HBase
325 HBase is compiled using Maven.
326 You must use at least Maven 3.0.4.
327 To check your Maven version, run the command +mvn -version+.
329 .JDK Version Requirements
332 Starting with HBase 1.0 you must use Java 7 or later to build from source code.
333 See <<java,java>> for more complete information about supported JDK versions.
336 [[maven.build.commands]]
337 ==== Maven Build Commands
339 All commands are executed from the local HBase project directory.
343 The simplest command to compile HBase from its java source code is to use the `package` target, which builds JARs with the compiled files.
347 mvn package -DskipTests
350 Or, to clean up before compiling:
354 mvn clean package -DskipTests
357 With Eclipse set up as explained above in <<eclipse,eclipse>>, you can also use the menu:Build[] command in Eclipse.
358 To create the full installable HBase package takes a little bit more work, so read on.
360 [[maven.build.commands.compile]]
363 The `compile` target does not create the JARs with the compiled files.
377 To install the JARs in your _~/.m2/_ directory, use the `install` target.
391 mvn clean install -DskipTests
394 [[maven.build.commands.unitall]]
395 ==== Running all or individual Unit Tests
397 See the <<hbase.unittests.cmds,hbase.unittests.cmds>> section in <<hbase.unittests,hbase.unittests>>
399 [[maven.build.hadoop]]
400 ==== Building against various hadoop versions.
402 HBase supports building against Apache Hadoop versions: 2.y and 3.y (early release artifacts). By default we build against Hadoop 2.x.
404 To build against a specific release from the Hadoop 2.y line, set e.g. `-Dhadoop-two.version=2.6.3`.
408 mvn -Dhadoop-two.version=2.6.3 ...
411 To change the major release line of Hadoop we build against, add a hadoop.profile property when you invoke +mvn+:
415 mvn -Dhadoop.profile=3.0 ...
418 The above will build against whatever explicit hadoop 3.y version we have in our _pom.xml_ as our '3.0' version.
419 Tests may not all pass so you may need to pass `-DskipTests` unless you are inclined to fix the failing tests.
421 To pick a particular Hadoop 3.y release, you'd set hadoop-three.version property e.g. `-Dhadoop-three.version=3.0.0`.
426 You may need to change the protobuf definitions that reside in the _hbase-protocol_ module or other modules.
428 Previous to hbase-2.0.0, protobuf definition files were sprinkled across all hbase modules but now all
429 to do with protobuf must reside in the hbase-protocol module; we are trying to contain our protobuf
430 use so we can freely change versions without upsetting any downstream project use of protobuf.
432 The protobuf files are located in _hbase-protocol/src/main/protobuf_.
433 For the change to be effective, you will need to regenerate the classes.
437 mvn package -pl hbase-protocol -am
440 Similarly, protobuf definitions for internal use are located in the _hbase-protocol-shaded_ module.
444 mvn package -pl hbase-protocol-shaded -am
447 Typically, protobuf code generation is done using the native `protoc` binary. In our build we use a maven plugin for
448 convenience; however, the plugin may not be able to retrieve appropriate binaries for all platforms. If you find yourself
449 on a platform where protoc fails, you will have to compile protoc from source, and run it independent of our maven build.
450 You can disable the inline code generation by specifying `-Dprotoc.skip` in your maven arguments, allowing your build to proceed further.
453 If you need to manually generate your protobuf files, you should not use `clean` in subsequent maven calls, as that will delete the newly generated files.
455 Read the _hbase-protocol/README.txt_ for more details
460 You may need to change the thrift definitions that reside in the _hbase-thrift_ module or other modules.
462 The thrift files are located in _hbase-thrift/src/main/resources_.
463 For the change to be effective, you will need to regenerate the classes.
464 You can use maven profile `compile-thrift` to do this.
468 mvn compile -Pcompile-thrift
471 You may also want to define `thrift.path` for the thrift binary, using the following command:
476 mvn compile -Pcompile-thrift -Dthrift.path=/opt/local/bin/thrift
481 You can build a tarball without going through the release process described in <<releasing,releasing>>, by running the following command:
484 mvn -DskipTests clean install && mvn -DskipTests package assembly:single
487 The distribution tarball is built in _hbase-assembly/target/hbase-<version>-bin.tar.gz_.
489 You can install or deploy the tarball by having the assembly:single goal before install or deploy in the maven command:
492 mvn -DskipTests package assembly:single install
495 mvn -DskipTests package assembly:single deploy
501 ===== Maven Site failure
502 If you see `Unable to find resource 'VM_global_library.vm'`, ignore it.
504 It is link:https://issues.apache.org/jira/browse/MSITE-286[officially ugly] though.
507 == Releasing Apache HBase
509 .Building against HBase 1.x
512 HBase 1.x requires Java 7 to build.
513 See <<java,java>> for Java requirements per HBase release.
516 [[maven.settings.xml]]
517 .Example _~/.m2/settings.xml_ File
519 Publishing to maven requires you sign the artifacts you want to upload.
520 For the build to sign them for you, you a properly configured _settings.xml_ in your local repository under _.m2_, such as the following.
524 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
525 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
526 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
527 http://maven.apache.org/xsd/settings-1.0.0.xsd">
529 <!- To publish a snapshot of some part of Maven -->
531 <id>apache.snapshots.https</id>
532 <username>YOUR_APACHE_ID
534 <password>YOUR_APACHE_PASSWORD
537 <!-- To publish a website using Maven -->
538 <!-- To stage a release of some part of Maven -->
540 <id>apache.releases.https</id>
541 <username>YOUR_APACHE_ID
543 <password>YOUR_APACHE_PASSWORD
549 <id>apache-release</id>
551 <gpg.keyname>YOUR_KEYNAME</gpg.keyname>
552 <!--Keyname is something like this ... 00A5F21E... do gpg --list-keys to find it-->
553 <gpg.passphrase>YOUR_KEY_PASSWORD
563 === Making a Release Candidate
564 Only committers can make releases of hbase artifacts.
567 Check to be sure recent builds have been passing for the branch from where you
568 are going to take your release. You should also have tried recent branch tips
569 out on a cluster under load, perhaps by running the `hbase-it` integration test
570 suite for a few hours to 'burn in' the near-candidate bits.
572 You will need a published signing key added to the hbase
573 link:https://dist.apache.org/repos/dist/release/hbase/KEYS[KEYS] file.
574 (For how to add a KEY, see _Step 1._ in link:https://cwiki.apache.org/confluence/display/HADOOP2/HowToRelease[How To Release],
575 the Hadoop version of this document).
577 Next make sure JIRA is properly primed, that all issues targeted against
578 the prospective release have been resolved and are present in git on the
579 particular branch. If any outstanding issues, move them out of the release by
580 adjusting the fix version to remove this pending release as a target.
581 Any JIRA with a fix version that matches the release candidate
582 target release will be included in the generated _CHANGES.md/RELEASENOTES.md_
583 files that ship with the release so make sure JIRA is correct before you begin.
585 After doing the above, you can move to the manufacture of an RC.
586 Building an RC is involved. We've tried to script it. In the next section
587 we describe the script. It is followed by a description of the steps
588 involved which the script automates.
590 [[do-release-docker.sh]]
591 ==== Release Candidate Generating Script
593 The _dev-support/create-release/do-release-docker.sh_ Release Candidate (RC)
594 Generating script is maintained in the master branch but can generate RCs
595 for any 2.x+ branch (The script does not work against branch-1). Check out
596 and update the master branch when making RCs.
598 The script builds in a Docker container to ensure we have a consistent
599 environment building. It will ask you for passwords for apache and for your
600 gpg signing key so it can sign and commit on your behalf. The passwords
601 are passed to gpg-agent in the container and purged along with the container
602 when the build is done.
606 _dev-support/create-release/do-release-docker.sh_ supercedes the previous
607 _dev-support/make_rc.sh_ script. It is more comprehensive automating all
608 steps, rather than a portion, building a RC.
613 * Set version to the release version
614 * Updates RELEASENOTES.md and CHANGES.md
616 * Set version to next SNAPSHOT version.
617 * Builds, signs, and hashes all artifacts.
618 * Generates the api compatibility report
619 * Pushes release tgzs to the dev dir in a apache dist.
620 * Pushes to repository.apache.org staging.
621 * Creates vote email template.
623 The RC building script is _dev-support/create-release/do-release-docker.sh_.
624 Pass _-h_ to _dev-support/create-release/do-release-docker.sh_ to
625 see available options:
628 Usage: do-release-docker.sh [options]
630 This script runs the release scripts inside a docker image.
634 -d [path] required. working directory. output will be written to "output" in here.
635 -n dry run mode. Checks and local builds, but does not upload anything.
636 -t [tag] tag for the hbase-rm docker image to use for building (default: "latest").
637 -j [path] path to local JDK installation to use building. By default the script will
638 use openjdk8 installed in the docker image.
639 -s [step] runs a single step of the process; valid steps are: tag, build, publish. if
640 none specified, runs tag, then build, and then publish.
643 Running the below command will do all steps above using the
644 'rm' working directory under Downloads as workspace:
646 $ ./dev-support/create-release/do-release-docker.sh -d ~/Downloads/rm
649 The script will ask you a set of questions about the release version
650 and branch, the version to generate the compatibility report against,
651 and so on, before it starts executing (If you set the appropriate
652 environment variables, the script will skip asking you questions --
653 which can come in handy if you end up having to re-run the script
656 On branch 2.1, a Release Candidate (RC) creation can take many hours
657 (~8 hours) so run your build on a machine you know will be
658 around for this swath of time. Start the build inside a _screen_
659 or _tmux_ session in case you become disconnected from your
662 The build is made of three stages: tag, build, and
663 publish. If the script fails, you may resort to 'fixing' the
664 failure manually and then asking the script to run the
665 subsequent stage rather than start over.
667 When the scripts run, they use the passed working directory.
668 Under the working directory is an _output_ dir. In here is
669 where the checkouts go, where we build up the _svn_ directory
670 to _svn_ commit to _apache/dist/dev_, etc. Each step also
671 dumps a log file in here: e.g. _tag.log_ for the tagging
672 step and _build.log_ for building.
674 The _tagging_ step will checkout hbase, set the version number
675 in all the poms – e.g. if branch-2.0 is at 2.0.6-SNAPSHOT
676 and you are making a 2.0.5 RC, it will set the versions in
677 all poms to 2.0.5 – appropriately. It then generate CHANGES.md
678 and RELEASENOTES.md by checking out yetus and then
679 calling its generator scripts. It then commits the poms with
680 their new versions along with the changed CHANGES.md and
681 RELEASENOTES.md, tags, and pushes up all changes to the
684 The _build_ step will checkout hbase, build all including
685 javadoc and doc (javadoc takes the bulk of the time – 4 hours plus),
686 run assemblies to produce src and bin tarballs, sign and hash it
687 all, and then make a dir under apache dist dev named for the RC.
688 It will copy all artifacts in here including top-level CHANGES.md
689 and RELEASENOTES.md. It will generate api diff docs and put them
690 into this RC dir too. When done, it commits the svn RC.
692 The publish step will checkout hbase, build, and then copy up all
693 artifacts to repository.apache.org (signed and hashed). When done,
694 it will dump out an email template with all the correct links in place.
696 Check the artifacts pushed to the dev distribution directory and up
697 in repository.apache.org. If all looks good, check the generated
698 email and send to the dev list.
700 Under the create-release dir, scripts should make some sense:
702 do-release-docker.sh # Main entrance.
703 do-release.sh . # More checks. Not usable really other than by setting env variables before running it.
704 release-tag.sh # Does tagging steps.
705 release-build.sh . # Does the build and publish step.
706 release-util.sh # Utility used by all of the above.
707 vote.tmpl # Template for email to send out.
708 hbase-rm # Has docker image we use.
711 If the RC fails, the script will do the right thing when it comes
712 to edit of the _CHANGES.md_ and _RELEASENOTES.md_ removing the old
713 and updating the files with the updated content (No harm verifying
716 One trick for checking stuff especially in utility is to do as follows:
719 $ source release-util.sh ; generate_api_report ../../ rel/2.1.3 2.14RC1
722 i.e. source the release-util.sh script and then run one of its functions
723 passing args. Helped debugging stuff.
726 ==== Release Candidate Procedure
727 Here we describe the steps involved generating a Release Candidate, the steps
728 automated by the script described in the previous section.
730 The process below makes use of various tools, mainly _git_ and _maven_.
732 .Specifying the Heap Space for Maven
735 You may run into OutOfMemoryErrors building, particularly building the site and
736 documentation. Up the heap for Maven by setting the `MAVEN_OPTS` variable.
737 You can prefix the variable to the Maven command, as in the following example:
740 MAVEN_OPTS="-Xmx4g -XX:MaxPermSize=256m" mvn package
743 You could also set this in an environment variable or alias in your shell.
746 ===== Update the _CHANGES.md_ and _RELEASENOTES.md_ files and the POM files.
748 Update _CHANGES.md_ with the changes since the last release. Be careful with where you put
749 headings and license. Respect the instructions and warning you find in current
750 _CHANGES.md_ and _RELEASENOTES.md_ since these two files are processed by tooling that is
751 looking for particular string sequences. See link:https://issues.apache.org/jira/browse/HBASE-21399[HBASE-21399]
752 for description on how to make use of yetus generating additions to
753 _CHANGES.md_ and _RELEASENOTES.md_ (RECOMMENDED!). Adding JIRA fixes, make sure the
754 URL to the JIRA points to the proper location which lists fixes for this release.
756 Next, adjust the version in all the POM files appropriately.
757 If you are making a release candidate, you must remove the `-SNAPSHOT` label from all versions
758 in all pom.xml files.
759 If you are running this receipe to publish a snapshot, you must keep the `-SNAPSHOT` suffix on the hbase version.
760 The link:http://www.mojohaus.org/versions-maven-plugin/[Versions Maven Plugin] can be of use here.
761 To set a version in all the many poms of the hbase multi-module project, use a command like the following:
765 $ mvn clean org.codehaus.mojo:versions-maven-plugin:2.5:set -DnewVersion=2.1.0-SNAPSHOT
\x1a
768 Make sure all versions in poms are changed! Checkin the _CHANGES.md_, _RELEASENOTES.md_, and
769 any maven version changes.
771 ===== Update the documentation.
773 Update the documentation under _src/main/asciidoc_.
774 This usually involves copying the latest from master branch and making version-particular
775 adjustments to suit this release candidate version. Commit your changes.
777 ===== Clean the checkout dir
785 Check licenses are good
789 $ mvn apache-rat:check
792 If the above fails, check the rat log.
796 $ grep 'Rat check' patchprocess/mvn_apache_rat.log
799 ===== Create a release tag.
800 Presuming you have run basic tests, the rat check, passes and all is
801 looking good, now is the time to tag the release candidate (You
802 always remove the tag if you need to redo). To tag, do
803 what follows substituting in the version appropriate to your build.
804 All tags should be signed tags; i.e. pass the _-s_ option (See
805 link:http://https://git-scm.com/book/id/v2/Git-Tools-Signing-Your-Work[Signing Your Work]
806 for how to set up your git environment for signing).
810 $ git tag -s 2.0.0-alpha4-RC0 -m "Tagging the 2.0.0-alpha4 first Releae Candidate (Candidates start at zero)"
813 Or, if you are making a release, tags should have a _rel/_ prefix to ensure
814 they are preserved in the Apache repo as in:
818 +$ git tag -s rel/2.0.0-alpha4 -m "Tagging the 2.0.0-alpha4 Release"
821 Push the (specific) tag (only) so others have access.
825 $ git push origin 2.0.0-alpha4-RC0
828 For how to delete tags, see
829 link:http://www.manikrathee.com/how-to-delete-a-tag-in-git.html[How to Delete a Tag]. Covers
830 deleting tags that have not yet been pushed to the remote Apache
831 repo as well as delete of tags pushed to Apache.
833 ===== Build the source tarball.
834 Now, build the source tarball. Lets presume we are building the source
835 tarball for the tag _2.0.0-alpha4-RC0_ into _/tmp/hbase-2.0.0-alpha4-RC0/_
836 (This step requires that the mvn and git clean steps described above have just been done).
840 $ git archive --format=tar.gz --output="/tmp/hbase-2.0.0-alpha4-RC0/hbase-2.0.0-alpha4-src.tar.gz" --prefix="hbase-2.0.0-alpha4/" $git_tag
843 Above we generate the hbase-2.0.0-alpha4-src.tar.gz tarball into the
844 _/tmp/hbase-2.0.0-alpha4-RC0_ build output directory (We don't want the _RC0_ in the name or prefix.
845 These bits are currently a release candidate but if the VOTE passes, they will become the release so we do not taint
846 the artifact names with _RCX_).
848 ===== Build the binary tarball.
849 Next, build the binary tarball. Add the `-Prelease` profile when building.
850 It runs the license apache-rat check among other rules that help ensure
851 all is wholesome. Do it in two steps.
853 First install into the local repository
857 $ mvn clean install -DskipTests -Prelease
860 Next, generate documentation and assemble the tarball. Be warned,
861 this next step can take a good while, a couple of hours generating site
866 $ mvn install -DskipTests site assembly:single -Prelease
869 Otherwise, the build complains that hbase modules are not in the maven repository
870 when you try to do it all in one step, especially on a fresh repository.
871 It seems that you need the install goal in both steps.
873 Extract the generated tarball -- you'll find it under
874 _hbase-assembly/target_ and check it out.
875 Look at the documentation, see if it runs, etc.
876 If good, copy the tarball beside the source tarball in the
877 build output directory.
879 ===== Deploy to the Maven Repository.
881 Next, deploy HBase to the Apache Maven repository. Add the
882 apache-release` profile when running the `mvn deploy` command.
883 This profile comes from the Apache parent pom referenced by our pom files.
884 It does signing of your artifacts published to Maven, as long as the
885 _settings.xml_ is configured correctly, as described in <<maven.settings.xml>>.
886 This step depends on the local repository having been populate
887 by the just-previous bin tarball build.
892 $ mvn deploy -DskipTests -Papache-release -Prelease
895 This command copies all artifacts up to a temporary staging Apache mvn repository in an 'open' state.
896 More work needs to be done on these maven artifacts to make them generally available.
898 We do not release HBase tarball to the Apache Maven repository. To avoid deploying the tarball, do not
899 include the `assembly:single` goal in your `mvn deploy` command. Check the deployed artifacts as described in the next section.
904 If you ran the old _dev-support/make_rc.sh_ script, this is as far as it takes you.
905 To finish the release, take up the script from here on out.
908 ===== Make the Release Candidate available.
910 The artifacts are in the maven repository in the staging area in the 'open' state.
911 While in this 'open' state you can check out what you've published to make sure all is good.
912 To do this, log in to Apache's Nexus at link:https://repository.apache.org[repository.apache.org] using your Apache ID.
913 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.
914 Use the tree view to expand the list of repository contents and inspect if the artifacts you expect are present. Check the POMs.
915 As long as the staging repo is open you can re-upload if something is missing or built incorrectly.
917 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.
918 Sometimes the upload fails in the middle. This is another reason you might have to 'Drop' the upload from the staging repository.
920 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.
921 (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.)
923 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.
928 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.
929 Check it out and run its simple test to make sure maven artifacts are properly deployed to the maven repository.
930 Be sure to edit the pom to point to the proper staging repository.
931 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.
934 See link:https://www.apache.org/dev/publishing-maven-artifacts.html[Publishing Maven Artifacts] for some pointers on this maven staging process.
936 If the HBase version ends in `-SNAPSHOT`, the artifacts go elsewhere.
937 They are put into the Apache snapshots repository directly and are immediately available.
938 Making a SNAPSHOT release, this is what you want to happen.
940 At this stage, you have two tarballs in your 'build output directory' and a set of artifacts
941 in a staging area of the maven repository, in the 'closed' state.
942 Next sign, fingerprint and then 'stage' your release candiate build output directory via svnpubsub by committing
943 your directory to link:https://dist.apache.org/repos/dist/dev/hbase/[The dev distribution directory]
944 (See comments on link:https://issues.apache.org/jira/browse/HBASE-10554[HBASE-10554 Please delete old releases from mirroring system]
945 but in essence it is an svn checkout of link:https://dist.apache.org/repos/dist/dev/hbase[dev/hbase] -- releases are at
946 link:https://dist.apache.org/repos/dist/release/hbase[release/hbase]). In the _version directory_ run the following commands:
950 $ for i in *.tar.gz; do echo $i; gpg --print-md MD5 $i > $i.md5 ; done
951 $ for i in *.tar.gz; do echo $i; gpg --print-md SHA512 $i > $i.sha ; done
952 $ for i in *.tar.gz; do echo $i; gpg --armor --output $i.asc --detach-sig $i ; done
954 # Presuming our 'build output directory' is named 0.96.0RC0, copy it to the svn checkout of the dist dev dir
955 # in this case named hbase.dist.dev.svn
956 $ cd /Users/stack/checkouts/hbase.dist.dev.svn
959 Working Copy Root Path: /Users/stack/checkouts/hbase.dist.dev.svn
960 URL: https://dist.apache.org/repos/dist/dev/hbase
961 Repository Root: https://dist.apache.org/repos/dist
962 Repository UUID: 0d268c88-bc11-4956-87df-91683dc98e59
966 Last Changed Author: ndimiduk
967 Last Changed Rev: 15045
968 Last Changed Date: 2016-08-28 11:13:36 -0700 (Sun, 28 Aug 2016)
969 $ mv 0.96.0RC0 /Users/stack/checkouts/hbase.dist.dev.svn
974 Ensure it actually gets published by checking link:https://dist.apache.org/repos/dist/dev/hbase/[https://dist.apache.org/repos/dist/dev/hbase/].
976 Announce the release candidate on the mailing list and call a vote.
979 === Publishing a SNAPSHOT to maven
981 Make sure your _settings.xml_ is set up properly (see <<maven.settings.xml>>).
982 Make sure the hbase version includes `-SNAPSHOT` as a suffix.
983 Following is an example of publishing SNAPSHOTS of a release that had an hbase version of 0.96.0 in its poms.
988 $ mvn clean install -DskipTests javadoc:aggregate site assembly:single -Prelease
989 $ mvn -DskipTests deploy -Papache-release
992 The _make_rc.sh_ script mentioned above (see <<maven.release,maven.release>>) can help you publish `SNAPSHOTS`.
993 Make sure your `hbase.version` has a `-SNAPSHOT` suffix before running the script.
994 It will put a snapshot up into the apache snapshot repository for you.
997 == Voting on Release Candidates
999 Everyone is encouraged to try and vote on HBase release candidates.
1000 Only the votes of PMC members are binding.
1001 PMC members, please read this WIP doc on policy voting for a release candidate, link:https://github.com/rectang/asfrelease/blob/master/release.md[Release Policy].
1005 Before casting +1 binding votes, individuals are required to
1006 download the signed source code package onto their own hardware, compile it as
1007 provided, and test the resulting executable on their own platform, along with also
1008 validating cryptographic signatures and verifying that the package meets the
1009 requirements of the ASF policy on releases.
1012 Regards the latter, run `mvn apache-rat:check` to verify all files are suitably licensed.
1013 See link:http://search-hadoop.com/m/DHED4dhFaU[HBase, mail # dev - On recent discussion clarifying ASF release policy]
1014 for how we arrived at this process.
1016 To help with the release verification, please follow the guideline below and vote based on the your verification.
1018 === Baseline Verifications for Voting Release Candidates
1020 Although contributors have their own checklist for verifications, the following items are usually used for voting on release candidates.
1023 * RELEASENOTES.md (release notes) if any
1024 * Generated API compatibility report
1025 ** For what should be compatible please refer the link:https://hbase.apache.org/book.html#hbase.versioning[versioning guideline], especially for items with marked as high severity
1026 * Use `hbase-vote.sh` to perform sanity checks for checksum, signatures, files are licensed, built from source, and unit tests.
1027 ** `hbase-vote.sh` shell script is available under `dev-support` directory of HBase source. Following are the usage details.
1031 ./dev-support/hbase-vote.sh -h
1032 hbase-vote. A script for standard vote which verifies the following items
1033 1. Checksum of sources and binaries
1034 2. Signature of sources and binaries
1036 4. Built from source
1039 Usage: hbase-vote.sh -s | --source <url> [-k | --key <signature>] [-f | --keys-file-url <url>] [-o | --output-dir </path/to/use>]
1040 hbase-vote.sh -h | --help
1042 -h | --help Show this screen.
1043 -s | --source '<url>' A URL pointing to the release candidate sources and binaries
1044 e.g. https://dist.apache.org/repos/dist/dev/hbase/hbase-<version>RC0/
1045 -k | --key '<signature>' A signature of the public key, e.g. 9AD2AE49
1046 -f | --keys-file-url '<url>' the URL of the key file, default is
1047 http://www.apache.org/dist/hbase/KEYS
1048 -o | --output-dir '</path>' directory which has the stdout and stderr of each verification target
1050 * If you see any unit test failures, please call out the solo test result and whether it's part of flaky (nightly) tests dashboard, e.g. link:https://builds.apache.org/view/H-L/view/HBase/job/HBase-Find-Flaky-Tests/job/master/lastSuccessfulBuild/artifact/dashboard.html[dashboard of master branch] (please change the test branch accordingly).
1052 === Additional Verifications for Voting Release Candidates
1054 Other than the common verifications, contributors may call out additional concerns, e.g. for a specific feature by running end to end tests on a distributed environment. This is optional and always encouraged.
1056 * Start a distributed HBase cluster and call out the test result of specific workload on cluster. e.g.
1057 ** Run basic table operations, e.g. `create/put/get/scan/flush/list/disable/drop`
1058 ** Run built-in tests, e.g. `LoadTestTool` (LTT) and `IntegrationTestBigLinkedList` (ITBLL)
1060 [[hbase.release.announcement]]
1061 == Announcing Releases
1063 Once an RC has passed successfully and the needed artifacts have been staged for disribution, you'll need to let everyone know about our shiny new release. It's not a requirement, but to make things easier for release managers we have a template you can start with. Be sure you replace \_version_ and other markers with the relevant version numbers. You should manually verify all links before sending.
1067 The HBase team is happy to announce the immediate availability of HBase _version_.
1069 Apache HBaseâ„¢ is an open-source, distributed, versioned, non-relational database.
1070 Apache HBase gives you low latency random access to billions of rows with
1071 millions of columns atop non-specialized hardware. To learn more about HBase,
1072 see https://hbase.apache.org/.
1074 HBase _version_ is the _nth_ minor release in the HBase _major_.x line, which aims to
1075 improve the stability and reliability of HBase. This release includes roughly
1076 XXX resolved issues not covered by previous _major_.x releases.
1078 Notable new features include:
1079 - List text descriptions of features that fit on one line
1080 - Including if JDK or Hadoop support versions changes
1081 - If the "stable" pointer changes, call that out
1082 - For those with obvious JIRA IDs, include them (HBASE-YYYYY)
1084 The full list of issues can be found in the included CHANGES.md and RELEASENOTES.md,
1085 or via our issue tracker:
1087 https://s.apache.org/hbase-_version_-jira
1089 To download please follow the links and instructions on our website:
1091 https://hbase.apache.org/downloads.html
1094 Question, comments, and problems are always welcome at: dev@hbase.apache.org.
1096 Thanks to all who contributed and made this release possible.
1102 You should sent this message to the following lists: dev@hbase.apache.org, user@hbase.apache.org, announce@apache.org. If you'd like a spot check before sending, feel free to ask via jira or the dev list.
1105 == Generating the HBase Reference Guide
1107 The manual is marked up using Asciidoc.
1108 We then use the link:http://asciidoctor.org/docs/asciidoctor-maven-plugin/[Asciidoctor maven plugin] to transform the markup to html.
1109 This plugin is run when you specify the +site+ goal as in when you run +mvn site+.
1110 See <<appendix_contributing_to_documentation,appendix contributing to documentation>> for more information on building the documentation.
1113 == Updating link:https://hbase.apache.org[hbase.apache.org]
1115 [[hbase.org.site.contributing]]
1116 === Contributing to hbase.apache.org
1118 See <<appendix_contributing_to_documentation,appendix contributing to documentation>> for more information on contributing to the documentation or website.
1120 [[hbase.org.site.publishing]]
1121 === Publishing link:https://hbase.apache.org[hbase.apache.org]
1123 See <<website_publish>> for instructions on publishing the website and documentation.
1128 Developers, at a minimum, should familiarize themselves with the unit test detail; unit tests in HBase have a character not usually seen in other projects.
1130 This information is about unit tests for HBase itself.
1131 For developing unit tests for your HBase applications, see <<unit.tests,unit.tests>>.
1133 [[hbase.moduletests]]
1134 === Apache HBase Modules
1136 As of 0.96, Apache HBase is split into multiple modules.
1137 This creates "interesting" rules for how and where tests are written.
1138 If you are writing code for `hbase-server`, see <<hbase.unittests,hbase.unittests>> for how to write your tests.
1139 These tests can spin up a minicluster and will need to be categorized.
1140 For any other module, for example `hbase-common`, the tests must be strict unit tests and just test the class under test - no use of the HBaseTestingUtility or minicluster is allowed (or even possible given the dependency tree).
1142 [[hbase.moduletest.shell]]
1143 ==== Testing the HBase Shell
1145 The HBase shell and its tests are predominantly written in jruby.
1147 In order to make these tests run as a part of the standard build, there are a few JUnit test classes that take care of loading the jruby implemented tests and running them.
1148 The tests were split into separate classes to accomodate class level timeouts (see <<hbase.unittests>> for specifics).
1149 You can run all of these tests from the top level with:
1153 mvn clean test -Dtest=Test*Shell
1156 If you have previously done a `mvn install`, then you can instruct maven to run only the tests in the hbase-shell module with:
1160 mvn clean test -pl hbase-shell
1163 Alternatively, you may limit the shell tests that run using the system variable `shell.test`.
1164 This value should specify the ruby literal equivalent of a particular test case by name.
1165 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:
1169 mvn clean test -pl hbase-shell -Dshell.test=/AdminAlterTableTest/
1172 You may also use a link:http://docs.ruby-doc.com/docs/ProgrammingRuby/html/language.html#UJ[Ruby Regular Expression
1173 literal] (in the `/pattern/` style) to select a set of test cases.
1174 You can run all of the HBase admin related tests, including both the normal administration and the security administration, with the command:
1179 mvn clean test -pl hbase-shell -Dshell.test=/.*Admin.*Test/
1182 In the event of a test failure, you can see details by examining the XML version of the surefire report results
1186 vim hbase-shell/target/surefire-reports/TEST-org.apache.hadoop.hbase.client.TestShell.xml
1189 [[hbase.moduletest.run]]
1190 ==== Running Tests in other Modules
1192 If the module you are developing in has no other dependencies on other HBase modules, then you can cd into that module and just run:
1199 which will just run the tests IN THAT MODULE.
1200 If there are other dependencies on other modules, then you will have run the command from the ROOT HBASE DIRECTORY.
1201 This will run the tests in the other modules, unless you specify to skip the tests in that module.
1202 For instance, to skip the tests in the hbase-server module, you would run:
1206 mvn clean test -PskipServerTests
1209 from the top level directory to run all the tests in modules other than hbase-server.
1210 Note that you can specify to skip tests in multiple modules as well as just for a single module.
1211 For example, to skip the tests in `hbase-server` and `hbase-common`, you would run:
1215 mvn clean test -PskipServerTests -PskipCommonTests
1218 Also, keep in mind that if you are running tests in the `hbase-server` module you will need to apply the maven profiles discussed in <<hbase.unittests.cmds,hbase.unittests.cmds>> to get the tests to run properly.
1223 Apache HBase unit tests must carry a Category annotation and
1224 as of `hbase-2.0.0`, must be stamped with the HBase `ClassRule`.
1225 Here is an example of what a Test Class looks like with a
1226 Category and ClassRule included:
1231 @Category(SmallTests.class)
1232 public class TestHRegionInfo {
1234 public static final HBaseClassTestRule CLASS_RULE =
1235 HBaseClassTestRule.forClass(TestHRegionInfo.class);
1238 public void testCreateHRegionInfoName() throws Exception {
1243 Here the Test Class is `TestHRegionInfo`. The `CLASS_RULE` has
1244 the same form in every test class only the `.class` you pass
1245 is that of the local test; i.e. in the TestTimeout Test Class, you'd
1246 pass `TestTimeout.class` to the `CLASS_RULE` instead of the
1247 `TestHRegionInfo.class` we have above. The `CLASS_RULE`
1248 is where we'll enforce timeouts (currently set at a hard-limit of
1249 thirteen! minutes for all tests -- 780 seconds) and other cross-unit test facility.
1250 The test is in the `SmallTest` Category.
1252 Categories can be arbitrary and provided as a list but each test MUST
1253 carry one from the following list of sizings: `small`, `medium`, `large`, and
1254 `integration`. The test sizing is designated using the JUnit
1255 link:https://github.com/junit-team/junit4/wiki/Categories[categories]: `SmallTests`, `MediumTests`, `LargeTests`, `IntegrationTests`.
1256 JUnit Categories are denoted using java annotations (a special unit test looks
1257 for the presence of the @Category annotation in all unit tess and will fail if it
1258 finds a test suite missing a sizing marking).
1260 The first three categories, `small`, `medium`, and `large`, are for test cases which run when you
1262 In other words, these three categorizations are for HBase unit tests.
1263 The `integration` category is not for unit tests, but for integration tests.
1264 These are normally run when you invoke `$ mvn verify`.
1265 Integration tests are described in <<integration.tests,integration.tests>>.
1267 Keep reading to figure which annotation of the set `small`, `medium`, and `large`
1268 to put on your new HBase test case.
1271 Small Tests (((SmallTests)))::
1272 _Small_ test cases are executed in a shared JVM and each test suite/test class should
1273 run in 15 seconds or less; i.e. a link:https://en.wikipedia.org/wiki/JUnit[junit test fixture], a java object made
1274 up of test methods, should finish in under 15 seconds, no matter how many or how few test methods
1275 it has. These test cases should not use a minicluster as a minicluster starts many services,
1276 most unrelated to what is being tested. Multiple start/stops may leak resources or just overwhelm
1277 the single JVM context.
1279 Medium Tests (((MediumTests)))::
1280 _Medium_ test cases are executed in separate JVM and individual test suites or test classes or in
1281 junit parlance, link:https://en.wikipedia.org/wiki/JUnit[test fixture], should run in 50 seconds
1282 or less. These test cases can use a mini cluster. Since we start up a JVM per test fixture (and
1283 often a cluster too), be sure to make the startup pay by writing test fixtures that do a lot of
1284 testing running tens of seconds perhaps combining test rather than spin up a jvm (and cluster)
1285 per test method; this practice will help w/ overall test times.
1287 Large Tests (((LargeTests)))::
1288 _Large_ test cases are everything else. They are typically large-scale tests, regression tests
1289 for specific bugs, timeout tests, or performance tests. No large test suite can take longer than
1290 thirteen minutes. It will be killed as timed out. Cast your test as an Integration Test if it needs
1293 Integration Tests (((IntegrationTests)))::
1294 _Integration_ tests are system level tests.
1295 See <<integration.tests,integration.tests>> for more info.
1296 If you invoke `$ mvn test` on integration tests, there is no timeout for the test.
1298 [[hbase.unittests.cmds]]
1301 [[hbase.unittests.cmds.test]]
1302 ==== Default: small and medium category tests
1304 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.
1305 Medium tests are NOT executed if there is an error in a small test. Large tests are NOT executed.
1307 [[hbase.unittests.cmds.test.runalltests]]
1308 ==== Running all tests
1310 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.
1311 Medium and large tests are NOT executed if there is an error in a small test.
1313 [[hbase.unittests.cmds.test.localtests.mytest]]
1314 ==== Running a single test or all tests in a package
1316 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:
1319 mvn test -Dtest=MyTest1,MyTest2,MyTest3
1321 You can also pass a package, which will run all tests under the package:
1324 mvn test '-Dtest=org.apache.hadoop.hbase.client.*'
1327 When `-Dtest` is specified, the `localTests` profile will be used.
1328 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.
1329 You will see a new message at the end of the -report: `"[INFO] Tests are skipped"`.
1331 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.
1333 [[hbase.unittests.cmds.test.profiles]]
1334 ==== Other test invocation permutations
1336 Running `mvn test -P runSmallTests` will execute "small" tests only, using a single JVM.
1338 Running `mvn test -P runMediumTests` will execute "medium" tests only, launching a new JVM for each test-class.
1340 Running `mvn test -P runLargeTests` will execute "large" tests only, launching a new JVM for each test-class.
1342 For convenience, you can run `mvn test -P runDevTests` to execute both small and medium tests, using a single JVM.
1344 [[hbase.unittests.test.faster]]
1345 ==== Running tests faster
1347 By default, `$ mvn test -P runAllTests` runs all small tests in 1 forked instance and the medium and large tests in 5 parallel forked instances. Up these counts to get the build to run faster (you may run into
1348 rare issues of test mutual interference). For example,
1349 allowing that you want to have 2 tests in parallel per core, and you need about 2GB of memory per test (at the extreme), if you have an 8 core, 24GB box, you can have 16 tests in parallel.
1350 but the memory available limits it to 12 (24/2), To run all tests with 12 tests in parallel, do this: +mvn test -P runAllTests -Dsurefire.secondPartForkCount=12+.
1351 If using a version earlier than 2.0, do: +mvn test -P runAllTests -Dsurefire.secondPartThreadCount=12 +.
1352 You can also increase the fork count for the first party by setting -Dsurefire.firstPartForkCount to a value > 1.
1353 The values passed as fork counts can be specified as a fraction of CPU as follows: for two forks per available CPU, set the value to 2.0C; for a fork for every two CPUs, set it to 0.5C.
1354 To increase the speed, you can as well use a ramdisk.
1355 You will need 2GB of memory to run all tests.
1356 You will also need to delete the files between two test run.
1357 The typical way to configure a ramdisk on Linux is:
1361 sudo mount -t tmpfs -o size=2048M tmpfs /ram2G
1364 You can then use it to run all HBase tests on 2.0 with the command:
1368 -P runAllTests -Dsurefire.secondPartForkCount=12
1369 -Dtest.build.data.basedirectory=/ram2G
1372 On earlier versions, use:
1376 -P runAllTests -Dsurefire.secondPartThreadCount=12
1377 -Dtest.build.data.basedirectory=/ram2G
1380 [[hbase.unittests.cmds.test.hbasetests]]
1381 ==== +hbasetests.sh+
1383 It's also possible to use the script +hbasetests.sh+.
1384 This script runs the medium and large tests in parallel with two maven instances, and provides a single report.
1385 This script does not use the hbase version of surefire so no parallelization is being done other than the two maven instances the script sets up.
1386 It must be executed from the directory which contains the _pom.xml_.
1388 For example running +./dev-support/hbasetests.sh+ will execute small and medium tests.
1389 Running +./dev-support/hbasetests.sh
1390 runAllTests+ will execute all tests.
1391 Running +./dev-support/hbasetests.sh replayFailed+ will rerun the failed tests a second time, in a separate jvm and without parallelisation.
1393 [[hbase.unittests.timeouts]]
1394 ==== Test Timeouts(((Test Timeouts)))
1395 The HBase unit test sizing Categorization timeouts are not strictly enforced.
1397 Any test that runs longer than ten minutes will be timedout/killed.
1399 As of hbase-2.0.0, we have purged all per-test-method timeouts: i.e.
1403 @Test(timeout=30000)
1404 public void testCreateHRegionInfoName() throws Exception {
1408 They are discouraged and don't make much sense given we are timing
1409 base of how long the whole Test Fixture/Class/Suite takes and
1410 that the variance in how long a test method takes varies wildly
1411 dependent upon context (loaded Apache Infrastructure versus
1412 developer machine with nothing else running on it).
1416 [[hbase.unittests.resource.checker]]
1417 ==== Test Resource Checker(((Test ResourceChecker)))
1419 A custom Maven SureFire plugin listener checks a number of resources before and after each HBase unit test runs and logs its findings at the end of the test output files which can be found in _target/surefire-reports_ per Maven module (Tests write test reports named for the test class into this directory.
1420 Check the _*-out.txt_ files). The resources counted are the number of threads, the number of file descriptors, etc.
1421 If the number has increased, it adds a _LEAK?_ comment in the logs.
1422 As you can have an HBase instance running in the background, some threads can be deleted/created without any specific action in the test.
1423 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...+.
1427 2012-09-26 09:22:15,315 INFO [pool-1-thread-1]
1428 hbase.ResourceChecker(157): after:
1429 regionserver.TestColumnSeeking#testReseeking Thread=65 (was 65),
1430 OpenFileDescriptor=107 (was 107), MaxFileDescriptor=10240 (was 10240),
1431 ConnectionCount=1 (was 1)
1434 [[hbase.tests.writing]]
1437 [[hbase.tests.rules]]
1440 * As much as possible, tests should be written as category small tests.
1441 * All tests must be written to support parallel execution on the same machine, hence they should not use shared resources as fixed ports or fixed file names.
1442 * Tests should not overlog.
1443 More than 100 lines/second makes the logs complex to read and use i/o that are hence not available for the other tests.
1444 * Tests can be written with `HBaseTestingUtility`.
1445 This class offers helper functions to create a temp directory and do the cleanup, or to start a cluster.
1447 [[hbase.tests.categories]]
1448 ==== Categories and execution time
1450 * All tests must be categorized, if not they could be skipped.
1451 * All tests should be written to be as fast as possible.
1452 * See <<hbase.unittests,hbase.unittests>> for test case categories and corresponding timeouts.
1453 This should ensure a good parallelization for people using it, and ease the analysis when the test fails.
1455 [[hbase.tests.sleeps]]
1456 ==== Sleeps in tests
1458 Whenever possible, tests should not use [method]+Thread.sleep+, but rather waiting for the real event they need.
1459 This is faster and clearer for the reader.
1460 Tests should not do a [method]+Thread.sleep+ without testing an ending condition.
1461 This allows understanding what the test is waiting for.
1462 Moreover, the test will work whatever the machine performance is.
1463 Sleep should be minimal to be as fast as possible.
1464 Waiting for a variable should be done in a 40ms sleep loop.
1465 Waiting for a socket operation should be done in a 200 ms sleep loop.
1467 [[hbase.tests.cluster]]
1468 ==== Tests using a cluster
1470 Tests using a HRegion do not have to start a cluster: A region can use the local file system.
1471 Start/stopping a cluster cost around 10 seconds.
1472 They should not be started per test method but per test class.
1473 Started cluster must be shutdown using [method]+HBaseTestingUtility#shutdownMiniCluster+, which cleans the directories.
1474 As most as possible, tests should use the default settings for the cluster.
1475 When they don't, they should document it.
1476 This will allow to share the cluster later.
1478 [[hbase.tests.example.code]]
1479 ==== Tests Skeleton Code
1481 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.
1485 * Describe what this testcase tests. Talk about resources initialized in @BeforeClass (before
1486 * any test is run) and before each test is run, etc.
1488 // Specify the category as explained in <<hbase.unittests,hbase.unittests>>.
1489 @Category(SmallTests.class)
1490 public class TestExample {
1491 // Replace the TestExample.class in the below with the name of your test fixture class.
1492 private static final Log LOG = LogFactory.getLog(TestExample.class);
1494 // Handy test rule that allows you subsequently get the name of the current method. See
1495 // down in 'testExampleFoo()' where we use it to log current test's name.
1496 @Rule public TestName testName = new TestName();
1498 // The below rule does two things. It decides the timeout based on the category
1499 // (small/medium/large) of the testcase. This @Rule requires that the full testcase runs
1500 // within this timeout irrespective of individual test methods' times. The second
1501 // feature is we'll dump in the log when the test is done a count of threads still
1503 @Rule public static TestRule timeout = CategoryBasedTimeout.builder().
1504 withTimeout(this.getClass()).withLookingForStuckThread(true).build();
1507 public void setUp() throws Exception {
1511 public void tearDown() throws Exception {
1515 public void testExampleFoo() {
1516 LOG.info("Running test " + testName.getMethodName());
1521 [[integration.tests]]
1522 === Integration Tests
1524 HBase integration/system tests are tests that are beyond HBase unit tests.
1525 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.
1526 Integration tests are what you would run when you need to more elaborate proofing of a release candidate beyond what unit tests can do.
1527 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.
1529 Integration tests currently live under the _src/test_ directory in the hbase-it submodule and will match the regex: _**/IntegrationTest*.java_.
1530 All integration tests are also annotated with `@Category(IntegrationTests.class)`.
1532 Integration tests can be run in two modes: using a mini cluster, or against an actual distributed cluster.
1533 Maven failsafe is used to run the tests using the mini cluster.
1534 IntegrationTestsDriver class is used for executing the tests against a distributed cluster.
1535 Integration tests SHOULD NOT assume that they are running against a mini cluster, and SHOULD NOT use private API's to access cluster state.
1536 To interact with the distributed or mini cluster uniformly, `IntegrationTestingUtility`, and `HBaseCluster` classes, and public client API's can be used.
1538 On a distributed cluster, integration tests that use ChaosMonkey or otherwise manipulate services thru cluster manager (e.g.
1539 restart regionservers) use SSH to do it.
1540 To run these, test process should be able to run commands on remote end, so ssh should be configured accordingly (for example, if HBase runs under hbase user in your cluster, you can set up passwordless ssh for that user and run the test also under it). To facilitate that, `hbase.it.clustermanager.ssh.user`, `hbase.it.clustermanager.ssh.opts` and `hbase.it.clustermanager.ssh.cmd` configuration settings can be used.
1541 "User" is the remote user that cluster manager should use to perform ssh commands.
1542 "Opts" contains additional options that are passed to SSH (for example, "-i /tmp/my-key"). Finally, if you have some custom environment setup, "cmd" is the override format for the entire tunnel (ssh) command.
1543 The default string is {`/usr/bin/ssh %1$s %2$s%3$s%4$s "%5$s"`} and is a good starting point.
1544 This is a standard Java format string with 5 arguments that is used to execute the remote command.
1545 The argument 1 (%1$s) is SSH options set the via opts setting or via environment variable, 2 is SSH user name, 3 is "@" if username is set or "" otherwise, 4 is the target host name, and 5 is the logical command to execute (that may include single quotes, so don't use them). For example, if you run the tests under non-hbase user and want to ssh as that user and change to hbase on remote machine, you can use:
1548 /usr/bin/ssh %1$s %2$s%3$s%4$s "su hbase - -c \"%5$s\""
1550 That way, to kill RS (for example) integration tests may run:
1553 {/usr/bin/ssh some-hostname "su hbase - -c \"ps aux | ... | kill ...\""}
1555 The command is logged in the test logs, so you can verify it is correct for your environment.
1557 To disable the running of Integration Tests, pass the following profile on the command line `-PskipIntegrationTests`.
1561 $ mvn clean install test -Dtest=TestZooKeeper -PskipIntegrationTests
1564 [[maven.build.commands.integration.tests.mini]]
1565 ==== Running integration tests against mini cluster
1567 HBase 0.92 added a `verify` maven target.
1568 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
1569 plugin], running all the above mentioned HBase unit tests as well as tests that are in the HBase integration test group.
1570 After you have completed +mvn install -DskipTests+ You can run just the integration tests by invoking:
1579 If you just want to run the integration tests in top-level, you need to run two commands.
1582 mvn failsafe:integration-test
1585 This actually runs ALL the integration tests.
1587 NOTE: This command will always output `BUILD SUCCESS` even if there are test failures.
1589 At this point, you could grep the output by hand looking for failed tests.
1590 However, maven will do this for us; just use:
1595 The above command basically looks at all the test results (so don't remove the 'target' directory) for test failures and reports the results.
1597 [[maven.build.commands.integration.tests2]]
1598 ===== Running a subset of Integration tests
1600 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`.
1601 To just run `IntegrationTestClassXYZ.java`, use:
1603 mvn failsafe:integration-test -Dit.test=IntegrationTestClassXYZ -DfailIfNoTests=false
1605 The next thing you might want to do is run groups of integration tests, say all integration tests that are named IntegrationTestClassX*.java:
1607 mvn failsafe:integration-test -Dit.test=*ClassX* -DfailIfNoTests=false
1610 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:
1612 mvn failsafe:integration-test -Dit.test=*ClassX*,*ClassY -DfailIfNoTests=false
1615 [[maven.build.commands.integration.tests.distributed]]
1616 ==== Running integration tests against distributed cluster
1618 If you have an already-setup HBase cluster, you can launch the integration tests by invoking the class `IntegrationTestsDriver`.
1619 You may have to run test-compile first.
1620 The configuration will be picked by the bin/hbase script.
1625 Then launch the tests with:
1629 bin/hbase [--config config_dir] org.apache.hadoop.hbase.IntegrationTestsDriver
1632 Pass `-h` to get usage on this sweet tool.
1633 Running the IntegrationTestsDriver without any argument will launch tests found under `hbase-it/src/test`, having `@Category(IntegrationTests.class)` annotation, and a name starting with `IntegrationTests`.
1634 See the usage, by passing -h, to see how to filter test classes.
1635 You can pass a regex which is checked against the full class name; so, part of class name can be used.
1636 IntegrationTestsDriver uses Junit to run the tests.
1637 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]).
1639 The tests interact with the distributed cluster by using the methods in the `DistributedHBaseCluster` (implementing `HBaseCluster`) class, which in turn uses a pluggable `ClusterManager`.
1640 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.
1641 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.
1642 Currently tarball deployments, deployments which uses _hbase-daemons.sh_, and link:https://incubator.apache.org/ambari/[Apache Ambari] deployments are supported.
1643 _/etc/init.d/_ scripts are not supported for now, but it can be easily added.
1644 For other deployment options, a ClusterManager can be implemented and plugged in.
1646 [[maven.build.commands.integration.tests.destructive]]
1647 ==== Destructive integration / system tests (ChaosMonkey)
1649 HBase 0.96 introduced a tool named `ChaosMonkey`, modeled after
1650 link:https://netflix.github.io/chaosmonkey/[same-named tool by Netflix's Chaos Monkey tool].
1651 ChaosMonkey simulates real-world
1652 faults in a running cluster by killing or disconnecting random servers, or injecting
1653 other failures into the environment. You can use ChaosMonkey as a stand-alone tool
1654 to run a policy while other tests are running. In some environments, ChaosMonkey is
1655 always running, in order to constantly check that high availability and fault tolerance
1656 are working as expected.
1658 ChaosMonkey defines *Actions* and *Policies*.
1660 Actions:: Actions are predefined sequences of events, such as the following:
1662 * Restart active master (sleep 5 sec)
1663 * Restart random regionserver (sleep 5 sec)
1664 * Restart random regionserver (sleep 60 sec)
1665 * Restart META regionserver (sleep 5 sec)
1666 * Restart ROOT regionserver (sleep 5 sec)
1667 * Batch restart of 50% of regionservers (sleep 5 sec)
1668 * Rolling restart of 100% of regionservers (sleep 5 sec)
1670 Policies:: A policy is a strategy for executing one or more actions. The default policy
1671 executes a random action every minute based on predefined action weights.
1672 A given policy will be executed until ChaosMonkey is interrupted.
1674 Most ChaosMonkey actions are configured to have reasonable defaults, so you can run
1675 ChaosMonkey against an existing cluster without any additional configuration. The
1676 following example runs ChaosMonkey with the default configuration:
1680 $ bin/hbase org.apache.hadoop.hbase.util.ChaosMonkey
1682 12/11/19 23:21:57 INFO util.ChaosMonkey: Using ChaosMonkey Policy: class org.apache.hadoop.hbase.util.ChaosMonkey$PeriodicRandomActionPolicy, period:60000
1683 12/11/19 23:21:57 INFO util.ChaosMonkey: Sleeping for 26953 to add jitter
1684 12/11/19 23:22:24 INFO util.ChaosMonkey: Performing action: Restart active master
1685 12/11/19 23:22:24 INFO util.ChaosMonkey: Killing master:master.example.com,60000,1353367210440
1686 12/11/19 23:22:24 INFO hbase.HBaseCluster: Aborting Master: master.example.com,60000,1353367210440
1687 12/11/19 23:22:24 INFO hbase.ClusterManager: Executing remote command: ps aux | grep master | grep -v grep | tr -s ' ' | cut -d ' ' -f2 | xargs kill -s SIGKILL , hostname:master.example.com
1688 12/11/19 23:22:25 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:
1689 12/11/19 23:22:25 INFO hbase.HBaseCluster: Waiting service:master to stop: master.example.com,60000,1353367210440
1690 12/11/19 23:22:25 INFO hbase.ClusterManager: Executing remote command: ps aux | grep master | grep -v grep | tr -s ' ' | cut -d ' ' -f2 , hostname:master.example.com
1691 12/11/19 23:22:25 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:
1692 12/11/19 23:22:25 INFO util.ChaosMonkey: Killed master server:master.example.com,60000,1353367210440
1693 12/11/19 23:22:25 INFO util.ChaosMonkey: Sleeping for:5000
1694 12/11/19 23:22:30 INFO util.ChaosMonkey: Starting master:master.example.com
1695 12/11/19 23:22:30 INFO hbase.HBaseCluster: Starting Master on: master.example.com
1696 12/11/19 23:22:30 INFO hbase.ClusterManager: Executing remote command: /homes/enis/code/hbase-0.94/bin/../bin/hbase-daemon.sh --config /homes/enis/code/hbase-0.94/bin/../conf start master , hostname:master.example.com
1697 12/11/19 23:22:31 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:starting master, logging to /homes/enis/code/hbase-0.94/bin/../logs/hbase-enis-master-master.example.com.out
1699 12/11/19 23:22:33 INFO util.ChaosMonkey: Started master: master.example.com,60000,1353367210440
1700 12/11/19 23:22:33 INFO util.ChaosMonkey: Sleeping for:51321
1701 12/11/19 23:23:24 INFO util.ChaosMonkey: Performing action: Restart random region server
1702 12/11/19 23:23:24 INFO util.ChaosMonkey: Killing region server:rs3.example.com,60020,1353367027826
1703 12/11/19 23:23:24 INFO hbase.HBaseCluster: Aborting RS: rs3.example.com,60020,1353367027826
1704 12/11/19 23:23:24 INFO hbase.ClusterManager: Executing remote command: ps aux | grep regionserver | grep -v grep | tr -s ' ' | cut -d ' ' -f2 | xargs kill -s SIGKILL , hostname:rs3.example.com
1705 12/11/19 23:23:25 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:
1706 12/11/19 23:23:25 INFO hbase.HBaseCluster: Waiting service:regionserver to stop: rs3.example.com,60020,1353367027826
1707 12/11/19 23:23:25 INFO hbase.ClusterManager: Executing remote command: ps aux | grep regionserver | grep -v grep | tr -s ' ' | cut -d ' ' -f2 , hostname:rs3.example.com
1708 12/11/19 23:23:25 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:
1709 12/11/19 23:23:25 INFO util.ChaosMonkey: Killed region server:rs3.example.com,60020,1353367027826. Reported num of rs:6
1710 12/11/19 23:23:25 INFO util.ChaosMonkey: Sleeping for:60000
1711 12/11/19 23:24:25 INFO util.ChaosMonkey: Starting region server:rs3.example.com
1712 12/11/19 23:24:25 INFO hbase.HBaseCluster: Starting RS on: rs3.example.com
1713 12/11/19 23:24:25 INFO hbase.ClusterManager: Executing remote command: /homes/enis/code/hbase-0.94/bin/../bin/hbase-daemon.sh --config /homes/enis/code/hbase-0.94/bin/../conf start regionserver , hostname:rs3.example.com
1714 12/11/19 23:24:26 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:starting regionserver, logging to /homes/enis/code/hbase-0.94/bin/../logs/hbase-enis-regionserver-rs3.example.com.out
1716 12/11/19 23:24:27 INFO util.ChaosMonkey: Started region server:rs3.example.com,60020,1353367027826. Reported num of rs:6
1719 The output indicates that ChaosMonkey started the default `PeriodicRandomActionPolicy`
1720 policy, which is configured with all the available actions. It chose to run `RestartActiveMaster` and `RestartRandomRs` actions.
1722 ==== Available Policies
1723 HBase ships with several ChaosMonkey policies, available in the
1724 `hbase/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/policies/` directory.
1726 [[chaos.monkey.properties]]
1727 ==== Configuring Individual ChaosMonkey Actions
1729 ChaosMonkey integration tests can be configured per test run.
1730 Create a Java properties file in the HBase CLASSPATH and pass it to ChaosMonkey using
1731 the `-monkeyProps` configuration flag. Configurable properties, along with their default
1732 values if applicable, are listed in the `org.apache.hadoop.hbase.chaos.factories.MonkeyConstants`
1733 class. For properties that have defaults, you can override them by including them
1734 in your properties file.
1736 The following example uses a properties file called <<monkey.properties,monkey.properties>>.
1740 $ bin/hbase org.apache.hadoop.hbase.IntegrationTestIngest -m slowDeterministic -monkeyProps monkey.properties
1743 The above command will start the integration tests and chaos monkey. It will look for the
1744 properties file _monkey.properties_ on the HBase CLASSPATH; e.g. inside the HBASE _conf_ dir.
1746 Here is an example chaos monkey file:
1748 [[monkey.properties]]
1749 .Example ChaosMonkey Properties File
1752 sdm.action1.period=120000
1753 sdm.action2.period=40000
1754 move.regions.sleep.time=80000
1755 move.regions.max.time=1000000
1756 move.regions.sleep.time=80000
1757 batch.restart.rs.ratio=0.4f
1760 Periods/time are expressed in milliseconds.
1762 HBase 1.0.2 and newer adds the ability to restart HBase's underlying ZooKeeper quorum or
1763 HDFS nodes. To use these actions, you need to configure some new properties, which
1764 have no reasonable defaults because they are deployment-specific, in your ChaosMonkey
1765 properties file, which may be `hbase-site.xml` or a different properties file.
1770 <name>hbase.it.clustermanager.hadoop.home</name>
1771 <value>$HADOOP_HOME</value>
1774 <name>hbase.it.clustermanager.zookeeper.home</name>
1775 <value>$ZOOKEEPER_HOME</value>
1778 <name>hbase.it.clustermanager.hbase.user</name>
1779 <value>hbase</value>
1782 <name>hbase.it.clustermanager.hadoop.hdfs.user</name>
1786 <name>hbase.it.clustermanager.zookeeper.user</name>
1787 <value>zookeeper</value>
1792 == Developer Guidelines
1796 We use Git for source code management and latest development happens on `master` branch. There are
1797 branches for past major/minor/maintenance releases and important features and bug fixes are often
1798 back-ported to them.
1800 === Policy for Fix Version in JIRA
1802 To determine if a given fix is in a given release purely from the release numbers following rules
1805 Fix version of X.Y.Z => fixed in all releases X.Y.Z' (where Z' = Z). +
1806 Fix version of X.Y.0 => fixed in all releases X.Y'.* (where Y' = Y). +
1807 Fix version of X.0.0 => fixed in all releases X'.\*.* (where X' = X). +
1809 By this policy, fix version of 1.3.0 implies 1.4.0, but 1.3.2 does not imply 1.4.0 as we could not
1810 tell purely from the numbers which release came first.
1816 ==== Interface Classifications
1818 Interfaces are classified both by audience and by stability level.
1819 These labels appear at the head of a class.
1820 The conventions followed by HBase are inherited by its parent project, Hadoop.
1822 The following interface classifications are commonly used:
1825 `@InterfaceAudience.Public`::
1826 APIs for users and HBase applications.
1827 These APIs will be deprecated through major versions of HBase.
1829 `@InterfaceAudience.Private`::
1830 APIs for HBase internals developers.
1831 No guarantees on compatibility or availability in future versions.
1832 Private interfaces do not need an `@InterfaceStability` classification.
1834 `@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)`::
1835 APIs for HBase coprocessor writers.
1837 No `@InterfaceAudience` Classification::
1838 Packages without an `@InterfaceAudience` label are considered private.
1839 Mark your new packages if publicly accessible.
1841 .Excluding Non-Public Interfaces from API Documentation
1844 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.
1847 .@InterfaceStability
1848 `@InterfaceStability` is important for packages marked `@InterfaceAudience.Public`.
1850 `@InterfaceStability.Stable`::
1851 Public packages marked as stable cannot be changed without a deprecation path or a very good reason.
1853 `@InterfaceStability.Unstable`::
1854 Public packages marked as unstable can be changed without a deprecation path.
1856 `@InterfaceStability.Evolving`::
1857 Public packages marked as evolving may be changed, but it is discouraged.
1859 No `@InterfaceStability` Label::
1860 Public classes with no `@InterfaceStability` label are discouraged, and should be considered implicitly unstable.
1862 If you are unclear about how to mark packages, ask on the development list.
1864 [[common.patch.feedback]]
1865 ==== Code Formatting Conventions
1867 Please adhere to the following guidelines so that your patches can be reviewed more quickly.
1868 These guidelines have been developed based upon common feedback on patches from new contributors.
1870 See the link:http://www.oracle.com/technetwork/java/index-135089.html[Code
1871 Conventions for the Java Programming Language] for more information on coding conventions in Java.
1872 See <<eclipse.code.formatting,eclipse.code.formatting>> to setup Eclipse to check for some of
1873 these guidelines automatically.
1875 [[common.patch.feedback.space.invaders]]
1876 ===== Space Invaders
1878 Do not use extra spaces around brackets.
1879 Use the second style, rather than the first.
1884 if ( foo.equals( bar ) ) { // don't do this
1890 if (foo.equals(bar)) {
1896 foo = barArray[ i ]; // don't do this
1905 [[common.patch.feedback.autogen]]
1906 ===== Auto Generated Code
1908 Auto-generated code in Eclipse often uses bad variable names such as `arg0`.
1909 Use more informative variable names.
1910 Use code like the second example here.
1915 public void readFields(DataInput arg0) throws IOException { // don't do this
1916 foo = arg0.readUTF(); // don't do this
1922 public void readFields(DataInput di) throws IOException {
1926 [[common.patch.feedback.longlines]]
1929 Keep lines less than 100 characters.
1930 You can configure your IDE to do this automatically.
1935 Bar bar = foo.veryLongMethodWithManyArguments(argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8, argument9); // don't do this
1941 Bar bar = foo.veryLongMethodWithManyArguments(
1942 argument1, argument2, argument3,argument4, argument5, argument6, argument7, argument8, argument9);
1945 [[common.patch.feedback.trailingspaces]]
1946 ===== Trailing Spaces
1948 Be sure there is a line break after the end of your code, and avoid lines with nothing but whitespace.
1949 This makes diffs more meaningful.
1950 You can configure your IDE to help with this.
1955 Bar bar = foo.getBar(); <--- imagine there is an extra space(s) after the semicolon.
1958 [[common.patch.feedback.javadoc]]
1959 ===== API Documentation (Javadoc)
1961 Don't forget Javadoc!
1963 Javadoc warnings are checked during precommit.
1964 If the precommit tool gives you a '-1', please fix the javadoc issue.
1965 Your patch won't be committed if it adds such warnings.
1967 Also, no `@author` tags - that's a rule.
1969 [[common.patch.feedback.findbugs]]
1972 `Findbugs` is used to detect common bugs pattern.
1973 It is checked during the precommit build.
1974 If errors are found, please fix them.
1975 You can run findbugs locally with `mvn
1976 findbugs:findbugs`, which will generate the `findbugs` files locally.
1977 Sometimes, you may have to write code smarter than `findbugs`.
1978 You can annotate your code to tell `findbugs` you know what you're doing, by annotating your class with the following annotation:
1982 @edu.umd.cs.findbugs.annotations.SuppressWarnings(
1983 value="HE_EQUALS_USE_HASHCODE",
1984 justification="I know what I'm doing")
1987 It is important to use the Apache-licensed version of the annotations. That generally means using
1988 annotations in the `edu.umd.cs.findbugs.annotations` package so that we can rely on the cleanroom
1989 reimplementation rather than annotations in the `javax.annotations` package.
1991 [[common.patch.feedback.javadoc.defaults]]
1992 ===== Javadoc - Useless Defaults
1994 Don't just leave javadoc tags the way IDE generates them, or fill redundant information in them.
2000 * @param table <---- don't leave them empty!
2001 * @param region An HRegion object. <---- don't fill redundant information!
2002 * @return Foo Object foo just created. <---- Not useful information
2003 * @throws SomeException <---- Not useful. Function declarations already tell that!
2004 * @throws BarException when something went wrong <---- really?
2006 public Foo createFoo(Bar bar);
2009 Either add something descriptive to the tags, or just remove them.
2010 The preference is to add something descriptive and useful.
2012 [[common.patch.feedback.onething]]
2013 ===== One Thing At A Time, Folks
2015 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.
2017 Likewise, don't add unrelated cleanup or refactorings outside the scope of your Jira.
2019 [[common.patch.feedback.tests]]
2020 ===== Ambiguous Unit Tests
2022 Make sure that you're clear about what you are testing in your unit tests and why.
2024 ==== Garbage-Collection Conserving Guidelines
2026 The following guidelines were borrowed from http://engineering.linkedin.com/performance/linkedin-feed-faster-less-jvm-garbage.
2027 Keep them in mind to keep preventable garbage collection to a minimum. Have a look
2028 at the blog post for some great examples of how to refactor your code according to
2031 - Be careful with Iterators
2032 - Estimate the size of a collection when initializing
2033 - Defer expression evaluation
2034 - Compile the regex patterns in advance
2035 - Cache it if you can
2036 - String Interns are useful but dangerous
2038 [[design.invariants]]
2041 We don't have many but what we have we list below.
2042 All are subject to challenge of course but until then, please hold to the rules of the road.
2044 [[design.invariants.zk.data]]
2045 ==== No permanent state in ZooKeeper
2047 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.
2049 * .Exceptions: There are currently a few exceptions that we need to fix around whether a table is enabled or disabled.
2050 * Replication data is currently stored only in ZooKeeper.
2051 Deleting ZooKeeper data related to replication may cause replication to be disabled.
2052 Do not delete the replication tree, _/hbase/replication/_.
2054 WARNING: Replication may be disrupted and data loss may occur if you delete the replication tree (_/hbase/replication/_) from ZooKeeper.
2055 Follow progress on this issue at link:https://issues.apache.org/jira/browse/HBASE-10295[HBASE-10295].
2061 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.
2062 In this case, HBase can be run directly from the source in local-mode.
2063 All you need to do is run:
2067 ${HBASE_HOME}/bin/start-hbase.sh
2070 This will spin up a full local-cluster, just as if you had packaged up HBase and installed it on your machine.
2072 Keep in mind that you will need to have installed HBase into your local maven repository for the in-situ cluster to work properly.
2073 That is, you will need to run:
2077 mvn clean install -DskipTests
2080 to ensure that maven can find the correct classpath and dependencies.
2081 Generally, the above command is just a good thing to try running first, if maven is acting oddly.
2086 After adding a new feature a developer might want to add metrics.
2087 HBase exposes metrics using the Hadoop Metrics 2 system, so adding a new metric involves exposing that metric to the hadoop system.
2088 Unfortunately the API of metrics2 changed from hadoop 1 to hadoop 2.
2089 In order to get around this a set of interfaces and implementations have to be loaded at runtime.
2090 To get an in-depth look at the reasoning and structure of these classes you can read the blog post located link:https://blogs.apache.org/hbase/entry/migration_to_the_new_metrics[here].
2091 To add a metric to an existing MBean follow the short guide below:
2093 ==== Add Metric name and Function to Hadoop Compat Interface.
2095 Inside of the source interface the corresponds to where the metrics are generated (eg MetricsMasterSource for things coming from HMaster) create new static strings for metric name and description.
2096 Then add a new method that will be called to add new reading.
2098 ==== Add the Implementation to Both Hadoop 1 and Hadoop 2 Compat modules.
2100 Inside of the implementation of the source (eg.
2101 MetricsMasterSourceImpl in the above example) create a new histogram, counter, gauge, or stat in the init method.
2102 Then in the method that was added to the interface wire up the parameter passed in to the histogram.
2104 Now add tests that make sure the data is correctly exported to the metrics 2 system.
2105 For this the MetricsAssertHelper is provided.
2107 [[git.best.practices]]
2108 === Git Best Practices
2111 Use `git pull --rebase` or `git fetch` followed by `git rebase`.
2112 Do not use `git push --force`.::
2113 If the push does not work, fix the problem or ask for help.
2115 Please contribute to this document if you think of other Git best practices.
2117 ==== `rebase_all_git_branches.sh`
2119 The _dev-support/rebase_all_git_branches.sh_ script is provided to help keep your Git repository clean.
2120 Use the `-h` parameter to get usage instructions.
2121 The script automatically refreshes your tracking branches, attempts an automatic rebase of each local branch against its remote branch, and gives you the option to delete any branch which represents a closed `HBASE-` JIRA.
2122 The script has one optional configuration option, the location of your Git directory.
2123 You can set a default by editing the script.
2124 Otherwise, you can pass the git directory manually by using the `-d` parameter, followed by an absolute or relative directory name, or even '.' for the current working directory.
2125 The script checks the directory for sub-directory called _.git/_, before proceeding.
2127 [[submitting.patches]]
2128 === Submitting Patches
2130 If you are new to submitting patches to open source or new to submitting patches to Apache, start by
2131 reading the link:https://commons.apache.org/patches.html[On Contributing Patches] page from
2132 link:https://commons.apache.org/[Apache Commons Project].
2133 It provides a nice overview that applies equally to the Apache HBase Project.
2135 [[submitting.patches.create]]
2138 Make sure you review <<common.patch.feedback,common.patch.feedback>> for code style. If your
2140 was generated incorrectly or your code does not adhere to the code formatting guidelines, you may
2141 be asked to redo some work.
2144 .Using submit-patch.py (recommended)
2148 $ dev-support/submit-patch.py -jid HBASE-xxxxx
2151 Use this script to create patches, upload to jira and optionally create/update reviews on
2152 Review Board. Patch name is automatically formatted as _(JIRA).(branch name).(patch number).patch_
2153 to follow Yetus' naming rules. Use `-h` flag to know detailed usage information. Most useful options
2156 * `-b BRANCH, --branch BRANCH` : Specify base branch for generating the diff. If not specified,
2157 tracking branch is used. If there is no tracking branch, error will be thrown.
2158 * `-jid JIRA_ID, --jira-id JIRA_ID` : If used, deduces next patch version from attachments in the
2159 jira and uploads the new patch. Script will ask for jira username/password for authentication.
2160 If not set, patch is named <branch>.patch.
2162 By default, it'll also create/update review board. To skip that action, use `-srb` option. It uses
2163 'Issue Links' in the jira to figure out if a review request already exists. If no review
2164 request is present, then creates a new one and populates all required fields using jira summary,
2165 patch description, etc. Also adds this review's link to the jira.
2167 Save authentication credentials (optional)::
2168 Since attaching patches on JIRA and creating/changing review request on ReviewBoard requires
2169 valid user authentication, the script will prompt you for username and password. To avoid the hassle every
2170 time, set up `~/.apache-creds` with login details and encrypt it by following the steps in footer
2171 of script's help message.
2173 Python dependencies:: To install required python dependencies, execute
2174 `pip install -r dev-support/python-requirements.txt` from the master branch.
2178 . Use `git rebase -i` first, to combine (squash) smaller commits into a single larger one.
2179 . Create patch using IDE or Git commands. `git format-patch` is preferred since it preserves patch
2180 author's name and commit message. Also, it handles binary files by default, whereas `git diff`
2181 ignores them unless you use the `--binary` option.
2182 . Patch name should be as follows to adhere to Yetus' naming convention: +
2183 `(JIRA).(branch name).(patch number).patch` +
2184 For eg. HBASE-11625.master.001.patch, HBASE-XXXXX.branch-1.2.0005.patch, etc.
2185 . Attach the patch to the JIRA using `More->Attach Files` then click on btn:[Submit Patch]
2186 button, which'll trigger Hudson job to check patch for validity.
2187 . If your patch is longer than a single screen, also create a review on Review Board and
2188 add the link to JIRA. See <<reviewboard,reviewboard>>.
2192 .Few general guidelines
2193 * Always patch against the master branch first, even if you want to patch in another branch.
2194 HBase committers always apply patches first to the master branch, and backport if necessary.
2195 * Submit one single patch for a fix. If necessary, squash local commits to merge local commits into
2196 a single one first. See this
2197 link:http://stackoverflow.com/questions/5308816/how-to-use-git-merge-squash[Stack Overflow
2198 question] for more information about squashing commits.
2199 * Please understand that not every patch may get committed, and that feedback will likely be
2200 provided on the patch.
2201 * If you need to revise your patch, leave the previous patch file(s) attached to the JIRA, and
2202 upload a new one with incremented patch number. +
2203 Click on btn:[Cancel Patch] and then on btn:[Submit Patch] to trigger the presubmit run.
2205 [[submitting.patches.tests]]
2207 Always add and/or update relevant unit tests when making the changes.
2208 Make sure that new/changed unit tests pass locally before submitting the patch because it is faster
2209 than waiting for presubmit result which runs full test suite. This will save your own time and
2211 Use <<mockito,mockito>> to make mocks which are very useful for testing failure scenarios by
2212 injecting appropriate failures.
2214 If you are creating a new unit test class, notice how other unit test classes have
2215 classification/sizing annotations before class name and a static methods for setup/teardown of
2216 testing environment. Be sure to include annotations in any new unit test files.
2217 See <<hbase.tests,hbase.tests>> for more information on tests.
2219 ==== Integration Tests
2221 Significant new features should provide an integration test in addition to unit tests, suitable for exercising the new feature at different points in its configuration space.
2226 Patches larger than one screen, or patches that will be tricky to review, should go through link:https://reviews.apache.org[ReviewBoard].
2228 .Procedure: Use ReviewBoard
2229 . Register for an account if you don't already have one.
2230 It does not use the credentials from link:https://issues.apache.org[issues.apache.org].
2232 . Click [label]#New Review Request#.
2233 . Choose the `hbase-git` repository.
2234 Click Choose File to select the diff and optionally a parent diff.
2237 . Fill in the fields as required.
2238 At the minimum, fill in the [label]#Summary# and choose `hbase` as the [label]#Review Group#.
2239 If you fill in the [label]#Bugs# field, the review board links back to the relevant JIRA.
2240 The more fields you fill in, the better.
2241 Click btn:[Publish] to make your review request public.
2242 An email will be sent to everyone in the `hbase` group, to review the patch.
2243 . Back in your JIRA, click , and paste in the URL of your ReviewBoard request.
2244 This attaches the ReviewBoard to the JIRA, for easy access.
2245 . To cancel the request, click .
2247 For more information on how to use ReviewBoard, see link:http://www.reviewboard.org/docs/manual/1.5/[the ReviewBoard
2252 Submitting link:https://github.com/apache/hbase[GitHub] pull requests is another accepted form of
2253 contributing patches. Refer to GitHub link:https://help.github.com/[documentation] for details on
2254 how to create pull requests.
2256 NOTE: This section is incomplete and needs to be updated. Refer to
2257 link:https://issues.apache.org/jira/browse/HBASE-23557[HBASE-23557]
2259 ===== GitHub Tooling
2261 ====== Browser bookmarks
2263 Following is a useful javascript based browser bookmark that redirects from GitHub pull
2264 requests to the corresponding jira work item. This redirects based on the HBase jira ID mentioned
2265 in the issue title for the PR. Add the following javascript snippet as a browser bookmark to the
2266 tool bar. Clicking on it while you are on an HBase GitHub PR page redirects you to the corresponding
2269 [source, javascript]
2271 javascript:location.href='https://issues.apache.org/jira/browse/'+document.getElementsByClassName("js-issue-title")[0].innerHTML.match(/HBASE-\d+/)[0];
2274 ==== Guide for HBase Committers
2276 ===== Becoming a committer
2278 Committers are responsible for reviewing and integrating code changes, testing
2279 and voting on release candidates, weighing in on design discussions, as well as
2280 other types of project contributions. The PMC votes to make a contributor a
2281 committer based on an assessment of their contributions to the project. It is
2282 expected that committers demonstrate a sustained history of high-quality
2283 contributions to the project and community involvement.
2285 Contributions can be made in many ways. There is no single path to becoming a
2286 committer, nor any expected timeline. Submitting features, improvements, and bug
2287 fixes is the most common avenue, but other methods are both recognized and
2288 encouraged (and may be even more important to the health of HBase as a project and a
2289 community). A non-exhaustive list of potential contributions (in no particular
2292 * <<appendix_contributing_to_documentation,Update the documentation>> for new
2293 changes, best practices, recipes, and other improvements.
2294 * Keep the website up to date.
2295 * Perform testing and report the results. For instance, scale testing and
2296 testing non-standard configurations is always appreciated.
2297 * Maintain the shared Jenkins testing environment and other testing
2299 * <<hbase.rc.voting,Vote on release candidates>> after performing validation, even if non-binding.
2300 A non-binding vote is a vote by a non-committer.
2301 * Provide input for discussion threads on the link:/mail-lists.html[mailing lists] (which usually have
2302 `[DISCUSS]` in the subject line).
2303 * Answer questions questions on the user or developer mailing lists and on
2305 * Make sure the HBase community is a welcoming one and that we adhere to our
2306 link:/coc.html[Code of conduct]. Alert the PMC if you
2308 * Review other people's work (both code and non-code) and provide public
2310 * Report bugs that are found, or file new feature requests.
2311 * Triage issues and keep JIRA organized. This includes closing stale issues,
2312 labeling new issues, updating metadata, and other tasks as needed.
2313 * Mentor new contributors of all sorts.
2314 * Give talks and write blogs about HBase. Add these to the link:/[News] section
2316 * Provide UX feedback about HBase, the web UI, the CLI, APIs, and the website.
2317 * Write demo applications and scripts.
2318 * Help attract and retain a diverse community.
2319 * Interact with other projects in ways that benefit HBase and those other
2322 Not every individual is able to do all (or even any) of the items on this list.
2323 If you think of other ways to contribute, go for it (and add them to the list).
2324 A pleasant demeanor and willingness to contribute are all you need to make a
2325 positive impact on the HBase project. Invitations to become a committer are the
2326 result of steady interaction with the community over the long term, which builds
2327 trust and recognition.
2329 ===== New committers
2331 New committers are encouraged to first read Apache's generic committer
2334 * link:https://www.apache.org/dev/new-committers-guide.html[Apache New Committer Guide]
2335 * link:https://www.apache.org/dev/committers.html[Apache Committer FAQ]
2339 HBase committers should, as often as possible, attempt to review patches
2340 submitted by others. Ideally every submitted patch will get reviewed by a
2341 committer _within a few days_. If a committer reviews a patch they have not
2342 authored, and believe it to be of sufficient quality, then they can commit the
2343 patch. Otherwise the patch should be cancelled with a clear explanation for why
2346 The list of submitted patches is in the
2347 link:https://issues.apache.org/jira/secure/IssueNavigator.jspa?mode=hide&requestId=12312392[HBase Review Queue],
2348 which is ordered by time of last modification. Committers should scan the list
2349 from top to bottom, looking for patches that they feel qualified to review and
2350 possibly commit. If you see a patch you think someone else is better qualified
2351 to review, you can mention them by username in the JIRA.
2353 For non-trivial changes, it is required that another committer review your
2354 patches before commit. **Self-commits of non-trivial patches are not allowed.**
2355 Use the btn:[Submit Patch] button in JIRA, just like other contributors, and
2356 then wait for a `+1` response from another committer before committing.
2360 Patches which do not adhere to the guidelines in
2361 link:https://hbase.apache.org/book.html#developer[HowToContribute] and to the
2362 link:https://cwiki.apache.org/confluence/display/HADOOP2/CodeReviewChecklist[code review checklist]
2363 should be rejected. Committers should always be polite to contributors and try
2364 to instruct and encourage them to contribute better patches. If a committer
2365 wishes to improve an unacceptable patch, then it should first be rejected, and a
2366 new patch should be attached by the committer for further review.
2368 [[committing.patches]]
2371 Committers commit patches to the Apache HBase GIT repository.
2373 .Before you commit!!!!
2376 Make sure your local configuration is correct, especially your identity and email.
2377 Examine the output of the +$ git config --list+ command and be sure it is correct.
2378 See link:https://help.github.com/articles/set-up-git[Set Up Git] if you need
2382 When you commit a patch:
2384 . Include the Jira issue ID in the commit message along with a short description
2385 of the change. Try to add something more than just the Jira title so that
2386 someone looking at `git log` output doesn't have to go to Jira to discern what
2387 the change is about. Be sure to get the issue ID right, because this causes
2388 Jira to link to the change in Git (use the issue's "All" tab to see these
2390 . Commit the patch to a new branch based off `master` or the other intended
2391 branch. It's a good idea to include the JIRA ID in the name of this branch.
2392 Check out the relevant target branch where you want to commit, and make sure
2393 your local branch has all remote changes, by doing a +git pull --rebase+ or
2394 another similar command. Next, cherry-pick the change into each relevant
2395 branch (such as master), and push the changes to the remote branch using
2396 a command such as +git push <remote-server> <remote-branch>+.
2398 WARNING: If you do not have all remote changes, the push will fail.
2399 If the push fails for any reason, fix the problem or ask for help.
2400 Do not do a +git push --force+.
2402 Before you can commit a patch, you need to determine how the patch was created.
2403 The instructions and preferences around the way to create patches have changed,
2404 and there will be a transition period.
2406 .Determine How a Patch Was Created
2407 * If the first few lines of the patch look like the headers of an email, with a From, Date, and
2408 Subject, it was created using +git format-patch+. This is the preferred way, because you can
2409 reuse the submitter's commit message. If the commit message is not appropriate, you can still use
2410 the commit, then run `git commit --amend` and reword as appropriate.
2411 * If the first line of the patch looks similar to the following, it was created using +git diff+ without `--no-prefix`.
2412 This is acceptable too.
2413 Notice the `a` and `b` in front of the file names.
2414 This is the indication that the patch was not created with `--no-prefix`.
2417 diff --git a/src/main/asciidoc/_chapters/developer.adoc b/src/main/asciidoc/_chapters/developer.adoc
2420 * If the first line of the patch looks similar to the following (without the `a` and `b`), the
2421 patch was created with +git diff --no-prefix+ and you need to add `-p0` to the +git apply+ command
2425 diff --git src/main/asciidoc/_chapters/developer.adoc src/main/asciidoc/_chapters/developer.adoc
2429 .Example of committing a Patch
2431 One thing you will notice with these examples is that there are a lot of
2432 +git pull+ commands. The only command that actually writes anything to the
2433 remote repository is +git push+, and you need to make absolutely sure you have
2434 the correct versions of everything and don't have any conflicts before pushing.
2435 The extra +git pull+ commands are usually redundant, but better safe than sorry.
2437 The first example shows how to apply a patch that was generated with +git
2438 format-patch+ and apply it to the `master` and `branch-1` branches.
2440 The directive to use +git format-patch+ rather than +git diff+, and not to use
2441 `--no-prefix`, is a new one. See the second example for how to apply a patch
2442 created with +git diff+, and educate the person who created the patch.
2445 $ git checkout -b HBASE-XXXX
2446 $ git am ~/Downloads/HBASE-XXXX-v2.patch --signoff # If you are committing someone else's patch.
2447 $ git checkout master
2449 $ git cherry-pick <sha-from-commit>
2450 # Resolve conflicts if necessary or ask the submitter to do it
2451 $ git pull --rebase # Better safe than sorry
2452 $ git push origin master
2454 # Backport to branch-1
2455 $ git checkout branch-1
2457 $ git cherry-pick <sha-from-commit>
2458 # Resolve conflicts if necessary
2459 $ git pull --rebase # Better safe than sorry
2460 $ git push origin branch-1
2461 $ git branch -D HBASE-XXXX
2464 This example shows how to commit a patch that was created using +git diff+
2465 without `--no-prefix`. If the patch was created with `--no-prefix`, add `-p0` to
2466 the +git apply+ command.
2469 $ git apply ~/Downloads/HBASE-XXXX-v2.patch
2470 $ git commit -m "HBASE-XXXX Really Good Code Fix (Joe Schmo)" --author=<contributor> -a # This and next command is needed for patches created with 'git diff'
2471 $ git commit --amend --signoff
2472 $ git checkout master
2474 $ git cherry-pick <sha-from-commit>
2475 # Resolve conflicts if necessary or ask the submitter to do it
2476 $ git pull --rebase # Better safe than sorry
2477 $ git push origin master
2479 # Backport to branch-1
2480 $ git checkout branch-1
2482 $ git cherry-pick <sha-from-commit>
2483 # Resolve conflicts if necessary or ask the submitter to do it
2484 $ git pull --rebase # Better safe than sorry
2485 $ git push origin branch-1
2486 $ git branch -D HBASE-XXXX
2490 . Resolve the issue as fixed, thanking the contributor.
2491 Always set the "Fix Version" at this point, but only set a single fix version
2492 for each branch where the change was committed, the earliest release in that
2493 branch in which the change will appear.
2495 ====== Commit Message Format
2497 The commit message should contain the JIRA ID and a description of what the patch does.
2498 The preferred commit message format is:
2501 <jira-id> <jira-title> (<contributor-name-if-not-commit-author>)
2505 HBASE-12345 Fix All The Things (jane@example.com)
2508 If the contributor used +git format-patch+ to generate the patch, their commit
2509 message is in their patch and you can use that, but be sure the JIRA ID is at
2510 the front of the commit message, even if the contributor left it out.
2512 [[committer.amending.author]]
2513 ====== Use GitHub's "Co-authored-by" when there are multiple authors
2515 We've established the practice of committing to master and then cherry picking back to branches whenever possible, unless
2517 * it's breaking compat: In which case, if it can go in minor releases, backport to branch-1 and branch-2.
2518 * it's a new feature: No for maintenance releases, For minor releases, discuss and arrive at consensus.
2520 There are occasions when there are multiple author for a patch.
2521 For example when there is a minor conflict we can fix it up and just proceed with the commit.
2522 The amending author will be different from the original committer, so you should also attribute to the original author by
2523 adding one or more `Co-authored-by` trailers to the commit's message.
2524 See link:https://help.github.com/en/articles/creating-a-commit-with-multiple-authors/[the GitHub documentation for "Creating a commit with multiple authors"].
2526 In short, these are the steps to add Co-authors that will be tracked by GitHub:
2528 . Collect the name and email address for each co-author.
2529 . Commit the change, but after your commit description, instead of a closing quotation, add two empty lines. (Do not close the commit message with a quotation mark)
2530 . On the next line of the commit message, type `Co-authored-by: name <name@example.com>`. After the co-author information, add a closing quotation mark.
2532 Here is the example from the GitHub page, using 2 Co-authors:
2535 $ git commit -m "Refactor usability tests.
2538 Co-authored-by: name <name@example.com>
2539 Co-authored-by: another-name <another-name@example.com>"
2542 Note: `Amending-Author: Author <committer@apache>` was used prior to this
2543 link:https://lists.apache.org/thread.html/f00b5f9b65570e777dbb31c37d7b0ffc55c5fc567aefdb456608a042@%3Cdev.hbase.apache.org%3E[DISCUSSION].
2545 ====== Close related GitHub PRs
2547 As a project we work to ensure there's a JIRA associated with each change, but we don't mandate any particular tool be used for reviews. Due to implementation details of the ASF's integration between hosted git repositories and GitHub, the PMC has no ability to directly close PRs on our GitHub repo. In the event that a contributor makes a Pull Request on GitHub, either because the contributor finds that easier than attaching a patch to JIRA or because a reviewer prefers that UI for examining changes, it's important to make note of the PR in the commit that goes to the master branch so that PRs are kept up to date.
2549 To read more about the details of what kinds of commit messages will work with the GitHub "close via keyword in commit" mechanism see link:https://help.github.com/articles/closing-issues-using-keywords/[the GitHub documentation for "Closing issues using keywords"]. In summary, you should include a line with the phrase "closes #XXX", where the XXX is the pull request id. The pull request id is usually given in the GitHub UI in grey at the end of the subject heading.
2552 ====== Committers are responsible for making sure commits do not break the build or tests
2554 If a committer commits a patch, it is their responsibility to make sure it passes the test suite.
2555 It is helpful if contributors keep an eye out that their patch does not break the hbase build and/or tests, but ultimately, a contributor cannot be expected to be aware of all the particular vagaries and interconnections that occur in a project like HBase.
2559 ====== Patching Etiquette
2561 In the thread link:http://search-hadoop.com/m/DHED4EiwOz[HBase, mail # dev - ANNOUNCEMENT: Git Migration In Progress (WAS =>
2562 Re: Git Migration)], it was agreed on the following patch flow
2564 . Develop and commit the patch against master first.
2565 . Try to cherry-pick the patch when backporting if possible.
2566 . If this does not work, manually commit the patch to the branch.
2568 ====== Merge Commits
2570 Avoid merge commits, as they create problems in the git history.
2572 ====== Committing Documentation
2574 See <<appendix_contributing_to_documentation,appendix contributing to documentation>>.
2576 ====== How to re-trigger github Pull Request checks/re-build
2578 A Pull Request (PR) submission triggers the hbase yetus checks. The checks make
2579 sure the patch doesn't break the build or introduce test failures. The checks take
2580 around four hours to run (They are the same set run when you submit a patch via
2581 HBASE JIRA). When finished, they add a report to the PR as a comment. If a problem
2582 w/ the patch -- failed compile, checkstyle violation, or an added findbugs --
2583 the original author makes fixes and pushes a new patch. This re-runs the checks
2584 to produce a new report.
2586 Sometimes though, the patch is good but a flakey, unrelated test has the report vote -1
2587 on the patch. In this case, **committers** can retrigger the check run by doing a force push of the
2588 exact same patch. Or, click on the `Console output` link which shows toward the end
2589 of the report (For example `https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-289/1/console`).
2590 This will take you to `builds.apache.org`, to the build run that failed. See the
2591 "breadcrumbs" along the top (where breadcrumbs is the listing of the directories that
2592 gets us to this particular build page). It'll look something like
2593 `Jenkins > HBase-PreCommit-GitHub-PR > PR-289 > #1`. Click on the
2594 PR number -- i.e. PR-289 in our example -- and then, when you've arrived at the PR page,
2595 find the 'Build with Parameters' menu-item (along top left-hand menu). Click here and
2596 then `Build` leaving the JIRA_ISSUE_KEY empty. This will re-run your checks.
2600 Committers should hang out in the #hbase room on irc.freenode.net for real-time discussions.
2601 However any substantive discussion (as with any off-list project-related discussion) should be re-iterated in Jira or on the developer list.
2603 ==== Do not edit JIRA comments
2605 Misspellings and/or bad grammar is preferable to the disruption a JIRA comment edit causes: See the discussion at link:http://search-hadoop.com/?q=%5BReopened%5D+%28HBASE-451%29+Remove+HTableDescriptor+from+HRegionInfo&fc_project=HBase[Re:(HBASE-451) Remove HTableDescriptor from HRegionInfo]
2608 === The hbase-thirdparty dependency and shading/relocation
2610 A new project was created for the release of hbase-2.0.0. It was called
2611 `hbase-thirdparty`. This project exists only to provide the main hbase
2612 project with relocated -- or shaded -- versions of popular thirdparty
2613 libraries such as guava, netty, and protobuf. The mainline HBase project
2614 relies on the relocated versions of these libraries gotten from hbase-thirdparty
2615 rather than on finding these classes in their usual locations. We do this so
2616 we can specify whatever the version we wish. If we don't relocate, we must
2617 harmonize our version to match that which hadoop, spark, and other projects use.
2619 For developers, this means you need to be careful referring to classes from
2620 netty, guava, protobuf, gson, etc. (see the hbase-thirdparty pom.xml for what
2621 it provides). Devs must refer to the hbase-thirdparty provided classes. In
2622 practice, this is usually not an issue (though it can be a bit of a pain). You
2623 will have to hunt for the relocated version of your particular class. You'll
2624 find it by prepending the general relocation prefix of `org.apache.hbase.thirdparty.`.
2625 For example if you are looking for `com.google.protobuf.Message`, the relocated
2626 version used by HBase internals can be found at
2627 `org.apache.hbase.thirdparty.com.google.protobuf.Message`.
2629 For a few thirdparty libs, like protobuf (see the protobuf chapter in this book
2630 for the why), your IDE may give you both options -- the `com.google.protobuf.*`
2631 and the `org.apache.hbase.thirdparty.com.google.protobuf.*` -- because both
2632 classes are on your CLASSPATH. Unless you are doing the particular juggling
2633 required in Coprocessor Endpoint development (again see above cited protobuf
2634 chapter), you'll want to use the shaded version, always.
2636 The `hbase-thirdparty` project has groupid of `org.apache.hbase.thirdparty`.
2637 As of this writing, it provides three jars; one for netty with an artifactid of
2638 `hbase-thirdparty-netty`, one for protobuf at `hbase-thirdparty-protobuf` and then
2639 a jar for all else -- gson, guava -- at `hbase-thirdpaty-miscellaneous`.
2641 The hbase-thirdparty artifacts are a product produced by the Apache HBase
2642 project under the aegis of the HBase Project Management Committee. Releases
2643 are done via the usual voting project on the hbase dev mailing list. If issue
2644 in the hbase-thirdparty, use the hbase JIRA and mailing lists to post notice.
2646 [[hbase.archetypes.development]]
2647 === Development of HBase-related Maven archetypes
2649 The development of HBase-related Maven archetypes was begun with
2650 link:https://issues.apache.org/jira/browse/HBASE-14876[HBASE-14876].
2651 For an overview of the hbase-archetypes infrastructure and instructions
2652 for developing new HBase-related Maven archetypes, please see
2653 `hbase/hbase-archetypes/README.md`.
2655 ifdef::backend-docbook[]
2658 // Generated automatically by the DocBook toolchain.
2659 endif::backend-docbook[]