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:https://lists.apache.org/thread.html/b122265f4e4054cf08f8cd38609fb06af72f398c44f9086b05ef4e21%401407246237%40%3Cdev.hbase.apache.org%3E[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. You must use at least Maven 3.0.4. To check your Maven version, run
326 the command +mvn -version+.
328 [[build.basic.jdk_requirements]]
329 ==== JDK Version Requirements
331 HBase has Java version compiler requirements that vary by release branch. At compilation time,
332 HBase has the same version requirements as it does for runtime. See <<java,java>> for a complete
333 support matrix of Java version by HBase version.
335 [[maven.build.commands]]
336 ==== Maven Build Commands
338 All commands are executed from the local HBase project directory.
342 The simplest command to compile HBase from its java source code is to use the `package` target, which builds JARs with the compiled files.
346 mvn package -DskipTests
349 Or, to clean up before compiling:
353 mvn clean package -DskipTests
356 With Eclipse set up as explained above in <<eclipse,eclipse>>, you can also use the menu:Build[] command in Eclipse.
357 To create the full installable HBase package takes a little bit more work, so read on.
359 [[maven.build.commands.compile]]
362 The `compile` target does not create the JARs with the compiled files.
376 To install the JARs in your _~/.m2/_ directory, use the `install` target.
390 mvn clean install -DskipTests
393 [[maven.build.commands.unitall]]
394 ==== Running all or individual Unit Tests
396 See the <<hbase.unittests.cmds,hbase.unittests.cmds>> section in <<hbase.unittests,hbase.unittests>>
398 [[maven.build.hadoop]]
399 ==== Building against various Hadoop versions
401 HBase supports building against Apache Hadoop versions: 2.y and 3.y (early release artifacts).
402 Exactly which version of Hadoop is used by default varies by release branch. See the section
403 <<hadoop,Hadoop>> for the complete breakdown of supported Hadoop version by HBase release.
405 The mechanism for selecting a Hadoop version at build time is identical across all releases. Which
406 version of Hadoop is default varies. We manage Hadoop major version selection by way of Maven
407 profiles. Due to the peculiarities of Maven profile mutual exclusion, the profile that builds
408 against a particular Hadoop version is activated by setting a property, *not* the usual profile
409 activation. Hadoop version profile activation is summarized by the following table.
411 .Hadoop Profile Activation by HBase Release
412 [cols="3*^.^", options="header"]
414 | | Hadoop2 Activation | Hadoop3 Activation
415 | HBase 1.3+ | _active by default_ | `-Dhadoop.profile=3.0`
416 | HBase 3.0+ | _not supported_ | _active by default_
421 Please note that where a profile is active by default, `hadoop.profile` must NOT be provided.
424 Once the Hadoop major version profile is activated, the exact Hadoop version can be
425 specified by overriding the appropriate property value. For Hadoop2 versions, the property name
426 is `hadoop-two.version`. With Hadoop3 versions, the property name is `hadoop-three.version`.
428 .Example 1, Building HBase 1.7 against Hadoop 2.10.0
430 For example, to build HBase 1.7 against Hadoop 2.10.0, the profile is set for Hadoop2 by default,
431 so only `hadoop-two.version` must be specified:
435 git checkout branch-1
436 mvn -Dhadoop-two.version=2.10.0 ...
439 .Example 2, Building HBase 2.3 or 2.4 against Hadoop 3.4.0-SNAPSHOT
441 This is how a developer might check the compatibility of HBase 2.3 or 2.4 against an unreleased
442 Hadoop version (currently 3.4). Both the Hadoop3 profile and version must be specified:
446 git checkout branch-2.4
447 mvn -Dhadoop.profile=3.0 -Dhadoop-three.version=3.4.0-SNAPSHOT ...
450 .Example 3, Building HBase 3.0 against Hadoop 3.4.0-SNAPSHOT
452 The same developer might want also to check the development version of HBase (currently 3.0)
453 against the development version of Hadoop (currently 3.4). In this case, the Hadoop3 profile is
454 active by default, so only `hadoop-three.version` must be specified:
459 mvn -Dhadoop-three.version=3.4.0-SNAPSHOT ...
462 [[maven.build.jdk11_hadoop3]]
463 ==== Building with JDK11 and Hadoop3
465 HBase manages JDK-specific build settings using Maven profiles. The profile appropriate to the JDK
466 in use is automatically activated. Building and running on JDK8 supports both Hadoop2 and Hadoop3.
467 For JDK11, only Hadoop3 is supported. Thus, the Hadoop3 profile must be active when building on
468 JDK11, and the artifacts used when running HBase on JDK11 must be compiled against Hadoop3.
469 Furthermore, the JDK11 profile requires a minimum Hadoop version of 3.2.0. This value is specified
470 by the JDK11 profile, but it can be overridden using the `hadoop-three.version` property as normal.
471 For details on Hadoop profile activation by HBase branch, see
472 <<maven.build.hadoop,Building against various Hadoop versions>>. See <<java,java>> for a complete
473 support matrix of Java version by HBase version.
475 .Example 1, Building HBase 2.3 or 2.4 with JDK11
477 To build HBase 2.3 or 2.4 with JDK11, the Hadoop3 profile must be activated explicitly.
481 git checkout branch-2.4
482 JAVA_HOME=/usr/lib/jvm/java-11 mvn -Dhadoop.profile=3.0 ...
485 .Example 2, Building HBase 3.0 with JDK11
487 For HBase 3.0, the Hadoop3 profile is active by default, no additional properties need be
493 JAVA_HOME=/usr/lib/jvm/java-11 mvn ...
496 [[maven.build.jdk11_hadoop3_ide]]
497 ==== Building and testing in an IDE with JDK11 and Hadoop3
499 Continuing the discussion from the <<maven.build.jdk11_hadoop3,earlier section>>, building and
500 testing with JDK11 and Hadoop3 within an IDE may require additional configuration. Specifically,
501 make sure the JVM version used by the IDE is a JDK11, the active JDK Maven profile is for JDK11,
502 and the Maven profile for JDK8 is NOT active. Likewise, ensure the Hadoop3 Maven profile is active
503 and the Hadoop2 Maven profile is NOT active.
508 You may need to change the protobuf definitions that reside in the _hbase-protocol_ module or other modules.
510 Previous to hbase-2.0.0, protobuf definition files were sprinkled across all hbase modules but now all
511 to do with protobuf must reside in the hbase-protocol module; we are trying to contain our protobuf
512 use so we can freely change versions without upsetting any downstream project use of protobuf.
514 The protobuf files are located in _hbase-protocol/src/main/protobuf_.
515 For the change to be effective, you will need to regenerate the classes.
519 mvn package -pl hbase-protocol -am
522 Similarly, protobuf definitions for internal use are located in the _hbase-protocol-shaded_ module.
526 mvn package -pl hbase-protocol-shaded -am
529 Typically, protobuf code generation is done using the native `protoc` binary. In our build we use a maven plugin for
530 convenience; however, the plugin may not be able to retrieve appropriate binaries for all platforms. If you find yourself
531 on a platform where protoc fails, you will have to compile protoc from source, and run it independent of our maven build.
532 You can disable the inline code generation by specifying `-Dprotoc.skip` in your maven arguments, allowing your build to proceed further.
535 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.
537 Read the _hbase-protocol/README.txt_ for more details
542 You may need to change the thrift definitions that reside in the _hbase-thrift_ module or other modules.
544 The thrift files are located in _hbase-thrift/src/main/resources_.
545 For the change to be effective, you will need to regenerate the classes.
546 You can use maven profile `compile-thrift` to do this.
550 mvn compile -Pcompile-thrift
553 You may also want to define `thrift.path` for the thrift binary, using the following command:
558 mvn compile -Pcompile-thrift -Dthrift.path=/opt/local/bin/thrift
563 You can build a tarball without going through the release process described in <<releasing,releasing>>, by running the following command:
566 mvn -DskipTests clean install && mvn -DskipTests package assembly:single
569 The distribution tarball is built in _hbase-assembly/target/hbase-<version>-bin.tar.gz_.
571 You can install or deploy the tarball by having the assembly:single goal before install or deploy in the maven command:
574 mvn -DskipTests package assembly:single install
577 mvn -DskipTests package assembly:single deploy
583 ===== Maven Site failure
584 If you see `Unable to find resource 'VM_global_library.vm'`, ignore it.
586 It is link:https://issues.apache.org/jira/browse/MSITE-286[officially ugly] though.
588 [[build.on.linux.aarch64]]
589 === Build On Linux Aarch64
590 HBase runs on both Windows and UNIX-like systems, and it should run on any platform
591 that runs a supported version of Java. This should include JVMs on x86_64 and aarch64.
592 The documentation below describes how to build hbase on aarch64 platform.
594 ==== Set Environment Variables
595 Manually install Java and Maven on aarch64 servers if they are not installed,
596 and set environment variables. For example:
600 export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-arm64
601 export MAVEN_HOME=/opt/maven
602 export PATH=${MAVEN_HOME}/bin:${JAVA_HOME}/bin:${PATH}
605 ==== Use Protobuf Supported On Aarch64
606 Now HBase uses protobuf of two versions. Version '3.11.4' of protobuf that hbase uses
607 internally and version '2.5.0' as external usage.
608 Package protoc-2.5.0 does not work on aarch64 platform, we should add maven
609 profile '-Paarch64' when building. It downloads protoc-2.5.0 package from maven
610 repository which we made on aarch64 platform locally.
614 mvn clean install -Paarch64 -DskipTests
618 Protobuf is released with aarch64 protoc since version '3.5.0', and we are planning to
619 upgrade protobuf later, then we don't have to add the profile '-Paarch64' anymore.
623 == Releasing Apache HBase
625 .Building against HBase 1.x
628 See old refguides for how to build HBase 1.x.
629 The below is for building hbase2.
633 === Making a Release Candidate
634 Only committers can make releases of hbase artifacts.
637 Check to be sure recent builds have been passing for the branch from where you
638 are going to take your release. You should also have tried recent branch tips
639 out on a cluster under load, perhaps by running the `hbase-it` integration test
640 suite for a few hours to 'burn in' the near-candidate bits.
642 You will need a published signing key added to the hbase
643 link:https://dist.apache.org/repos/dist/release/hbase/KEYS[KEYS] file.
644 (For how to add a KEY, see _Step 1._ in link:https://cwiki.apache.org/confluence/display/HADOOP2/HowToRelease[How To Release],
645 the Hadoop version of this document).
647 Next make sure JIRA is properly primed, that all issues targeted against
648 the prospective release have been resolved and are present in git on the
649 particular branch. If any outstanding issues, move them out of the release by
650 adjusting the fix version to remove this pending release as a target.
651 Any JIRA with a fix version that matches the release candidate
652 target release will be included in the generated _CHANGES.md/RELEASENOTES.md_
653 files that ship with the release so make sure JIRA is correct before you begin.
655 After doing the above, you can move to the manufacture of an RC.
657 Building an RC is involved so we've scripted it. The script builds in a Docker
658 container to ensure we have a consistent environment building. It will ask you
659 for passwords for apache and for your gpg signing key so it can sign and commit
660 on your behalf. The passwords are passed to gpg-agent in the container and
661 purged along with the container when the build is done.
665 * Set version to the release version
666 * Updates RELEASENOTES.md and CHANGES.md
668 * Set version to next SNAPSHOT version.
669 * Builds, signs, and hashes all artifacts.
670 * Generates the api compatibility report
671 * Pushes release tgzs to the dev dir in a apache dist.
672 * Pushes to repository.apache.org staging.
673 * Creates vote email template.
675 The _dev-support/create-release/do-release-docker.sh_ Release Candidate (RC)
676 Generating script is maintained in the master branch but can generate RCs
677 for any 2.x+ branch (The script does not work against branch-1). Check out
678 and update the master branch when making RCs. See
679 _dev-support/create-release/README.txt_ for how to configure your
680 environment and run the script.
684 _dev-support/create-release/do-release-docker.sh_ supercedes the previous
685 _dev-support/make_rc.sh_ script. It is more comprehensive automating all
686 steps, rather than a portion, building a RC.
689 ==== Release Candidate Procedure
690 Here we outline the steps involved generating a Release Candidate, the steps
691 automated by the _dev-support/create-release/do-release-docker.sh_ script
692 described in the previous section. Running these steps manually tends to
693 be error-prone so is not recommended. The below is informational only.
695 The process below makes use of various tools, mainly _git_ and _maven_.
697 .Specifying the Heap Space for Maven
700 You may run into OutOfMemoryErrors building, particularly building the site and
701 documentation. Up the heap for Maven by setting the `MAVEN_OPTS` variable.
702 You can prefix the variable to the Maven command, as in the following example:
705 MAVEN_OPTS="-Xmx4g -XX:MaxPermSize=256m" mvn package
708 You could also set this in an environment variable or alias in your shell.
711 [[maven.settings.xml]]
712 .Example _~/.m2/settings.xml_ File
714 Publishing to maven requires you sign the artifacts you want to upload.
715 For the build to sign them for you, you a properly configured _settings.xml_
716 in your local repository under _.m2_, such as the following.
720 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
721 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
722 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
723 http://maven.apache.org/xsd/settings-1.0.0.xsd">
725 <!- To publish a snapshot of some part of Maven -->
727 <id>apache.snapshots.https</id>
728 <username>YOUR_APACHE_ID
730 <password>YOUR_APACHE_PASSWORD
733 <!-- To publish a website using Maven -->
734 <!-- To stage a release of some part of Maven -->
736 <id>apache.releases.https</id>
737 <username>YOUR_APACHE_ID
739 <password>YOUR_APACHE_PASSWORD
745 <id>apache-release</id>
747 <gpg.keyname>YOUR_KEYNAME</gpg.keyname>
748 <!--Keyname is something like this ... 00A5F21E... do gpg --list-keys to find it-->
749 <gpg.passphrase>YOUR_KEY_PASSWORD
758 ===== Update the _CHANGES.md_ and _RELEASENOTES.md_ files and the POM files.
760 Update _CHANGES.md_ with the changes since the last release. Be careful with where you put
761 headings and license. Respect the instructions and warning you find in current
762 _CHANGES.md_ and _RELEASENOTES.md_ since these two files are processed by tooling that is
763 looking for particular string sequences. See link:https://issues.apache.org/jira/browse/HBASE-21399[HBASE-21399]
764 for description on how to make use of yetus generating additions to
765 _CHANGES.md_ and _RELEASENOTES.md_ (RECOMMENDED!). Adding JIRA fixes, make sure the
766 URL to the JIRA points to the proper location which lists fixes for this release.
768 Next, adjust the version in all the POM files appropriately.
769 If you are making a release candidate, you must remove the `-SNAPSHOT` label from all versions
770 in all pom.xml files.
771 If you are running this receipe to publish a snapshot, you must keep the `-SNAPSHOT` suffix on the hbase version.
772 The link:http://www.mojohaus.org/versions-maven-plugin/[Versions Maven Plugin] can be of use here.
773 To set a version in all the many poms of the hbase multi-module project, use a command like the following:
777 $ mvn clean org.codehaus.mojo:versions-maven-plugin:2.5:set -DnewVersion=2.1.0-SNAPSHOT
\x1a
780 Make sure all versions in poms are changed! Checkin the _CHANGES.md_, _RELEASENOTES.md_, and
781 any maven version changes.
783 ===== Update the documentation.
785 Update the documentation under _src/main/asciidoc_.
786 This usually involves copying the latest from master branch and making version-particular
787 adjustments to suit this release candidate version. Commit your changes.
789 ===== Clean the checkout dir
797 Check licenses are good
801 $ mvn apache-rat:check
804 If the above fails, check the rat log.
808 $ grep 'Rat check' patchprocess/mvn_apache_rat.log
811 ===== Create a release tag.
812 Presuming you have run basic tests, the rat check, passes and all is
813 looking good, now is the time to tag the release candidate (You
814 always remove the tag if you need to redo). To tag, do
815 what follows substituting in the version appropriate to your build.
816 All tags should be signed tags; i.e. pass the _-s_ option (See
817 link:http://https://git-scm.com/book/id/v2/Git-Tools-Signing-Your-Work[Signing Your Work]
818 for how to set up your git environment for signing).
822 $ git tag -s 2.0.0-alpha4-RC0 -m "Tagging the 2.0.0-alpha4 first Releae Candidate (Candidates start at zero)"
825 Or, if you are making a release, tags should have a _rel/_ prefix to ensure
826 they are preserved in the Apache repo as in:
830 +$ git tag -s rel/2.0.0-alpha4 -m "Tagging the 2.0.0-alpha4 Release"
833 Push the (specific) tag (only) so others have access.
837 $ git push origin 2.0.0-alpha4-RC0
840 For how to delete tags, see
841 link:http://www.manikrathee.com/how-to-delete-a-tag-in-git.html[How to Delete a Tag]. Covers
842 deleting tags that have not yet been pushed to the remote Apache
843 repo as well as delete of tags pushed to Apache.
845 ===== Build the source tarball.
846 Now, build the source tarball. Lets presume we are building the source
847 tarball for the tag _2.0.0-alpha4-RC0_ into _/tmp/hbase-2.0.0-alpha4-RC0/_
848 (This step requires that the mvn and git clean steps described above have just been done).
852 $ 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
855 Above we generate the hbase-2.0.0-alpha4-src.tar.gz tarball into the
856 _/tmp/hbase-2.0.0-alpha4-RC0_ build output directory (We don't want the _RC0_ in the name or prefix.
857 These bits are currently a release candidate but if the VOTE passes, they will become the release so we do not taint
858 the artifact names with _RCX_).
860 ===== Build the binary tarball.
861 Next, build the binary tarball. Add the `-Prelease` profile when building.
862 It runs the license apache-rat check among other rules that help ensure
863 all is wholesome. Do it in two steps.
865 First install into the local repository
869 $ mvn clean install -DskipTests -Prelease
872 Next, generate documentation and assemble the tarball. Be warned,
873 this next step can take a good while, a couple of hours generating site
878 $ mvn install -DskipTests site assembly:single -Prelease
881 Otherwise, the build complains that hbase modules are not in the maven repository
882 when you try to do it all in one step, especially on a fresh repository.
883 It seems that you need the install goal in both steps.
885 Extract the generated tarball -- you'll find it under
886 _hbase-assembly/target_ and check it out.
887 Look at the documentation, see if it runs, etc.
888 If good, copy the tarball beside the source tarball in the
889 build output directory.
891 ===== Deploy to the Maven Repository.
893 Next, deploy HBase to the Apache Maven repository. Add the
894 apache-release` profile when running the `mvn deploy` command.
895 This profile comes from the Apache parent pom referenced by our pom files.
896 It does signing of your artifacts published to Maven, as long as the
897 _settings.xml_ is configured correctly, as described in <<maven.settings.xml>>.
898 This step depends on the local repository having been populate
899 by the just-previous bin tarball build.
904 $ mvn deploy -DskipTests -Papache-release -Prelease
907 This command copies all artifacts up to a temporary staging Apache mvn repository in an 'open' state.
908 More work needs to be done on these maven artifacts to make them generally available.
910 We do not release HBase tarball to the Apache Maven repository. To avoid deploying the tarball, do not
911 include the `assembly:single` goal in your `mvn deploy` command. Check the deployed artifacts as described in the next section.
916 If you ran the old _dev-support/make_rc.sh_ script, this is as far as it takes you.
917 To finish the release, take up the script from here on out.
920 ===== Make the Release Candidate available.
922 The artifacts are in the maven repository in the staging area in the 'open' state.
923 While in this 'open' state you can check out what you've published to make sure all is good.
924 To do this, log in to Apache's Nexus at link:https://repository.apache.org[repository.apache.org] using your Apache ID.
925 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.
926 Use the tree view to expand the list of repository contents and inspect if the artifacts you expect are present. Check the POMs.
927 As long as the staging repo is open you can re-upload if something is missing or built incorrectly.
929 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.
930 Sometimes the upload fails in the middle. This is another reason you might have to 'Drop' the upload from the staging repository.
932 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.
933 (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.)
935 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.
940 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.
941 Check it out and run its simple test to make sure maven artifacts are properly deployed to the maven repository.
942 Be sure to edit the pom to point to the proper staging repository.
943 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.
946 See link:https://www.apache.org/dev/publishing-maven-artifacts.html[Publishing Maven Artifacts] for some pointers on this maven staging process.
948 If the HBase version ends in `-SNAPSHOT`, the artifacts go elsewhere.
949 They are put into the Apache snapshots repository directly and are immediately available.
950 Making a SNAPSHOT release, this is what you want to happen.
952 At this stage, you have two tarballs in your 'build output directory' and a set of artifacts
953 in a staging area of the maven repository, in the 'closed' state.
954 Next sign, fingerprint and then 'stage' your release candiate build output directory via svnpubsub by committing
955 your directory to link:https://dist.apache.org/repos/dist/dev/hbase/[The dev distribution directory]
956 (See comments on link:https://issues.apache.org/jira/browse/HBASE-10554[HBASE-10554 Please delete old releases from mirroring system]
957 but in essence it is an svn checkout of link:https://dist.apache.org/repos/dist/dev/hbase[dev/hbase] -- releases are at
958 link:https://dist.apache.org/repos/dist/release/hbase[release/hbase]). In the _version directory_ run the following commands:
962 $ for i in *.tar.gz; do echo $i; gpg --print-md MD5 $i > $i.md5 ; done
963 $ for i in *.tar.gz; do echo $i; gpg --print-md SHA512 $i > $i.sha ; done
964 $ for i in *.tar.gz; do echo $i; gpg --armor --output $i.asc --detach-sig $i ; done
966 # Presuming our 'build output directory' is named 0.96.0RC0, copy it to the svn checkout of the dist dev dir
967 # in this case named hbase.dist.dev.svn
968 $ cd /Users/stack/checkouts/hbase.dist.dev.svn
971 Working Copy Root Path: /Users/stack/checkouts/hbase.dist.dev.svn
972 URL: https://dist.apache.org/repos/dist/dev/hbase
973 Repository Root: https://dist.apache.org/repos/dist
974 Repository UUID: 0d268c88-bc11-4956-87df-91683dc98e59
978 Last Changed Author: ndimiduk
979 Last Changed Rev: 15045
980 Last Changed Date: 2016-08-28 11:13:36 -0700 (Sun, 28 Aug 2016)
981 $ mv 0.96.0RC0 /Users/stack/checkouts/hbase.dist.dev.svn
986 Ensure it actually gets published by checking link:https://dist.apache.org/repos/dist/dev/hbase/[https://dist.apache.org/repos/dist/dev/hbase/].
988 Announce the release candidate on the mailing list and call a vote.
991 === Publishing a SNAPSHOT to maven
993 Make sure your _settings.xml_ is set up properly (see <<maven.settings.xml>>).
994 Make sure the hbase version includes `-SNAPSHOT` as a suffix.
995 Following is an example of publishing SNAPSHOTS of a release that had an hbase version of 0.96.0 in its poms.
1000 $ mvn clean install -DskipTests javadoc:aggregate site assembly:single -Prelease
1001 $ mvn -DskipTests deploy -Papache-release
1004 The _make_rc.sh_ script mentioned above (see <<maven.release,maven.release>>) can help you publish `SNAPSHOTS`.
1005 Make sure your `hbase.version` has a `-SNAPSHOT` suffix before running the script.
1006 It will put a snapshot up into the apache snapshot repository for you.
1009 == Voting on Release Candidates
1011 Everyone is encouraged to try and vote on HBase release candidates.
1012 Only the votes of PMC members are binding.
1013 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].
1017 Before casting +1 binding votes, individuals are required to
1018 download the signed source code package onto their own hardware, compile it as
1019 provided, and test the resulting executable on their own platform, along with also
1020 validating cryptographic signatures and verifying that the package meets the
1021 requirements of the ASF policy on releases.
1024 Regards the latter, run `mvn apache-rat:check` to verify all files are suitably licensed.
1025 See link:https://mail-archives.apache.org/mod_mbox/hbase-dev/201406.mbox/%3CCA%2BRK%3D_B8EP0JMFV%2Bdt-k1g%3DBmedzyq2z1GSqrnMMiH6%3DcdoiAA%40mail.gmail.com%3E[HBase, mail # dev - On recent discussion clarifying ASF release policy]
1026 for how we arrived at this process.
1028 To help with the release verification, please follow the guideline below and vote based on the your verification.
1030 === Baseline Verifications for Voting Release Candidates
1032 Although contributors have their own checklist for verifications, the following items are usually used for voting on release candidates.
1035 * RELEASENOTES.md (release notes) if any
1036 * Generated API compatibility report
1037 ** 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
1038 * Use `hbase-vote.sh` to perform sanity checks for checksum, signatures, files are licensed, built from source, and unit tests.
1039 ** `hbase-vote.sh` shell script is available under `dev-support` directory of HBase source. Following are the usage details.
1043 ./dev-support/hbase-vote.sh -h
1044 hbase-vote. A script for standard vote which verifies the following items
1045 1. Checksum of sources and binaries
1046 2. Signature of sources and binaries
1048 4. Built from source
1051 Usage: hbase-vote.sh -s | --source <url> [-k | --key <signature>] [-f | --keys-file-url <url>] [-o | --output-dir </path/to/use>] [-P runSmallTests] [-D property[=value]]
1052 hbase-vote.sh -h | --help
1054 -h | --help Show this screen.
1055 -s | --source '<url>' A URL pointing to the release candidate sources and binaries
1056 e.g. https://dist.apache.org/repos/dist/dev/hbase/hbase-<version>RC0/
1057 -k | --key '<signature>' A signature of the public key, e.g. 9AD2AE49
1058 -f | --keys-file-url '<url>' the URL of the key file, default is
1059 https://downloads.apache.org/hbase/KEYS
1060 -o | --output-dir '</path>' directory which has the stdout and stderr of each verification target
1061 -P | list of maven profiles to activate for test UT/IT, i.e. <-P runSmallTests> Defaults to runAllTests
1062 -D | list of maven properties to set for the mvn invocations, i.e. <-D hadoop.profile=3.0> Defaults to unset
1064 * 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).
1066 === Additional Verifications for Voting Release Candidates
1068 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.
1070 * Start a distributed HBase cluster and call out the test result of specific workload on cluster. e.g.
1071 ** Run basic table operations, e.g. `create/put/get/scan/flush/list/disable/drop`
1072 ** Run built-in tests, e.g. `LoadTestTool` (LTT) and `IntegrationTestBigLinkedList` (ITBLL)
1074 [[hbase.release.announcement]]
1075 == Announcing Releases
1077 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.
1081 The HBase team is happy to announce the immediate availability of HBase _version_.
1083 Apache HBaseâ„¢ is an open-source, distributed, versioned, non-relational database.
1084 Apache HBase gives you low latency random access to billions of rows with
1085 millions of columns atop non-specialized hardware. To learn more about HBase,
1086 see https://hbase.apache.org/.
1088 HBase _version_ is the _nth_ minor release in the HBase _major_.x line, which aims to
1089 improve the stability and reliability of HBase. This release includes roughly
1090 XXX resolved issues not covered by previous _major_.x releases.
1092 Notable new features include:
1093 - List text descriptions of features that fit on one line
1094 - Including if JDK or Hadoop support versions changes
1095 - If the "stable" pointer changes, call that out
1096 - For those with obvious JIRA IDs, include them (HBASE-YYYYY)
1098 The full list of issues can be found in the included CHANGES.md and RELEASENOTES.md,
1099 or via our issue tracker:
1101 https://s.apache.org/hbase-_version_-jira
1103 To download please follow the links and instructions on our website:
1105 https://hbase.apache.org/downloads.html
1108 Question, comments, and problems are always welcome at: dev@hbase.apache.org.
1110 Thanks to all who contributed and made this release possible.
1116 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.
1119 == Generating the HBase Reference Guide
1121 The manual is marked up using Asciidoc.
1122 We then use the link:http://asciidoctor.org/docs/asciidoctor-maven-plugin/[Asciidoctor maven plugin] to transform the markup to html.
1123 This plugin is run when you specify the +site+ goal as in when you run +mvn site+.
1124 See <<appendix_contributing_to_documentation,appendix contributing to documentation>> for more information on building the documentation.
1127 == Updating link:https://hbase.apache.org[hbase.apache.org]
1129 [[hbase.org.site.contributing]]
1130 === Contributing to hbase.apache.org
1132 See <<appendix_contributing_to_documentation,appendix contributing to documentation>> for more information on contributing to the documentation or website.
1134 [[hbase.org.site.publishing]]
1135 === Publishing link:https://hbase.apache.org[hbase.apache.org]
1137 See <<website_publish>> for instructions on publishing the website and documentation.
1142 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.
1144 This information is about unit tests for HBase itself.
1145 For developing unit tests for your HBase applications, see <<unit.tests,unit.tests>>.
1147 [[hbase.moduletests]]
1148 === Apache HBase Modules
1150 As of 0.96, Apache HBase is split into multiple modules.
1151 This creates "interesting" rules for how and where tests are written.
1152 If you are writing code for `hbase-server`, see <<hbase.unittests,hbase.unittests>> for how to write your tests.
1153 These tests can spin up a minicluster and will need to be categorized.
1154 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).
1156 [[hbase.moduletest.shell]]
1157 ==== Testing the HBase Shell
1159 The HBase shell and its tests are predominantly written in jruby.
1161 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.
1162 The tests were split into separate classes to accomodate class level timeouts (see <<hbase.unittests>> for specifics).
1163 You can run all of these tests from the top level with:
1167 mvn clean test -Dtest=Test*Shell
1170 If you have previously done a `mvn install`, then you can instruct maven to run only the tests in the hbase-shell module with:
1174 mvn clean test -pl hbase-shell
1177 Alternatively, you may limit the shell tests that run using the system variable `shell.test`.
1178 This value should specify the ruby literal equivalent of a particular test case by name.
1179 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:
1183 mvn clean test -pl hbase-shell -Dshell.test=/AdminAlterTableTest/
1186 You may also use a link:http://docs.ruby-doc.com/docs/ProgrammingRuby/html/language.html#UJ[Ruby Regular Expression
1187 literal] (in the `/pattern/` style) to select a set of test cases.
1188 You can run all of the HBase admin related tests, including both the normal administration and the security administration, with the command:
1193 mvn clean test -pl hbase-shell -Dshell.test=/.*Admin.*Test/
1196 In the event of a test failure, you can see details by examining the XML version of the surefire report results
1200 vim hbase-shell/target/surefire-reports/TEST-org.apache.hadoop.hbase.client.TestShell.xml
1203 [[hbase.moduletest.run]]
1204 ==== Running Tests in other Modules
1206 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:
1213 which will just run the tests IN THAT MODULE.
1214 If there are other dependencies on other modules, then you will have run the command from the ROOT HBASE DIRECTORY.
1215 This will run the tests in the other modules, unless you specify to skip the tests in that module.
1216 For instance, to skip the tests in the hbase-server module, you would run:
1220 mvn clean test -PskipServerTests
1223 from the top level directory to run all the tests in modules other than hbase-server.
1224 Note that you can specify to skip tests in multiple modules as well as just for a single module.
1225 For example, to skip the tests in `hbase-server` and `hbase-common`, you would run:
1229 mvn clean test -PskipServerTests -PskipCommonTests
1232 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.
1237 Apache HBase unit tests must carry a Category annotation and
1238 as of `hbase-2.0.0`, must be stamped with the HBase `ClassRule`.
1239 Here is an example of what a Test Class looks like with a
1240 Category and ClassRule included:
1245 @Category(SmallTests.class)
1246 public class TestHRegionInfo {
1248 public static final HBaseClassTestRule CLASS_RULE =
1249 HBaseClassTestRule.forClass(TestHRegionInfo.class);
1252 public void testCreateHRegionInfoName() throws Exception {
1257 Here the Test Class is `TestHRegionInfo`. The `CLASS_RULE` has
1258 the same form in every test class only the `.class` you pass
1259 is that of the local test; i.e. in the TestTimeout Test Class, you'd
1260 pass `TestTimeout.class` to the `CLASS_RULE` instead of the
1261 `TestHRegionInfo.class` we have above. The `CLASS_RULE`
1262 is where we'll enforce timeouts (currently set at a hard-limit of
1263 thirteen! minutes for all tests -- 780 seconds) and other cross-unit test facility.
1264 The test is in the `SmallTest` Category.
1266 Categories can be arbitrary and provided as a list but each test MUST
1267 carry one from the following list of sizings: `small`, `medium`, `large`, and
1268 `integration`. The test sizing is designated using the JUnit
1269 link:https://github.com/junit-team/junit4/wiki/Categories[categories]: `SmallTests`, `MediumTests`, `LargeTests`, `IntegrationTests`.
1270 JUnit Categories are denoted using java annotations (a special unit test looks
1271 for the presence of the @Category annotation in all unit tess and will fail if it
1272 finds a test suite missing a sizing marking).
1274 The first three categories, `small`, `medium`, and `large`, are for test cases which run when you
1276 In other words, these three categorizations are for HBase unit tests.
1277 The `integration` category is not for unit tests, but for integration tests.
1278 These are normally run when you invoke `$ mvn verify`.
1279 Integration tests are described in <<integration.tests,integration.tests>>.
1281 Keep reading to figure which annotation of the set `small`, `medium`, and `large`
1282 to put on your new HBase test case.
1285 Small Tests (((SmallTests)))::
1286 _Small_ test cases are executed in a shared JVM and each test suite/test class should
1287 run in 15 seconds or less; i.e. a link:https://en.wikipedia.org/wiki/JUnit[junit test fixture], a java object made
1288 up of test methods, should finish in under 15 seconds, no matter how many or how few test methods
1289 it has. These test cases should not use a minicluster as a minicluster starts many services,
1290 most unrelated to what is being tested. Multiple start/stops may leak resources or just overwhelm
1291 the single JVM context.
1293 Medium Tests (((MediumTests)))::
1294 _Medium_ test cases are executed in separate JVM and individual test suites or test classes or in
1295 junit parlance, link:https://en.wikipedia.org/wiki/JUnit[test fixture], should run in 50 seconds
1296 or less. These test cases can use a mini cluster. Since we start up a JVM per test fixture (and
1297 often a cluster too), be sure to make the startup pay by writing test fixtures that do a lot of
1298 testing running tens of seconds perhaps combining test rather than spin up a jvm (and cluster)
1299 per test method; this practice will help w/ overall test times.
1301 Large Tests (((LargeTests)))::
1302 _Large_ test cases are everything else. They are typically large-scale tests, regression tests
1303 for specific bugs, timeout tests, or performance tests. No large test suite can take longer than
1304 thirteen minutes. It will be killed as timed out. Cast your test as an Integration Test if it needs
1307 Integration Tests (((IntegrationTests)))::
1308 _Integration_ tests are system level tests.
1309 See <<integration.tests,integration.tests>> for more info.
1310 If you invoke `$ mvn test` on integration tests, there is no timeout for the test.
1312 [[hbase.unittests.cmds]]
1315 The state of tests on the hbase branches varies. Some branches keep good test hygiene and all tests pass
1316 reliably with perhaps an unlucky sporadic flakey test failure. On other branches, the case may be less so with
1317 frequent flakies and even broken tests in need of attention that fail 100% of the time. Try and figure
1318 the state of tests on the branch you are currently interested in; the current state of nightly
1319 link:https://builds.apache.org/view/H-L/view/HBase/job/HBase%20Nightly/[apache jenkins builds] is a good
1320 place to start. Tests on master branch are generally not in the best of condition as releases
1321 are less frequent off master. This can make it hard landing patches especially given our dictum that
1322 patches land on master branch first.
1324 The full test suite can take from 5-6 hours on an anemic VM with 4 CPUs and minimal
1325 parallelism to 50 minutes or less on a linux machine with dozens of CPUs and plenty of
1328 When you go to run the full test suite, make sure you up the test runner user nproc
1329 (`ulimit -u` -- make sure it > 6000 or more if more parallelism) and the number of
1330 open files (`ulimit -n` -- make sure it > 10240 or more) limits on your system.
1331 Errors because the test run hits
1332 limits are often only opaquely related to the constraint. You can see the current
1333 user settings by running `ulimit -a`.
1335 [[hbase.unittests.cmds.test]]
1336 ==== Default: small and medium category tests
1338 Running `mvn test` will execute all small tests in a single JVM (no fork) and then medium tests in a
1339 forked, separate JVM for each test instance (For definition of 'small' test and so on, see
1340 <<hbase.unittests>>). Medium tests are NOT executed if there is an error in a
1341 small test. Large tests are NOT executed.
1343 [[hbase.unittests.cmds.test.runalltests]]
1344 ==== Running all tests
1346 Running `mvn test -P runAllTests` will execute small tests in a single JVM, then medium and large tests
1347 in a forked, separate JVM for each test. Medium and large tests are NOT executed if there is an error in
1350 [[hbase.unittests.cmds.test.localtests.mytest]]
1351 ==== Running a single test or all tests in a package
1353 To run an individual test, e.g. `MyTest`, rum `mvn test -Dtest=MyTest` You can also pass multiple,
1354 individual tests as a comma-delimited list:
1357 mvn test -Dtest=MyTest1,MyTest2,MyTest3
1359 You can also pass a package, which will run all tests under the package:
1362 mvn test '-Dtest=org.apache.hadoop.hbase.client.*'
1365 When `-Dtest` is specified, the `localTests` profile will be used.
1366 Each junit test is executed in a separate JVM (A fork per test class).
1367 There is no parallelization when tests are running in this mode.
1368 You will see a new message at the end of the -report: `"[INFO] Tests are skipped"`.
1369 It's harmless. However, you need to make sure the sum of
1370 `Tests run:` in the `Results:` section of test reports matching the number of tests
1371 you specified because no error will be reported when a non-existent test case is specified.
1373 [[hbase.unittests.cmds.test.profiles]]
1374 ==== Other test invocation permutations
1376 Running `mvn test -P runSmallTests` will execute "small" tests only, using a single JVM.
1378 Running `mvn test -P runMediumTests` will execute "medium" tests only, launching a new JVM for each test-class.
1380 Running `mvn test -P runLargeTests` will execute "large" tests only, launching a new JVM for each test-class.
1382 For convenience, you can run `mvn test -P runDevTests` to execute both small and medium tests, using a single JVM.
1384 [[hbase.unittests.test.faster]]
1385 ==== Running tests faster
1387 By default, `$ mvn test -P runAllTests` runs all tests using a quarter of the CPUs available on machine
1388 hosting the test run (see `surefire.firstPartForkCount` and `surefire.secondPartForkCount` in the top-level
1389 hbase `pom.xml` which default to 0.25C, or 1/4 of CPU count). Up these counts to get the build to run faster.
1390 You can also have hbase modules
1391 run their tests in parrallel when the dependency graph allows by passing `--threads=N` when you invoke
1392 maven, where `N` is the amount of parallelism wanted.
1393 maven, where `N` is the amount of _module_ parallelism wanted.
1395 For example, allowing that you want to use all cores on a machine to run tests,
1396 you could start up the maven test run with:
1399 $ x="1.0C"; mvn -Dsurefire.firstPartForkCount=$x -Dsurefire.secondPartForkCount=$x test -PrunAllTests
1402 If a 32 core machine, you should see periods during which 32 forked jvms appear in your process listing each running unit tests.
1403 Your milage may vary. Dependent on hardware, overcommittment of CPU and/or memory can bring the test suite crashing down,
1404 usually complaining with a spew of test system exits and incomplete test report xml files. Start gently, with the default fork
1405 and move up gradually.
1407 Adding the `--threads=N`, maven will run N maven modules in parallel (when module inter-dependencies allow). Be aware, if you have
1408 set the forkcount to `1.0C`, and the `--threads` count to '2', the number of concurrent test runners can approach
1409 2 * CPU, a count likely to overcommit the host machine (with attendant test exits failures).
1411 You will need ~2.2GB of memory per forked JVM plus the memory used by maven itself (3-4G).
1415 To increase the speed, you can as well use a ramdisk. 2-3G should be sufficient. Be sure to
1416 delete the files between each test run. The typical way to configure a ramdisk on Linux is:
1420 sudo mount -t tmpfs -o size=2048M tmpfs /ram2G
1423 You can then use it to run all HBase tests on 2.0 with the command:
1426 mvn test -PrunAllTests -Dtest.build.data.basedirectory=/ram2G
1429 [[hbase.unittests.cmds.test.hbasetests]]
1430 ==== +hbasetests.sh+
1432 It's also possible to use the script +hbasetests.sh+.
1433 This script runs the medium and large tests in parallel with two maven instances, and provides a single report.
1434 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.
1435 It must be executed from the directory which contains the _pom.xml_.
1437 For example running +./dev-support/hbasetests.sh+ will execute small and medium tests.
1438 Running +./dev-support/hbasetests.sh
1439 runAllTests+ will execute all tests.
1440 Running +./dev-support/hbasetests.sh replayFailed+ will rerun the failed tests a second time, in a separate jvm and without parallelisation.
1442 [[hbase.unittests.timeouts]]
1443 ==== Test Timeouts(((Test Timeouts)))
1444 The HBase unit test sizing Categorization timeouts are not strictly enforced.
1446 Any test that runs longer than ten minutes will be timedout/killed.
1448 As of hbase-2.0.0, we have purged all per-test-method timeouts: i.e.
1452 @Test(timeout=30000)
1453 public void testCreateHRegionInfoName() throws Exception {
1457 They are discouraged and don't make much sense given we are timing
1458 base of how long the whole Test Fixture/Class/Suite takes and
1459 that the variance in how long a test method takes varies wildly
1460 dependent upon context (loaded Apache Infrastructure versus
1461 developer machine with nothing else running on it).
1465 [[hbase.unittests.resource.checker]]
1466 ==== Test Resource Checker(((Test ResourceChecker)))
1468 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.
1469 Check the _*-out.txt_ files). The resources counted are the number of threads, the number of file descriptors, etc.
1470 If the number has increased, it adds a _LEAK?_ comment in the logs.
1471 As you can have an HBase instance running in the background, some threads can be deleted/created without any specific action in the test.
1472 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...+.
1476 2012-09-26 09:22:15,315 INFO [pool-1-thread-1]
1477 hbase.ResourceChecker(157): after:
1478 regionserver.TestColumnSeeking#testReseeking Thread=65 (was 65),
1479 OpenFileDescriptor=107 (was 107), MaxFileDescriptor=10240 (was 10240),
1480 ConnectionCount=1 (was 1)
1483 [[hbase.tests.writing]]
1486 [[hbase.tests.rules]]
1489 * As much as possible, tests should be written as category small tests.
1490 * 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.
1491 * Tests should not overlog.
1492 More than 100 lines/second makes the logs complex to read and use i/o that are hence not available for the other tests.
1493 * Tests can be written with `HBaseTestingUtility`.
1494 This class offers helper functions to create a temp directory and do the cleanup, or to start a cluster.
1496 [[hbase.tests.categories]]
1497 ==== Categories and execution time
1499 * All tests must be categorized, if not they could be skipped.
1500 * All tests should be written to be as fast as possible.
1501 * See <<hbase.unittests,hbase.unittests>> for test case categories and corresponding timeouts.
1502 This should ensure a good parallelization for people using it, and ease the analysis when the test fails.
1504 [[hbase.tests.sleeps]]
1505 ==== Sleeps in tests
1507 Whenever possible, tests should not use [method]+Thread.sleep+, but rather waiting for the real event they need.
1508 This is faster and clearer for the reader.
1509 Tests should not do a [method]+Thread.sleep+ without testing an ending condition.
1510 This allows understanding what the test is waiting for.
1511 Moreover, the test will work whatever the machine performance is.
1512 Sleep should be minimal to be as fast as possible.
1513 Waiting for a variable should be done in a 40ms sleep loop.
1514 Waiting for a socket operation should be done in a 200 ms sleep loop.
1516 [[hbase.tests.cluster]]
1517 ==== Tests using a cluster
1519 Tests using a HRegion do not have to start a cluster: A region can use the local file system.
1520 Start/stopping a cluster cost around 10 seconds.
1521 They should not be started per test method but per test class.
1522 Started cluster must be shutdown using [method]+HBaseTestingUtility#shutdownMiniCluster+, which cleans the directories.
1523 As most as possible, tests should use the default settings for the cluster.
1524 When they don't, they should document it.
1525 This will allow to share the cluster later.
1527 [[hbase.tests.example.code]]
1528 ==== Tests Skeleton Code
1530 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.
1534 * Describe what this testcase tests. Talk about resources initialized in @BeforeClass (before
1535 * any test is run) and before each test is run, etc.
1537 // Specify the category as explained in <<hbase.unittests,hbase.unittests>>.
1538 @Category(SmallTests.class)
1539 public class TestExample {
1540 // Replace the TestExample.class in the below with the name of your test fixture class.
1541 private static final Log LOG = LogFactory.getLog(TestExample.class);
1543 // Handy test rule that allows you subsequently get the name of the current method. See
1544 // down in 'testExampleFoo()' where we use it to log current test's name.
1545 @Rule public TestName testName = new TestName();
1547 // The below rule does two things. It decides the timeout based on the category
1548 // (small/medium/large) of the testcase. This @Rule requires that the full testcase runs
1549 // within this timeout irrespective of individual test methods' times. The second
1550 // feature is we'll dump in the log when the test is done a count of threads still
1552 @Rule public static TestRule timeout = CategoryBasedTimeout.builder().
1553 withTimeout(this.getClass()).withLookingForStuckThread(true).build();
1556 public void setUp() throws Exception {
1560 public void tearDown() throws Exception {
1564 public void testExampleFoo() {
1565 LOG.info("Running test " + testName.getMethodName());
1570 [[integration.tests]]
1571 === Integration Tests
1573 HBase integration/system tests are tests that are beyond HBase unit tests.
1574 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.
1575 Integration tests are what you would run when you need to more elaborate proofing of a release candidate beyond what unit tests can do.
1576 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.
1578 Integration tests currently live under the _src/test_ directory in the hbase-it submodule and will match the regex: _**/IntegrationTest*.java_.
1579 All integration tests are also annotated with `@Category(IntegrationTests.class)`.
1581 Integration tests can be run in two modes: using a mini cluster, or against an actual distributed cluster.
1582 Maven failsafe is used to run the tests using the mini cluster.
1583 IntegrationTestsDriver class is used for executing the tests against a distributed cluster.
1584 Integration tests SHOULD NOT assume that they are running against a mini cluster, and SHOULD NOT use private API's to access cluster state.
1585 To interact with the distributed or mini cluster uniformly, `IntegrationTestingUtility`, and `HBaseCluster` classes, and public client API's can be used.
1587 On a distributed cluster, integration tests that use ChaosMonkey or otherwise manipulate services thru cluster manager (e.g.
1588 restart regionservers) use SSH to do it.
1589 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.
1590 "User" is the remote user that cluster manager should use to perform ssh commands.
1591 "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.
1592 The default string is {`/usr/bin/ssh %1$s %2$s%3$s%4$s "%5$s"`} and is a good starting point.
1593 This is a standard Java format string with 5 arguments that is used to execute the remote command.
1594 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:
1597 /usr/bin/ssh %1$s %2$s%3$s%4$s "su hbase - -c \"%5$s\""
1599 That way, to kill RS (for example) integration tests may run:
1602 {/usr/bin/ssh some-hostname "su hbase - -c \"ps aux | ... | kill ...\""}
1604 The command is logged in the test logs, so you can verify it is correct for your environment.
1606 To disable the running of Integration Tests, pass the following profile on the command line `-PskipIntegrationTests`.
1610 $ mvn clean install test -Dtest=TestZooKeeper -PskipIntegrationTests
1613 [[maven.build.commands.integration.tests.mini]]
1614 ==== Running integration tests against mini cluster
1616 HBase 0.92 added a `verify` maven target.
1617 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
1618 plugin], running all the above mentioned HBase unit tests as well as tests that are in the HBase integration test group.
1619 After you have completed +mvn install -DskipTests+ You can run just the integration tests by invoking:
1628 If you just want to run the integration tests in top-level, you need to run two commands.
1631 mvn failsafe:integration-test
1634 This actually runs ALL the integration tests.
1636 NOTE: This command will always output `BUILD SUCCESS` even if there are test failures.
1638 At this point, you could grep the output by hand looking for failed tests.
1639 However, maven will do this for us; just use:
1644 The above command basically looks at all the test results (so don't remove the 'target' directory) for test failures and reports the results.
1646 [[maven.build.commands.integration.tests2]]
1647 ===== Running a subset of Integration tests
1649 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`.
1650 To just run `IntegrationTestClassXYZ.java`, use:
1652 mvn failsafe:integration-test -Dit.test=IntegrationTestClassXYZ -DfailIfNoTests=false
1654 The next thing you might want to do is run groups of integration tests, say all integration tests that are named IntegrationTestClassX*.java:
1656 mvn failsafe:integration-test -Dit.test=*ClassX* -DfailIfNoTests=false
1659 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:
1661 mvn failsafe:integration-test -Dit.test=*ClassX*,*ClassY -DfailIfNoTests=false
1664 [[maven.build.commands.integration.tests.distributed]]
1665 ==== Running integration tests against distributed cluster
1667 If you have an already-setup HBase cluster, you can launch the integration tests by invoking the class `IntegrationTestsDriver`.
1668 You may have to run test-compile first.
1669 The configuration will be picked by the bin/hbase script.
1674 Then launch the tests with:
1678 bin/hbase [--config config_dir] org.apache.hadoop.hbase.IntegrationTestsDriver
1681 Pass `-h` to get usage on this sweet tool.
1682 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`.
1683 See the usage, by passing -h, to see how to filter test classes.
1684 You can pass a regex which is checked against the full class name; so, part of class name can be used.
1685 IntegrationTestsDriver uses Junit to run the tests.
1686 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]).
1688 The tests interact with the distributed cluster by using the methods in the `DistributedHBaseCluster` (implementing `HBaseCluster`) class, which in turn uses a pluggable `ClusterManager`.
1689 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.
1690 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.
1691 Currently tarball deployments, deployments which uses _hbase-daemons.sh_, and link:https://incubator.apache.org/ambari/[Apache Ambari] deployments are supported.
1692 _/etc/init.d/_ scripts are not supported for now, but it can be easily added.
1693 For other deployment options, a ClusterManager can be implemented and plugged in.
1695 [[maven.build.commands.integration.tests.destructive]]
1696 ==== Destructive integration / system tests (ChaosMonkey)
1698 HBase 0.96 introduced a tool named `ChaosMonkey`, modeled after
1699 link:https://netflix.github.io/chaosmonkey/[same-named tool by Netflix's Chaos Monkey tool].
1700 ChaosMonkey simulates real-world
1701 faults in a running cluster by killing or disconnecting random servers, or injecting
1702 other failures into the environment. You can use ChaosMonkey as a stand-alone tool
1703 to run a policy while other tests are running. In some environments, ChaosMonkey is
1704 always running, in order to constantly check that high availability and fault tolerance
1705 are working as expected.
1707 ChaosMonkey defines *Actions* and *Policies*.
1709 Actions:: Actions are predefined sequences of events, such as the following:
1711 * Restart active master (sleep 5 sec)
1712 * Restart random regionserver (sleep 5 sec)
1713 * Restart random regionserver (sleep 60 sec)
1714 * Restart META regionserver (sleep 5 sec)
1715 * Restart ROOT regionserver (sleep 5 sec)
1716 * Batch restart of 50% of regionservers (sleep 5 sec)
1717 * Rolling restart of 100% of regionservers (sleep 5 sec)
1719 Policies:: A policy is a strategy for executing one or more actions. The default policy
1720 executes a random action every minute based on predefined action weights.
1721 A given policy will be executed until ChaosMonkey is interrupted.
1723 Most ChaosMonkey actions are configured to have reasonable defaults, so you can run
1724 ChaosMonkey against an existing cluster without any additional configuration. The
1725 following example runs ChaosMonkey with the default configuration:
1729 $ bin/hbase org.apache.hadoop.hbase.util.ChaosMonkey
1731 12/11/19 23:21:57 INFO util.ChaosMonkey: Using ChaosMonkey Policy: class org.apache.hadoop.hbase.util.ChaosMonkey$PeriodicRandomActionPolicy, period:60000
1732 12/11/19 23:21:57 INFO util.ChaosMonkey: Sleeping for 26953 to add jitter
1733 12/11/19 23:22:24 INFO util.ChaosMonkey: Performing action: Restart active master
1734 12/11/19 23:22:24 INFO util.ChaosMonkey: Killing master:master.example.com,60000,1353367210440
1735 12/11/19 23:22:24 INFO hbase.HBaseCluster: Aborting Master: master.example.com,60000,1353367210440
1736 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
1737 12/11/19 23:22:25 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:
1738 12/11/19 23:22:25 INFO hbase.HBaseCluster: Waiting service:master to stop: master.example.com,60000,1353367210440
1739 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
1740 12/11/19 23:22:25 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:
1741 12/11/19 23:22:25 INFO util.ChaosMonkey: Killed master server:master.example.com,60000,1353367210440
1742 12/11/19 23:22:25 INFO util.ChaosMonkey: Sleeping for:5000
1743 12/11/19 23:22:30 INFO util.ChaosMonkey: Starting master:master.example.com
1744 12/11/19 23:22:30 INFO hbase.HBaseCluster: Starting Master on: master.example.com
1745 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
1746 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
1748 12/11/19 23:22:33 INFO util.ChaosMonkey: Started master: master.example.com,60000,1353367210440
1749 12/11/19 23:22:33 INFO util.ChaosMonkey: Sleeping for:51321
1750 12/11/19 23:23:24 INFO util.ChaosMonkey: Performing action: Restart random region server
1751 12/11/19 23:23:24 INFO util.ChaosMonkey: Killing region server:rs3.example.com,60020,1353367027826
1752 12/11/19 23:23:24 INFO hbase.HBaseCluster: Aborting RS: rs3.example.com,60020,1353367027826
1753 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
1754 12/11/19 23:23:25 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:
1755 12/11/19 23:23:25 INFO hbase.HBaseCluster: Waiting service:regionserver to stop: rs3.example.com,60020,1353367027826
1756 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
1757 12/11/19 23:23:25 INFO hbase.ClusterManager: Executed remote command, exit code:0 , output:
1758 12/11/19 23:23:25 INFO util.ChaosMonkey: Killed region server:rs3.example.com,60020,1353367027826. Reported num of rs:6
1759 12/11/19 23:23:25 INFO util.ChaosMonkey: Sleeping for:60000
1760 12/11/19 23:24:25 INFO util.ChaosMonkey: Starting region server:rs3.example.com
1761 12/11/19 23:24:25 INFO hbase.HBaseCluster: Starting RS on: rs3.example.com
1762 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
1763 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
1765 12/11/19 23:24:27 INFO util.ChaosMonkey: Started region server:rs3.example.com,60020,1353367027826. Reported num of rs:6
1768 The output indicates that ChaosMonkey started the default `PeriodicRandomActionPolicy`
1769 policy, which is configured with all the available actions. It chose to run `RestartActiveMaster` and `RestartRandomRs` actions.
1771 ==== Available Policies
1772 HBase ships with several ChaosMonkey policies, available in the
1773 `hbase/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/policies/` directory.
1775 [[chaos.monkey.properties]]
1776 ==== Configuring Individual ChaosMonkey Actions
1778 ChaosMonkey integration tests can be configured per test run.
1779 Create a Java properties file in the HBase CLASSPATH and pass it to ChaosMonkey using
1780 the `-monkeyProps` configuration flag. Configurable properties, along with their default
1781 values if applicable, are listed in the `org.apache.hadoop.hbase.chaos.factories.MonkeyConstants`
1782 class. For properties that have defaults, you can override them by including them
1783 in your properties file.
1785 The following example uses a properties file called <<monkey.properties,monkey.properties>>.
1789 $ bin/hbase org.apache.hadoop.hbase.IntegrationTestIngest -m slowDeterministic -monkeyProps monkey.properties
1792 The above command will start the integration tests and chaos monkey. It will look for the
1793 properties file _monkey.properties_ on the HBase CLASSPATH; e.g. inside the HBASE _conf_ dir.
1795 Here is an example chaos monkey file:
1797 [[monkey.properties]]
1798 .Example ChaosMonkey Properties File
1801 sdm.action1.period=120000
1802 sdm.action2.period=40000
1803 move.regions.sleep.time=80000
1804 move.regions.max.time=1000000
1805 move.regions.sleep.time=80000
1806 batch.restart.rs.ratio=0.4f
1809 Periods/time are expressed in milliseconds.
1811 HBase 1.0.2 and newer adds the ability to restart HBase's underlying ZooKeeper quorum or
1812 HDFS nodes. To use these actions, you need to configure some new properties, which
1813 have no reasonable defaults because they are deployment-specific, in your ChaosMonkey
1814 properties file, which may be `hbase-site.xml` or a different properties file.
1819 <name>hbase.it.clustermanager.hadoop.home</name>
1820 <value>$HADOOP_HOME</value>
1823 <name>hbase.it.clustermanager.zookeeper.home</name>
1824 <value>$ZOOKEEPER_HOME</value>
1827 <name>hbase.it.clustermanager.hbase.user</name>
1828 <value>hbase</value>
1831 <name>hbase.it.clustermanager.hadoop.hdfs.user</name>
1835 <name>hbase.it.clustermanager.zookeeper.user</name>
1836 <value>zookeeper</value>
1840 ==== Customizing Destructive ChaosMonkey Actions
1842 The session above shows how to setup custom configurations for the _slowDeterministic_ monkey
1843 policy. This is a policy that pre-defines a set of destructive actions of varying gravity for a
1844 running cluster. These actions are grouped into three categories: _light weight_, _mid weight_ and
1845 _heavy weight_. Although it's possible to define some properties for the different actions
1846 (such as timeouts, frequency, etc), the actions themselves are not configurable.
1848 For certain deployments, it may be interesting to define its own test strategy, either less or more
1849 aggressive than the pre-defined set of actions provided by _slowDeterministic_. For such cases,
1850 the _configurableSlowDeterministic_ policy can be used. It allows for a customizable set of
1851 _heavy weight_ actions to be defined in the _monkey.properties_ properties file:
1855 batch.restart.rs.ratio=0.3f
1856 heavy.actions=RestartRandomRsAction(500000);MoveRandomRegionOfTableAction(360000,$table_name);SplitAllRegionOfTableAction($table_name)
1859 The above properties file definition instructs chaos monkey to perform a RegionServer crash every 8 minutes,
1860 a random region move every 6 minutes, and at least one split of all table regions.
1862 To run this policy, just specify _configurableSlowDeterministic_ as the monkey policy to run, together
1863 with a property file containing the _heavy.actions_ property definition:
1867 $ bin/hbase org.apache.hadoop.hbase.IntegrationTestIngest -m configurableSlowDeterministic -monkeyProps monkey.properties
1870 When specifying monkey actions, make sure to define all required constructor parameters. For actions
1871 that require a table name parameter, the _$table_name_ placeholder can be specified, and it will
1872 automatically resort to the table created by the integration test run.
1874 If _heavy.actions_ property is omitted in the properties file, _configurableSlowDeterministic_ will
1875 just run as the _slowDeterministic_ policy
1876 (it will execute all the heavy weight actions defined by _slowDeterministic_ policy).
1881 == Developer Guidelines
1885 We use Git for source code management and latest development happens on `master` branch. There are
1886 branches for past major/minor/maintenance releases and important features and bug fixes are often
1887 back-ported to them.
1889 === Policy for Fix Version in JIRA
1891 To determine if a given fix is in a given release purely from the release numbers following rules
1894 Fix version of X.Y.Z => fixed in all releases X.Y.Z' (where Z' = Z). +
1895 Fix version of X.Y.0 => fixed in all releases X.Y'.* (where Y' = Y). +
1896 Fix version of X.0.0 => fixed in all releases X'.\*.* (where X' = X). +
1898 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
1899 tell purely from the numbers which release came first.
1905 ==== Interface Classifications
1907 Interfaces are classified both by audience and by stability level.
1908 These labels appear at the head of a class.
1909 The conventions followed by HBase are inherited by its parent project, Hadoop.
1911 The following interface classifications are commonly used:
1914 `@InterfaceAudience.Public`::
1915 APIs for users and HBase applications.
1916 These APIs will be deprecated through major versions of HBase.
1918 `@InterfaceAudience.Private`::
1919 APIs for HBase internals developers.
1920 No guarantees on compatibility or availability in future versions.
1921 Private interfaces do not need an `@InterfaceStability` classification.
1923 `@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)`::
1924 APIs for HBase coprocessor writers.
1926 No `@InterfaceAudience` Classification::
1927 Packages without an `@InterfaceAudience` label are considered private.
1928 Mark your new packages if publicly accessible.
1930 .Excluding Non-Public Interfaces from API Documentation
1933 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.
1936 .@InterfaceStability
1937 `@InterfaceStability` is important for packages marked `@InterfaceAudience.Public`.
1939 `@InterfaceStability.Stable`::
1940 Public packages marked as stable cannot be changed without a deprecation path or a very good reason.
1942 `@InterfaceStability.Unstable`::
1943 Public packages marked as unstable can be changed without a deprecation path.
1945 `@InterfaceStability.Evolving`::
1946 Public packages marked as evolving may be changed, but it is discouraged.
1948 No `@InterfaceStability` Label::
1949 Public classes with no `@InterfaceStability` label are discouraged, and should be considered implicitly unstable.
1951 If you are unclear about how to mark packages, ask on the development list.
1953 [[common.patch.feedback]]
1954 ==== Code Formatting Conventions
1956 Please adhere to the following guidelines so that your patches can be reviewed more quickly.
1957 These guidelines have been developed based upon common feedback on patches from new contributors.
1959 See the link:http://www.oracle.com/technetwork/java/index-135089.html[Code
1960 Conventions for the Java Programming Language] for more information on coding conventions in Java.
1961 See <<eclipse.code.formatting,eclipse.code.formatting>> to setup Eclipse to check for some of
1962 these guidelines automatically.
1964 [[common.patch.feedback.space.invaders]]
1965 ===== Space Invaders
1967 Do not use extra spaces around brackets.
1968 Use the second style, rather than the first.
1973 if ( foo.equals( bar ) ) { // don't do this
1979 if (foo.equals(bar)) {
1985 foo = barArray[ i ]; // don't do this
1994 [[common.patch.feedback.autogen]]
1995 ===== Auto Generated Code
1997 Auto-generated code in Eclipse often uses bad variable names such as `arg0`.
1998 Use more informative variable names.
1999 Use code like the second example here.
2004 public void readFields(DataInput arg0) throws IOException { // don't do this
2005 foo = arg0.readUTF(); // don't do this
2011 public void readFields(DataInput di) throws IOException {
2015 [[common.patch.feedback.longlines]]
2018 Keep lines less than 100 characters.
2019 You can configure your IDE to do this automatically.
2024 Bar bar = foo.veryLongMethodWithManyArguments(argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8, argument9); // don't do this
2030 Bar bar = foo.veryLongMethodWithManyArguments(
2031 argument1, argument2, argument3,argument4, argument5, argument6, argument7, argument8, argument9);
2034 [[common.patch.feedback.trailingspaces]]
2035 ===== Trailing Spaces
2037 Be sure there is a line break after the end of your code, and avoid lines with nothing but whitespace.
2038 This makes diffs more meaningful.
2039 You can configure your IDE to help with this.
2044 Bar bar = foo.getBar(); <--- imagine there is an extra space(s) after the semicolon.
2047 [[common.patch.feedback.javadoc]]
2048 ===== API Documentation (Javadoc)
2050 Don't forget Javadoc!
2052 Javadoc warnings are checked during precommit.
2053 If the precommit tool gives you a '-1', please fix the javadoc issue.
2054 Your patch won't be committed if it adds such warnings.
2056 Also, no `@author` tags - that's a rule.
2058 [[common.patch.feedback.findbugs]]
2061 `Findbugs` is used to detect common bugs pattern.
2062 It is checked during the precommit build.
2063 If errors are found, please fix them.
2064 You can run findbugs locally with `mvn
2065 findbugs:findbugs`, which will generate the `findbugs` files locally.
2066 Sometimes, you may have to write code smarter than `findbugs`.
2067 You can annotate your code to tell `findbugs` you know what you're doing, by annotating your class with the following annotation:
2071 @edu.umd.cs.findbugs.annotations.SuppressWarnings(
2072 value="HE_EQUALS_USE_HASHCODE",
2073 justification="I know what I'm doing")
2076 It is important to use the Apache-licensed version of the annotations. That generally means using
2077 annotations in the `edu.umd.cs.findbugs.annotations` package so that we can rely on the cleanroom
2078 reimplementation rather than annotations in the `javax.annotations` package.
2080 [[common.patch.feedback.javadoc.defaults]]
2081 ===== Javadoc - Useless Defaults
2083 Don't just leave javadoc tags the way IDE generates them, or fill redundant information in them.
2089 * @param table <---- don't leave them empty!
2090 * @param region An HRegion object. <---- don't fill redundant information!
2091 * @return Foo Object foo just created. <---- Not useful information
2092 * @throws SomeException <---- Not useful. Function declarations already tell that!
2093 * @throws BarException when something went wrong <---- really?
2095 public Foo createFoo(Bar bar);
2098 Either add something descriptive to the tags, or just remove them.
2099 The preference is to add something descriptive and useful.
2101 [[common.patch.feedback.onething]]
2102 ===== One Thing At A Time, Folks
2104 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.
2106 Likewise, don't add unrelated cleanup or refactorings outside the scope of your Jira.
2108 [[common.patch.feedback.tests]]
2109 ===== Ambiguous Unit Tests
2111 Make sure that you're clear about what you are testing in your unit tests and why.
2113 ==== Garbage-Collection Conserving Guidelines
2115 The following guidelines were borrowed from http://engineering.linkedin.com/performance/linkedin-feed-faster-less-jvm-garbage.
2116 Keep them in mind to keep preventable garbage collection to a minimum. Have a look
2117 at the blog post for some great examples of how to refactor your code according to
2120 - Be careful with Iterators
2121 - Estimate the size of a collection when initializing
2122 - Defer expression evaluation
2123 - Compile the regex patterns in advance
2124 - Cache it if you can
2125 - String Interns are useful but dangerous
2127 [[design.invariants]]
2130 We don't have many but what we have we list below.
2131 All are subject to challenge of course but until then, please hold to the rules of the road.
2133 [[design.invariants.zk.data]]
2134 ==== No permanent state in ZooKeeper
2136 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.
2138 * .Exceptions: There are currently a few exceptions that we need to fix around whether a table is enabled or disabled.
2139 * Replication data is currently stored only in ZooKeeper.
2140 Deleting ZooKeeper data related to replication may cause replication to be disabled.
2141 Do not delete the replication tree, _/hbase/replication/_.
2143 WARNING: Replication may be disrupted and data loss may occur if you delete the replication tree (_/hbase/replication/_) from ZooKeeper.
2144 Follow progress on this issue at link:https://issues.apache.org/jira/browse/HBASE-10295[HBASE-10295].
2150 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.
2151 In this case, HBase can be run directly from the source in local-mode.
2152 All you need to do is run:
2156 ${HBASE_HOME}/bin/start-hbase.sh
2159 This will spin up a full local-cluster, just as if you had packaged up HBase and installed it on your machine.
2161 Keep in mind that you will need to have installed HBase into your local maven repository for the in-situ cluster to work properly.
2162 That is, you will need to run:
2166 mvn clean install -DskipTests
2169 to ensure that maven can find the correct classpath and dependencies.
2170 Generally, the above command is just a good thing to try running first, if maven is acting oddly.
2175 After adding a new feature a developer might want to add metrics.
2176 HBase exposes metrics using the Hadoop Metrics 2 system, so adding a new metric involves exposing that metric to the hadoop system.
2177 Unfortunately the API of metrics2 changed from hadoop 1 to hadoop 2.
2178 In order to get around this a set of interfaces and implementations have to be loaded at runtime.
2179 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].
2180 To add a metric to an existing MBean follow the short guide below:
2182 ==== Add Metric name and Function to Hadoop Compat Interface.
2184 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.
2185 Then add a new method that will be called to add new reading.
2187 ==== Add the Implementation to Both Hadoop 1 and Hadoop 2 Compat modules.
2189 Inside of the implementation of the source (eg.
2190 MetricsMasterSourceImpl in the above example) create a new histogram, counter, gauge, or stat in the init method.
2191 Then in the method that was added to the interface wire up the parameter passed in to the histogram.
2193 Now add tests that make sure the data is correctly exported to the metrics 2 system.
2194 For this the MetricsAssertHelper is provided.
2196 [[git.best.practices]]
2197 === Git Best Practices
2200 Use `git pull --rebase` or `git fetch` followed by `git rebase`.
2201 Do not use `git push --force`.::
2202 If the push does not work, fix the problem or ask for help.
2204 Please contribute to this document if you think of other Git best practices.
2206 ==== `rebase_all_git_branches.sh`
2208 The _dev-support/rebase_all_git_branches.sh_ script is provided to help keep your Git repository clean.
2209 Use the `-h` parameter to get usage instructions.
2210 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.
2211 The script has one optional configuration option, the location of your Git directory.
2212 You can set a default by editing the script.
2213 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.
2214 The script checks the directory for sub-directory called _.git/_, before proceeding.
2216 [[submitting.patches]]
2217 === Submitting Patches
2219 If you are new to submitting patches to open source or new to submitting patches to Apache, start by
2220 reading the link:https://commons.apache.org/patches.html[On Contributing Patches] page from
2221 link:https://commons.apache.org/[Apache Commons Project].
2222 It provides a nice overview that applies equally to the Apache HBase Project.
2224 [[submitting.patches.create]]
2227 Make sure you review <<common.patch.feedback,common.patch.feedback>> for code style. If your
2229 was generated incorrectly or your code does not adhere to the code formatting guidelines, you may
2230 be asked to redo some work.
2233 .Using submit-patch.py (recommended)
2237 $ dev-support/submit-patch.py -jid HBASE-xxxxx
2240 Use this script to create patches, upload to jira and optionally create/update reviews on
2241 Review Board. Patch name is automatically formatted as _(JIRA).(branch name).(patch number).patch_
2242 to follow Yetus' naming rules. Use `-h` flag to know detailed usage information. Most useful options
2245 * `-b BRANCH, --branch BRANCH` : Specify base branch for generating the diff. If not specified,
2246 tracking branch is used. If there is no tracking branch, error will be thrown.
2247 * `-jid JIRA_ID, --jira-id JIRA_ID` : If used, deduces next patch version from attachments in the
2248 jira and uploads the new patch. Script will ask for jira username/password for authentication.
2249 If not set, patch is named <branch>.patch.
2251 By default, it'll also create/update review board. To skip that action, use `-srb` option. It uses
2252 'Issue Links' in the jira to figure out if a review request already exists. If no review
2253 request is present, then creates a new one and populates all required fields using jira summary,
2254 patch description, etc. Also adds this review's link to the jira.
2256 Save authentication credentials (optional)::
2257 Since attaching patches on JIRA and creating/changing review request on ReviewBoard requires
2258 valid user authentication, the script will prompt you for username and password. To avoid the hassle every
2259 time, set up `~/.apache-creds` with login details and encrypt it by following the steps in footer
2260 of script's help message.
2262 Python dependencies:: To install required python dependencies, execute
2263 `pip install -r dev-support/python-requirements.txt` from the master branch.
2267 . Use `git rebase -i` first, to combine (squash) smaller commits into a single larger one.
2268 . Create patch using IDE or Git commands. `git format-patch` is preferred since it preserves patch
2269 author's name and commit message. Also, it handles binary files by default, whereas `git diff`
2270 ignores them unless you use the `--binary` option.
2271 . Patch name should be as follows to adhere to Yetus' naming convention: +
2272 `(JIRA).(branch name).(patch number).patch` +
2273 For eg. HBASE-11625.master.001.patch, HBASE-XXXXX.branch-1.2.0005.patch, etc.
2274 . Attach the patch to the JIRA using `More->Attach Files` then click on btn:[Submit Patch]
2275 button, which'll trigger Hudson job to check patch for validity.
2276 . If your patch is longer than a single screen, also create a review on Review Board and
2277 add the link to JIRA. See <<reviewboard,reviewboard>>.
2281 .Few general guidelines
2282 * Always patch against the master branch first, even if you want to patch in another branch.
2283 HBase committers always apply patches first to the master branch, and backport if necessary.
2284 * Submit one single patch for a fix. If necessary, squash local commits to merge local commits into
2285 a single one first. See this
2286 link:http://stackoverflow.com/questions/5308816/how-to-use-git-merge-squash[Stack Overflow
2287 question] for more information about squashing commits.
2288 * Please understand that not every patch may get committed, and that feedback will likely be
2289 provided on the patch.
2290 * If you need to revise your patch, leave the previous patch file(s) attached to the JIRA, and
2291 upload a new one with incremented patch number. +
2292 Click on btn:[Cancel Patch] and then on btn:[Submit Patch] to trigger the presubmit run.
2294 [[submitting.patches.tests]]
2296 Always add and/or update relevant unit tests when making the changes.
2297 Make sure that new/changed unit tests pass locally before submitting the patch because it is faster
2298 than waiting for presubmit result which runs full test suite. This will save your own time and
2300 Use <<mockito,mockito>> to make mocks which are very useful for testing failure scenarios by
2301 injecting appropriate failures.
2303 If you are creating a new unit test class, notice how other unit test classes have
2304 classification/sizing annotations before class name and a static methods for setup/teardown of
2305 testing environment. Be sure to include annotations in any new unit test files.
2306 See <<hbase.tests,hbase.tests>> for more information on tests.
2308 ==== Integration Tests
2310 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.
2315 Patches larger than one screen, or patches that will be tricky to review, should go through link:https://reviews.apache.org[ReviewBoard].
2317 .Procedure: Use ReviewBoard
2318 . Register for an account if you don't already have one.
2319 It does not use the credentials from link:https://issues.apache.org[issues.apache.org].
2321 . Click [label]#New Review Request#.
2322 . Choose the `hbase-git` repository.
2323 Click Choose File to select the diff and optionally a parent diff.
2326 . Fill in the fields as required.
2327 At the minimum, fill in the [label]#Summary# and choose `hbase` as the [label]#Review Group#.
2328 If you fill in the [label]#Bugs# field, the review board links back to the relevant JIRA.
2329 The more fields you fill in, the better.
2330 Click btn:[Publish] to make your review request public.
2331 An email will be sent to everyone in the `hbase` group, to review the patch.
2332 . Back in your JIRA, click , and paste in the URL of your ReviewBoard request.
2333 This attaches the ReviewBoard to the JIRA, for easy access.
2334 . To cancel the request, click .
2336 For more information on how to use ReviewBoard, see link:http://www.reviewboard.org/docs/manual/1.5/[the ReviewBoard
2341 Submitting link:https://github.com/apache/hbase[GitHub] pull requests is another accepted form of
2342 contributing patches. Refer to GitHub link:https://help.github.com/[documentation] for details on
2343 how to create pull requests.
2345 NOTE: This section is incomplete and needs to be updated. Refer to
2346 link:https://issues.apache.org/jira/browse/HBASE-23557[HBASE-23557]
2348 ===== GitHub Tooling
2350 ====== Browser bookmarks
2352 Following is a useful javascript based browser bookmark that redirects from GitHub pull
2353 requests to the corresponding jira work item. This redirects based on the HBase jira ID mentioned
2354 in the issue title for the PR. Add the following javascript snippet as a browser bookmark to the
2355 tool bar. Clicking on it while you are on an HBase GitHub PR page redirects you to the corresponding
2358 [source, javascript]
2360 javascript:location.href='https://issues.apache.org/jira/browse/'+document.getElementsByClassName("js-issue-title")[0].innerHTML.match(/HBASE-\d+/)[0];
2363 ==== Guide for HBase Committers
2365 ===== Becoming a committer
2367 Committers are responsible for reviewing and integrating code changes, testing
2368 and voting on release candidates, weighing in on design discussions, as well as
2369 other types of project contributions. The PMC votes to make a contributor a
2370 committer based on an assessment of their contributions to the project. It is
2371 expected that committers demonstrate a sustained history of high-quality
2372 contributions to the project and community involvement.
2374 Contributions can be made in many ways. There is no single path to becoming a
2375 committer, nor any expected timeline. Submitting features, improvements, and bug
2376 fixes is the most common avenue, but other methods are both recognized and
2377 encouraged (and may be even more important to the health of HBase as a project and a
2378 community). A non-exhaustive list of potential contributions (in no particular
2381 * <<appendix_contributing_to_documentation,Update the documentation>> for new
2382 changes, best practices, recipes, and other improvements.
2383 * Keep the website up to date.
2384 * Perform testing and report the results. For instance, scale testing and
2385 testing non-standard configurations is always appreciated.
2386 * Maintain the shared Jenkins testing environment and other testing
2388 * <<hbase.rc.voting,Vote on release candidates>> after performing validation, even if non-binding.
2389 A non-binding vote is a vote by a non-committer.
2390 * Provide input for discussion threads on the link:/mail-lists.html[mailing lists] (which usually have
2391 `[DISCUSS]` in the subject line).
2392 * Answer questions questions on the user or developer mailing lists and on
2394 * Make sure the HBase community is a welcoming one and that we adhere to our
2395 link:/coc.html[Code of conduct]. Alert the PMC if you
2397 * Review other people's work (both code and non-code) and provide public
2399 * Report bugs that are found, or file new feature requests.
2400 * Triage issues and keep JIRA organized. This includes closing stale issues,
2401 labeling new issues, updating metadata, and other tasks as needed.
2402 * Mentor new contributors of all sorts.
2403 * Give talks and write blogs about HBase. Add these to the link:/[News] section
2405 * Provide UX feedback about HBase, the web UI, the CLI, APIs, and the website.
2406 * Write demo applications and scripts.
2407 * Help attract and retain a diverse community.
2408 * Interact with other projects in ways that benefit HBase and those other
2411 Not every individual is able to do all (or even any) of the items on this list.
2412 If you think of other ways to contribute, go for it (and add them to the list).
2413 A pleasant demeanor and willingness to contribute are all you need to make a
2414 positive impact on the HBase project. Invitations to become a committer are the
2415 result of steady interaction with the community over the long term, which builds
2416 trust and recognition.
2418 ===== New committers
2420 New committers are encouraged to first read Apache's generic committer
2423 * link:https://www.apache.org/dev/new-committers-guide.html[Apache New Committer Guide]
2424 * link:https://www.apache.org/dev/committers.html[Apache Committer FAQ]
2428 HBase committers should, as often as possible, attempt to review patches
2429 submitted by others. Ideally every submitted patch will get reviewed by a
2430 committer _within a few days_. If a committer reviews a patch they have not
2431 authored, and believe it to be of sufficient quality, then they can commit the
2432 patch. Otherwise the patch should be cancelled with a clear explanation for why
2435 The list of submitted patches is in the
2436 link:https://issues.apache.org/jira/secure/IssueNavigator.jspa?mode=hide&requestId=12312392[HBase Review Queue],
2437 which is ordered by time of last modification. Committers should scan the list
2438 from top to bottom, looking for patches that they feel qualified to review and
2439 possibly commit. If you see a patch you think someone else is better qualified
2440 to review, you can mention them by username in the JIRA.
2442 For non-trivial changes, it is required that another committer review your
2443 patches before commit. **Self-commits of non-trivial patches are not allowed.**
2444 Use the btn:[Submit Patch] button in JIRA, just like other contributors, and
2445 then wait for a `+1` response from another committer before committing.
2449 Patches which do not adhere to the guidelines in
2450 link:https://hbase.apache.org/book.html#developer[HowToContribute] and to the
2451 link:https://cwiki.apache.org/confluence/display/HADOOP2/CodeReviewChecklist[code review checklist]
2452 should be rejected. Committers should always be polite to contributors and try
2453 to instruct and encourage them to contribute better patches. If a committer
2454 wishes to improve an unacceptable patch, then it should first be rejected, and a
2455 new patch should be attached by the committer for further review.
2457 [[committing.patches]]
2460 Committers commit patches to the Apache HBase GIT repository.
2462 .Before you commit!!!!
2465 Make sure your local configuration is correct, especially your identity and email.
2466 Examine the output of the +$ git config --list+ command and be sure it is correct.
2467 See link:https://help.github.com/articles/set-up-git[Set Up Git] if you need
2471 When you commit a patch:
2473 . Include the Jira issue ID in the commit message along with a short description
2474 of the change. Try to add something more than just the Jira title so that
2475 someone looking at `git log` output doesn't have to go to Jira to discern what
2476 the change is about. Be sure to get the issue ID right, because this causes
2477 Jira to link to the change in Git (use the issue's "All" tab to see these
2479 . Commit the patch to a new branch based off `master` or the other intended
2480 branch. It's a good idea to include the JIRA ID in the name of this branch.
2481 Check out the relevant target branch where you want to commit, and make sure
2482 your local branch has all remote changes, by doing a +git pull --rebase+ or
2483 another similar command. Next, cherry-pick the change into each relevant
2484 branch (such as master), and push the changes to the remote branch using
2485 a command such as +git push <remote-server> <remote-branch>+.
2487 WARNING: If you do not have all remote changes, the push will fail.
2488 If the push fails for any reason, fix the problem or ask for help.
2489 Do not do a +git push --force+.
2491 Before you can commit a patch, you need to determine how the patch was created.
2492 The instructions and preferences around the way to create patches have changed,
2493 and there will be a transition period.
2495 .Determine How a Patch Was Created
2496 * If the first few lines of the patch look like the headers of an email, with a From, Date, and
2497 Subject, it was created using +git format-patch+. This is the preferred way, because you can
2498 reuse the submitter's commit message. If the commit message is not appropriate, you can still use
2499 the commit, then run `git commit --amend` and reword as appropriate.
2500 * If the first line of the patch looks similar to the following, it was created using +git diff+ without `--no-prefix`.
2501 This is acceptable too.
2502 Notice the `a` and `b` in front of the file names.
2503 This is the indication that the patch was not created with `--no-prefix`.
2506 diff --git a/src/main/asciidoc/_chapters/developer.adoc b/src/main/asciidoc/_chapters/developer.adoc
2509 * If the first line of the patch looks similar to the following (without the `a` and `b`), the
2510 patch was created with +git diff --no-prefix+ and you need to add `-p0` to the +git apply+ command
2514 diff --git src/main/asciidoc/_chapters/developer.adoc src/main/asciidoc/_chapters/developer.adoc
2518 .Example of committing a Patch
2520 One thing you will notice with these examples is that there are a lot of
2521 +git pull+ commands. The only command that actually writes anything to the
2522 remote repository is +git push+, and you need to make absolutely sure you have
2523 the correct versions of everything and don't have any conflicts before pushing.
2524 The extra +git pull+ commands are usually redundant, but better safe than sorry.
2526 The first example shows how to apply a patch that was generated with +git
2527 format-patch+ and apply it to the `master` and `branch-1` branches.
2529 The directive to use +git format-patch+ rather than +git diff+, and not to use
2530 `--no-prefix`, is a new one. See the second example for how to apply a patch
2531 created with +git diff+, and educate the person who created the patch.
2534 $ git checkout -b HBASE-XXXX
2535 $ git am ~/Downloads/HBASE-XXXX-v2.patch --signoff # If you are committing someone else's patch.
2536 $ git checkout master
2538 $ git cherry-pick <sha-from-commit>
2539 # Resolve conflicts if necessary or ask the submitter to do it
2540 $ git pull --rebase # Better safe than sorry
2541 $ git push origin master
2543 # Backport to branch-1
2544 $ git checkout branch-1
2546 $ git cherry-pick <sha-from-commit>
2547 # Resolve conflicts if necessary
2548 $ git pull --rebase # Better safe than sorry
2549 $ git push origin branch-1
2550 $ git branch -D HBASE-XXXX
2553 This example shows how to commit a patch that was created using +git diff+
2554 without `--no-prefix`. If the patch was created with `--no-prefix`, add `-p0` to
2555 the +git apply+ command.
2558 $ git apply ~/Downloads/HBASE-XXXX-v2.patch
2559 $ 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'
2560 $ git commit --amend --signoff
2561 $ git checkout master
2563 $ git cherry-pick <sha-from-commit>
2564 # Resolve conflicts if necessary or ask the submitter to do it
2565 $ git pull --rebase # Better safe than sorry
2566 $ git push origin master
2568 # Backport to branch-1
2569 $ git checkout branch-1
2571 $ git cherry-pick <sha-from-commit>
2572 # Resolve conflicts if necessary or ask the submitter to do it
2573 $ git pull --rebase # Better safe than sorry
2574 $ git push origin branch-1
2575 $ git branch -D HBASE-XXXX
2579 . Resolve the issue as fixed, thanking the contributor.
2580 Always set the "Fix Version" at this point, but only set a single fix version
2581 for each branch where the change was committed, the earliest release in that
2582 branch in which the change will appear.
2584 ====== Commit Message Format
2586 The commit message should contain the JIRA ID and a description of what the patch does.
2587 The preferred commit message format is:
2590 <jira-id> <jira-title> (<contributor-name-if-not-commit-author>)
2594 HBASE-12345 Fix All The Things (jane@example.com)
2597 If the contributor used +git format-patch+ to generate the patch, their commit
2598 message is in their patch and you can use that, but be sure the JIRA ID is at
2599 the front of the commit message, even if the contributor left it out.
2601 [[committer.amending.author]]
2602 ====== Use GitHub's "Co-authored-by" when there are multiple authors
2604 We've established the practice of committing to master and then cherry picking back to branches whenever possible, unless
2606 * it's breaking compat: In which case, if it can go in minor releases, backport to branch-1 and branch-2.
2607 * it's a new feature: No for maintenance releases, For minor releases, discuss and arrive at consensus.
2609 There are occasions when there are multiple author for a patch.
2610 For example when there is a minor conflict we can fix it up and just proceed with the commit.
2611 The amending author will be different from the original committer, so you should also attribute to the original author by
2612 adding one or more `Co-authored-by` trailers to the commit's message.
2613 See link:https://help.github.com/en/articles/creating-a-commit-with-multiple-authors/[the GitHub documentation for "Creating a commit with multiple authors"].
2615 In short, these are the steps to add Co-authors that will be tracked by GitHub:
2617 . Collect the name and email address for each co-author.
2618 . 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)
2619 . 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.
2621 Here is the example from the GitHub page, using 2 Co-authors:
2624 $ git commit -m "Refactor usability tests.
2627 Co-authored-by: name <name@example.com>
2628 Co-authored-by: another-name <another-name@example.com>"
2631 Note: `Amending-Author: Author <committer@apache>` was used prior to this
2632 link:https://lists.apache.org/thread.html/f00b5f9b65570e777dbb31c37d7b0ffc55c5fc567aefdb456608a042@%3Cdev.hbase.apache.org%3E[DISCUSSION].
2634 ====== Close related GitHub PRs
2636 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.
2638 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.
2641 ====== Committers are responsible for making sure commits do not break the build or tests
2643 If a committer commits a patch, it is their responsibility to make sure it passes the test suite.
2644 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.
2648 ====== Patching Etiquette
2650 In the thread link:https://lists.apache.org/thread.html/186fcd5eb71973a7b282ecdba41606d3d221efd505d533bb729e1fad%401400648690%40%3Cdev.hbase.apache.org%3E[HBase, mail # dev - ANNOUNCEMENT: Git Migration In Progress (WAS =>
2651 Re: Git Migration)], it was agreed on the following patch flow
2653 . Develop and commit the patch against master first.
2654 . Try to cherry-pick the patch when backporting if possible.
2655 . If this does not work, manually commit the patch to the branch.
2657 ====== Merge Commits
2659 Avoid merge commits, as they create problems in the git history.
2661 ====== Committing Documentation
2663 See <<appendix_contributing_to_documentation,appendix contributing to documentation>>.
2665 ====== How to re-trigger github Pull Request checks/re-build
2667 A Pull Request (PR) submission triggers the hbase yetus checks. The checks make
2668 sure the patch doesn't break the build or introduce test failures. The checks take
2669 around four hours to run (They are the same set run when you submit a patch via
2670 HBASE JIRA). When finished, they add a report to the PR as a comment. If a problem
2671 w/ the patch -- failed compile, checkstyle violation, or an added findbugs --
2672 the original author makes fixes and pushes a new patch. This re-runs the checks
2673 to produce a new report.
2675 Sometimes though, the patch is good but a flakey, unrelated test has the report vote -1
2676 on the patch. In this case, **committers** can retrigger the check run by doing a force push of the
2677 exact same patch. Or, click on the `Console output` link which shows toward the end
2678 of the report (For example `https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-289/1/console`).
2679 This will take you to `builds.apache.org`, to the build run that failed. See the
2680 "breadcrumbs" along the top (where breadcrumbs is the listing of the directories that
2681 gets us to this particular build page). It'll look something like
2682 `Jenkins > HBase-PreCommit-GitHub-PR > PR-289 > #1`. Click on the
2683 PR number -- i.e. PR-289 in our example -- and then, when you've arrived at the PR page,
2684 find the 'Build with Parameters' menu-item (along top left-hand menu). Click here and
2685 then `Build` leaving the JIRA_ISSUE_KEY empty. This will re-run your checks.
2689 Committers should hang out in the #hbase room on irc.freenode.net for real-time discussions.
2690 However any substantive discussion (as with any off-list project-related discussion) should be re-iterated in Jira or on the developer list.
2692 ==== Do not edit JIRA comments
2694 Misspellings and/or bad grammar is preferable to the disruption a JIRA comment edit.
2697 === The hbase-thirdparty dependency and shading/relocation
2699 A new project was created for the release of hbase-2.0.0. It was called
2700 `hbase-thirdparty`. This project exists only to provide the main hbase
2701 project with relocated -- or shaded -- versions of popular thirdparty
2702 libraries such as guava, netty, and protobuf. The mainline HBase project
2703 relies on the relocated versions of these libraries gotten from hbase-thirdparty
2704 rather than on finding these classes in their usual locations. We do this so
2705 we can specify whatever the version we wish. If we don't relocate, we must
2706 harmonize our version to match that which hadoop, spark, and other projects use.
2708 For developers, this means you need to be careful referring to classes from
2709 netty, guava, protobuf, gson, etc. (see the hbase-thirdparty pom.xml for what
2710 it provides). Devs must refer to the hbase-thirdparty provided classes. In
2711 practice, this is usually not an issue (though it can be a bit of a pain). You
2712 will have to hunt for the relocated version of your particular class. You'll
2713 find it by prepending the general relocation prefix of `org.apache.hbase.thirdparty.`.
2714 For example if you are looking for `com.google.protobuf.Message`, the relocated
2715 version used by HBase internals can be found at
2716 `org.apache.hbase.thirdparty.com.google.protobuf.Message`.
2718 For a few thirdparty libs, like protobuf (see the protobuf chapter in this book
2719 for the why), your IDE may give you both options -- the `com.google.protobuf.*`
2720 and the `org.apache.hbase.thirdparty.com.google.protobuf.*` -- because both
2721 classes are on your CLASSPATH. Unless you are doing the particular juggling
2722 required in Coprocessor Endpoint development (again see above cited protobuf
2723 chapter), you'll want to use the shaded version, always.
2725 The `hbase-thirdparty` project has groupid of `org.apache.hbase.thirdparty`.
2726 As of this writing, it provides three jars; one for netty with an artifactid of
2727 `hbase-thirdparty-netty`, one for protobuf at `hbase-thirdparty-protobuf` and then
2728 a jar for all else -- gson, guava -- at `hbase-thirdpaty-miscellaneous`.
2730 The hbase-thirdparty artifacts are a product produced by the Apache HBase
2731 project under the aegis of the HBase Project Management Committee. Releases
2732 are done via the usual voting project on the hbase dev mailing list. If issue
2733 in the hbase-thirdparty, use the hbase JIRA and mailing lists to post notice.
2735 [[hbase.archetypes.development]]
2736 === Development of HBase-related Maven archetypes
2738 The development of HBase-related Maven archetypes was begun with
2739 link:https://issues.apache.org/jira/browse/HBASE-14876[HBASE-14876].
2740 For an overview of the hbase-archetypes infrastructure and instructions
2741 for developing new HBase-related Maven archetypes, please see
2742 `hbase/hbase-archetypes/README.md`.
2744 ifdef::backend-docbook[]
2747 // Generated automatically by the DocBook toolchain.
2748 endif::backend-docbook[]