You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/11/06 19:28:06 UTC

hbase git commit: Generate Thrift code using a maven profile

Repository: hbase
Updated Branches:
  refs/heads/master 910254715 -> cc71d3511


Generate Thrift code using a maven profile

Signed-off-by: stack <st...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/cc71d351
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/cc71d351
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/cc71d351

Branch: refs/heads/master
Commit: cc71d35112080659c18837d610c55a8d2bf0c216
Parents: 9102547
Author: Niels Basjes <nb...@bol.com>
Authored: Wed Nov 5 09:59:23 2014 +0100
Committer: stack <st...@apache.org>
Committed: Thu Nov 6 10:27:59 2014 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/thrift/package.html |  14 +--
 hbase-thrift/pom.xml                            | 112 +++++++++++++++++++
 .../apache/hadoop/hbase/thrift2/package.html    |   6 +-
 pom.xml                                         |   5 +-
 src/main/docbkx/developer.xml                   |  18 ++-
 5 files changed, 138 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/cc71d351/hbase-server/src/main/javadoc/org/apache/hadoop/hbase/thrift/package.html
----------------------------------------------------------------------
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..0e2e9b5 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."</blockquote>
 
-<h2><a name="description">Description</a></h2>
-
-<p><i>Important note:</i> We tried to deprecate this Thrift interface and replace it
+<h2>Important note</h2>
+<p><b><u>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).
-</p>
+</u></b></p>
 
