From 336c856e1a4f21c2b82b58598564f823922a0392 Mon Sep 17 00:00:00 2001
From: Niels Basjes
Date: Wed, 5 Nov 2014 09:59:23 +0100
Subject: [PATCH] [HBASE-12272] Generate Thrift code using a maven profile
---
.../org/apache/hadoop/hbase/thrift/package.html | 14 +--
hbase-thrift/pom.xml | 112 +++++++++++++++++++++
.../org/apache/hadoop/hbase/thrift2/package.html | 6 +-
pom.xml | 5 +-
src/main/docbkx/developer.xml | 18 +++-
5 files changed, 138 insertions(+), 17 deletions(-)
diff --git a/hbase-server/src/main/javadoc/org/apache/hadoop/hbase/thrift/package.html b/hbase-server/src/main/javadoc/org/apache/hadoop/hbase/thrift/package.html
index e4b4d40..db7a66f 100644
--- a/hbase-server/src/main/javadoc/org/apache/hadoop/hbase/thrift/package.html
+++ b/hbase-server/src/main/javadoc/org/apache/hadoop/hbase/thrift/package.html
@@ -33,15 +33,15 @@ It combines a software stack with a code generation engine to build services
that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby,
Erlang, Perl, Haskell, C#, Cocoa, Smalltalk, and OCaml."
-
-
-Important note: We tried to deprecate this Thrift interface and replace it
+
+We tried to deprecate this Thrift interface and replace it
with the Interface defined over in the thrift2 package only this package will not die.
Folks keep adding to it and fixing it up so its around for another while until someone
takes command and drives this package out of existence replacing it w/ an Interface that
better matches the hbase API (this package was modelled on old HBase API long since dropped).
-
+
+
The org.apache.hadoop.hbase.thrift.generated.Hbase.Iface HBase API is defined in the
file Hbase.thrift (Click the former to see the
thrift generated documentation of thrift interface). A server-side implementation of the API is in
@@ -93,11 +93,7 @@ These are the command line arguments the Thrift server understands in addition t
The files were generated by running the commands under the hbase checkout dir:
- thrift -strict --gen java:hashcode ./hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
- # Move the generated files into place their expected location under hbase
- mv gen-java/org/apache/hadoop/hbase/thrift/generated/* hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/
- # Remove the gen-java file made by thrift
- rm -rf gen-java
+ mvn compile -Pcompile-thrift
The 'thrift' binary is the Thrift compiler, and it is distributed as a part
diff --git a/hbase-thrift/pom.xml b/hbase-thrift/pom.xml
index 758091a..5dae2a3 100644
--- a/hbase-thrift/pom.xml
+++ b/hbase-thrift/pom.xml
@@ -257,6 +257,7 @@
jasper-runtime
+
@@ -271,6 +272,117 @@
true
+
+
+
+ compile-thrift
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 1.3.1
+
+
+ enforce-thrift-version
+
+ enforce
+
+
+
+
+ thrift.version
+ "The Thrift version must be specified."
+ 0\.9\.0
+
+-
+-
+[FATAL] ==========================================================================================
+[FATAL] HBase Thrift requires the thrift generator version 0.9.0.
+[FATAL] Setting it to something else needs to be reviewed for wire and behavior compatibility.
+[FATAL] ==========================================================================================
+-
+-
+
+
+
+ true
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.2.1
+
+
+ check-thrift-version
+ generate-sources
+
+ exec
+
+
+ sh
+ ${basedir}
+
+ -c
+ ${thrift.path} -version | \
+ fgrep 'Thrift version ${thrift.version}' && exit 0;
+ echo "========== [FATAL] Need Thrift version ${thrift.version} ==========";
+ exit 1
+
+
+
+
+ thrift
+ generate-sources
+
+ exec
+
+
+ ${thrift.path}
+ ${basedir}
+
+ -strict
+ --gen
+ java:hashcode
+ -out
+ ${basedir}/src/main/java
+ ${basedir}/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
+
+
+
+
+ thrift2
+ generate-sources
+
+ exec
+
+
+ ${thrift.path}
+ ${basedir}
+
+ -strict
+ --gen
+ java:hashcode
+ -out
+ ${basedir}/src/main/java
+ ${basedir}/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
+
+
+
+
+
+
+
+
+
diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/package.html b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/package.html
index 8f6058e..8c40d95 100644
--- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/package.html
+++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/package.html
@@ -91,11 +91,7 @@ These are the command line arguments the Thrift server understands in addition t
HBase currently uses version 0.9.0 of Apache Thrift.
The files were generated by running the commands under the hbase checkout dir:
- thrift -strict --gen java:hashcode ./hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
- # Move the generated files into place their expected location under hbase
- mv gen-java/org/apache/hadoop/hbase/thrift2/generated/* hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/
- # Remove the gen-java file made by thrift
- rm -rf gen-java
+ mvn compile -Pcompile-thrift
The 'thrift' binary is the Thrift compiler, and it is distributed separately from HBase
diff --git a/pom.xml b/pom.xml
index a025cd2..ee1a2f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -464,7 +464,7 @@
plexus-compiler-javac-errorprone
2.3
-
+
@@ -492,7 +492,7 @@
${hbase-surefire.argLine} ${argLine}
${test.output.tofile}
-
+
target/jacoco.exec
@@ -1012,6 +1012,7 @@
1.2.17
1.10.8
2.5.0
+ thrift
0.9.0
3.4.6
1.7.7
diff --git a/src/main/docbkx/developer.xml b/src/main/docbkx/developer.xml
index 4a59cf4..2b5fd1e 100644
--- a/src/main/docbkx/developer.xml
+++ b/src/main/docbkx/developer.xml
@@ -396,7 +396,7 @@ Access restriction: The method getLong(Object, long) from the type Unsafe is not
Build Protobuf
You may need to change the protobuf definitions that reside in the
hbase-protocol module or other modules.
- The protobuf files are located
+ The protobuf files are located in
hbase-protocol/src/main/protobuf. For the change to be
effective, you will need to regenerate the classes. You can use maven profile
compile-protobuf to do this.
@@ -410,6 +410,22 @@ mvn compile -Pcompile-protobuf -Dprotoc.path=/opt/local/bin/protoc
+
+ Build Thrift
+ You may need to change the thrift definitions that reside in the
+ hbase-thrift module or other modules.
+ The thrift files are located in
+ hbase-thrift/src/main/resources.
+ For the change to be effective, you will need to regenerate the classes.
+ You can use maven profile compile-thrift to do this.
+ mvn compile -Pcompile-thrift
+ You may also want to define thrift.path for the thrift
+ binary, using the following command:
+
+ mvn compile -Pcompile-thrift -Dthrift.path=/opt/local/bin/thrift
+
+
+
Build a Tarball
You can build a tarball without going through the release process described in
--
1.8.3.1