+<h2><a name="description">Description</a></h2>
 <p>The org.apache.hadoop.hbase.thrift.generated.Hbase.Iface HBase API is defined in the
 file <a href="doc-files/index.html">Hbase.thrift</a> (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
 
 <p>The files were generated by running the commands under the hbase checkout dir:
 <pre>
-  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
 </pre>
 
 <p>The 'thrift' binary is the Thrift compiler, and it is distributed as a part

http://git-wip-us.apache.org/repos/asf/hbase/blob/cc71d351/hbase-thrift/pom.xml
----------------------------------------------------------------------
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 @@
       <artifactId>jasper-runtime</artifactId>
     </dependency>
   </dependencies>
+
   <profiles>
     <!-- Skip the tests in this module -->
     <profile>
@@ -271,6 +272,117 @@
         <surefire.skipSecondPart>true</surefire.skipSecondPart>
       </properties>
     </profile>
+
+    <!--
+      Profile for regenerating the thrift java classes.
+      The generated files are to be committed to version control.
+      Activate using:
+       mvn compile -Dcompile-thrift
+    -->
+    <profile>
+      <id>compile-thrift</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-enforcer-plugin</artifactId>
+            <version>1.3.1</version>
+            <executions>
+              <execution>
+                <id>enforce-thrift-version</id>
+                <goals>
+                  <goal>enforce</goal>
+                </goals>
+                <configuration>
+                  <rules>
+                    <requireProperty>
+                      <property>thrift.version</property>
+                      <message>"The Thrift version must be specified."</message>
+                      <regex>0\.9\.0</regex>
+                      <regexMessage>
+-
+-
+[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] ==========================================================================================
+-
+-
+                      </regexMessage>
+                    </requireProperty>
+                  </rules>
+                  <fail>true</fail>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.2.1</version>
+            <executions>
+              <execution>
+                <id>check-thrift-version</id>
+                <phase>generate-sources</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <executable>sh</executable>
+                  <workingDirectory>${basedir}</workingDirectory>
+                  <arguments>
+                    <argument>-c</argument>
+                    <argument>${thrift.path} -version | \
+                      fgrep 'Thrift version ${thrift.version}' &amp;&amp; exit 0;
+                      echo "========== [FATAL] Need Thrift version ${thrift.version} ==========";
+                      exit 1</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+              <execution>
+                <id>thrift</id>
+                <phase>generate-sources</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <executable>${thrift.path}</executable>
+                  <workingDirectory>${basedir}</workingDirectory>
+                  <arguments>
+                    <argument>-strict</argument>
+                    <argument>--gen</argument>
+                    <argument>java:hashcode</argument>
+                    <argument>-out</argument>
+                    <argument>${basedir}/src/main/java</argument>
+                    <argument>${basedir}/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+              <execution>
+                <id>thrift2</id>
+                <phase>generate-sources</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+                <configuration>
+                  <executable>${thrift.path}</executable>
+                  <workingDirectory>${basedir}</workingDirectory>
+                  <arguments>
+                    <argument>-strict</argument>
+                    <argument>--gen</argument>
+                    <argument>java:hashcode</argument>
+                    <argument>-out</argument>
+                    <argument>${basedir}/src/main/java</argument>
+                    <argument>${basedir}/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
     <!-- profile against Hadoop 1.1.x: This is the default. It has to have the same
 activation property as the parent Hadoop 1.1.x profile to make sure it gets run at
 the same time. -->

http://git-wip-us.apache.org/repos/asf/hbase/blob/cc71d351/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/package.html
----------------------------------------------------------------------
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
 <p>HBase currently uses version 0.9.0 of Apache Thrift.</p>
 <p>The files were generated by running the commands under the hbase checkout dir:
 <pre>
-  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
 </pre>
 
 <p>The 'thrift' binary is the Thrift compiler, and it is distributed separately from HBase

http://git-wip-us.apache.org/repos/asf/hbase/blob/cc71d351/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a025cd2..ee1a2f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -464,7 +464,7 @@
              <artifactId>plexus-compiler-javac-errorprone</artifactId>
              <version>2.3</version>
            </dependency>
-         </dependencies>   
+         </dependencies>
         </plugin>
         <!-- Test oriented plugins -->
         <plugin>
@@ -492,7 +492,7 @@
             <!--Allocate some direct memory for direct memory tests-->
             <argLine>${hbase-surefire.argLine} ${argLine}</argLine>
             <redirectTestOutputToFile>${test.output.tofile}</redirectTestOutputToFile>
-	    <systemPropertyVariables>
+            <systemPropertyVariables>
               <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
             </systemPropertyVariables>
           </configuration>
@@ -1012,6 +1012,7 @@
     <log4j.version>1.2.17</log4j.version>
     <mockito-all.version>1.10.8</mockito-all.version>
     <protobuf.version>2.5.0</protobuf.version>
+    <thrift.path>thrift</thrift.path>
     <thrift.version>0.9.0</thrift.version>
     <zookeeper.version>3.4.6</zookeeper.version>
     <slf4j.version>1.7.7</slf4j.version>

http://git-wip-us.apache.org/repos/asf/hbase/blob/cc71d351/src/main/docbkx/developer.xml
----------------------------------------------------------------------
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
                 <title>Build Protobuf</title>
                 <para>You may need to change the protobuf definitions that reside in the
                         <filename>hbase-protocol</filename> module or other modules.</para>
-                <para> The protobuf files are located
+                <para> The protobuf files are located in
                         <filename>hbase-protocol/src/main/protobuf</filename>. For the change to be
                     effective, you will need to regenerate the classes. You can use maven profile
                         <code>compile-protobuf</code> to do this.</para>
@@ -410,6 +410,22 @@ mvn compile -Pcompile-protobuf -Dprotoc.path=/opt/local/bin/protoc
                 </para>
             </section>
 
+            <section xml:id="build.thrift">
+                <title>Build Thrift</title>
+                <para>You may need to change the thrift definitions that reside in the
+                  <filename>hbase-thrift</filename> module or other modules.</para>
+                <para>The thrift files are located in
+                  <filename>hbase-thrift/src/main/resources</filename>.
+                  For the change to be effective, you will need to regenerate the classes.
+                  You can use maven profile  <code>compile-thrift</code> to do this.</para>
+                <programlisting language="bourne">mvn compile -Pcompile-thrift</programlisting>
+                <para>You may also want to define <varname>thrift.path</varname> for the thrift
+                  binary, using the following command:</para>
+                <programlisting language="bourne">
+                  mvn compile -Pcompile-thrift -Dthrift.path=/opt/local/bin/thrift
+                </programlisting>
+            </section>
+
             <section>
                 <title>Build a Tarball</title>
                 <para>You can build a tarball without going through the release process described in