This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git

commit 0c0937debcf5f8022104261857cb66386809bd6a
Author: Istvan Toth <st...@apache.org>
AuthorDate: Thu Feb 27 09:16:40 2020 +0100

    PHOENIX-5721 Unify 4.x branches (HBase 1.4 and 1.5)
    
    adds the build profile infrastructure
    factors out the HBase 1.4 and 1.5 compatibility layers
---
 BUILDING.md                                        |  89 +++++++++++++
 build.txt                                          |  64 ----------
 phoenix-assembly/pom.xml                           |  12 +-
 .../src/build/components/all-common-files.xml      |   2 +-
 .../src/build/components/all-common-jars.xml       |  14 +-
 phoenix-client/pom.xml                             |   7 +-
 phoenix-core/pom.xml                               |  55 ++++++--
 .../hadoop/hbase/ipc/PhoenixRpcScheduler.java      |  49 +------
 .../coprocessor/DelegateRegionObserver.java        |  36 +-----
 .../coprocessor/PhoenixAccessController.java       |  38 ++++--
 .../PhoenixMetaDataCoprocessorHost.java            |  18 +--
 phoenix-hbase-compat-1.4.0/bin/pom.xml             |  83 ++++++++++++
 phoenix-hbase-compat-1.4.0/pom.xml                 |  83 ++++++++++++
 .../compat/hbase/CompatDelegateRegionObserver.java |  69 ++++++++++
 .../compat/hbase/CompatObserverContext.java        |  32 +++++
 ...CompatPhoenixMetaDataControllerEnvironment.java |  41 ++++++
 .../compat/hbase/CompatPhoenixRpcScheduler.java    |  55 ++++++++
 phoenix-hbase-compat-1.5.0/pom.xml                 |  84 ++++++++++++
 .../compat/hbase/CompatDelegateRegionObserver.java |  69 ++++++++++
 .../compat/hbase/CompatObserverContext.java        |  30 +++++
 ...CompatPhoenixMetaDataControllerEnvironment.java |  41 ++++++
 .../compat/hbase/CompatPhoenixRpcScheduler.java    |  70 ++++++++++
 phoenix-pherf/pom.xml                              |   2 +-
 phoenix-server/pom.xml                             |   6 +-
 phoenix-tracing-webapp/pom.xml                     |   2 +-
 pom.xml                                            | 141 ++++++++++++++++++++-
 26 files changed, 994 insertions(+), 198 deletions(-)

diff --git a/BUILDING.md b/BUILDING.md
new file mode 100644
index 0000000..74ea502
--- /dev/null
+++ b/BUILDING.md
@@ -0,0 +1,89 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+![logo](http://phoenix.apache.org/images/logo.png)
+
+<b>[Apache Phoenix](http://phoenix.apache.org/)</b> is a SQL skin over HBase 
delivered as a
+client-embedded JDBC driver targeting low latency queries over HBase data. 
Visit the Apache
+Phoenix website <b>[here](http://phoenix.apache.org/)</b>.
+
+
+Building Apache Phoenix
+========================
+
+Phoenix uses Maven (3.X) to build all its necessary resources.
+
+Building from source
+--------------------
+
+On first setup, you may need to run `$ mvn install -DskipTests`
+to install the local jars. This is a side-effect of multi-module maven projects
+
+To re-generate the antlr based files:  
+`$ mvn process-sources`
+
+To build the jars and the assembly tarball:  
+`$ mvn package`
+and optionally, to just skip all the tests and build the jars:  
+`$ mvn package -DskipTests`
+
+Note: javadocs are generated in target/apidocs
+
+HBase version compatibility
+---------------------------
+
+As Phoenix uses *limited public* HBase APIs, which sometimes change even 
within a minor release,
+Phoenix may not build or work with older releases of HBase, or ones that were 
released after
+Phoenix, even within the same HBase minor release.
+
+By default, Phoenix will be built for the latest supported HBase 1.x release. 
You can specify the
+targeted HBase minor release by setting the `hbase.profile` system property 
for maven.
+
+You can also specify the exact HBase release to build Phoenix with by 
additionally
+setting the `hbase.version` system property.
+
+ * `mvn clean install` will build the for the latest known supported HBase 1.x 
relese
+ * `mvn clean install -Dhbase.profile=1.4` will use the latest known supported 
HBase 1.1 release
+ * `mvn clean install -Dhbase.profile=1.4 -Dhbase.version=1.4.3` will build 
with HBase 1.4.3
+
+Phoenix verifies the specified `hbase.profile` and `hbase.version` properties, 
and will reject
+combinations that are known not to work. You may disable this verification by 
adding
+`-Denforcer.skip=true` to the maven command line. (In case you are using an 
HBase package that
+modifies the canonical version number in a way that Phoenix cannot parse)
+
+Importing into eclipse
+----------------------
+
+Use the m2e eclipse plugin and do Import->Maven Project and just pick the root 
'phoenix' directory.
+
+Running the tests
+-----------------
+
+All tests  
+`$ mvn clean test`
+
+Findbugs
+--------
+
+Findbugs report is generated in /target/site  
+`$ mvn site`
+
+Generate Apache Web Site
+------------------------
+
+checkout https://svn.apache.org/repos/asf/phoenix  
+`$ build.sh`
diff --git a/build.txt b/build.txt
deleted file mode 100644
index aac954c..0000000
--- a/build.txt
+++ /dev/null
@@ -1,64 +0,0 @@
-############################################################################
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-############################################################################
-
-
-# Building Apache Phoenix
-=========================
-
-Phoenix uses Maven (3.X) to build all its necessary resources. 
-
-## Building from source
-=======================
-
-On first setup, you may need to run
-       $ mvn install -DskipTests
-to install the local jars. This is a side-effect of multi-module maven projects
-
-1. To re-generate the antlr based files:
-       $ mvn process-sources
-
-2. To build the jars
-       $ mvn package
-and optionally, to just skip all the tests and build the jars:
-       $ mvn package -DskipTests
-
-Note: javadocs are generated in target/apidocs
-
-## Importing into eclipse
-=========================
-
-Use the m2e eclipse plugin and do Import->Maven Project and just pick the root 
'phoenix' directory.
-
-## Running the tests
-====================
-
-1. All tests 
-       $ mvn clean test
-
-## Findbugs
-===========
-Findbugs report is generated in /target/site
-       $ mvn site
-       
-
-## Generate Apache Web Site
-===========================
-checkout https://svn.apache.org/repos/asf/phoenix
-        $ build.sh
diff --git a/phoenix-assembly/pom.xml b/phoenix-assembly/pom.xml
index 638afb5..47bb723 100644
--- a/phoenix-assembly/pom.xml
+++ b/phoenix-assembly/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.phoenix</groupId>
     <artifactId>phoenix</artifactId>
-    <version>4.16.0-HBase-1.5-SNAPSHOT</version>
+    <version>4.16.0-SNAPSHOT</version>
   </parent>
   <artifactId>phoenix-assembly</artifactId>
   <name>Phoenix Assembly</name>
@@ -52,8 +52,12 @@
               
<workingDirectory>${project.basedir}/../phoenix-client/target</workingDirectory>
               <arguments>
                 <argument>-fnsv</argument>
-                <argument>phoenix-client-${project.version}.jar</argument>
-                <argument>phoenix-${project.version}-client.jar</argument>
+                <argument>
+                  phoenix-client-${project.version}-${hbase.profile.string}.jar
+                </argument>
+                <argument>
+                  phoenix-${project.version}-${hbase.profile.string}-client.jar
+                </argument>
               </arguments>
             </configuration>
           </execution>
@@ -81,7 +85,7 @@
               <goal>single</goal>
             </goals>
             <configuration>
-            <finalName>phoenix-${project.version}</finalName>
+            
<finalName>phoenix-${project.version}-${hbase.profile.string}</finalName>
               <attach>false</attach>
               <tarLongFileMode>gnu</tarLongFileMode>
               <appendAssemblyId>false</appendAssemblyId>
diff --git a/phoenix-assembly/src/build/components/all-common-files.xml 
b/phoenix-assembly/src/build/components/all-common-files.xml
index a17a138..386fe4a 100644
--- a/phoenix-assembly/src/build/components/all-common-files.xml
+++ b/phoenix-assembly/src/build/components/all-common-files.xml
@@ -27,7 +27,7 @@
       <directory>${project.basedir}/..</directory>
       <outputDirectory>/</outputDirectory>
       <includes>
-        <include>*.txt</include>
+        <include>*.md</include>
       </includes>
     </fileSet>
     <!-- Copy the executable files from the bin directory  -->
diff --git a/phoenix-assembly/src/build/components/all-common-jars.xml 
b/phoenix-assembly/src/build/components/all-common-jars.xml
index d7e8735..365530e 100644
--- a/phoenix-assembly/src/build/components/all-common-jars.xml
+++ b/phoenix-assembly/src/build/components/all-common-jars.xml
@@ -27,9 +27,9 @@
       <directory>${project.basedir}/../phoenix-client/target</directory>
       <outputDirectory>/</outputDirectory>
       <includes>
-        <include>phoenix-client-${project.version}.jar</include>
+        
<include>phoenix-client-${project.version}-${hbase.profile.string}.jar</include>
         <!-- deprecated jar name, which we now have a symlink for -->
-        <include>phoenix-${project.version}-client.jar</include>
+        
<include>phoenix-${project.version}-${hbase.profile.string}-client.jar</include>
       </includes>
     </fileSet>
     <fileSet>
@@ -161,6 +161,16 @@
       <fileMode>0644</fileMode>
     </fileSet>
     <fileSet>
+      <directory>
+        
${project.basedir}/../phoenix-hbase-compat-${hbase.compat.version}/target/
+      </directory>
+      <outputDirectory>lib</outputDirectory>
+      <includes>
+        <include>phoenix-*.jar</include>
+      </includes>
+      <fileMode>0644</fileMode>
+    </fileSet>
+    <fileSet>
       
<directory>${project.basedir}/../phoenix-load-balancer/target/</directory>
       <outputDirectory>lib</outputDirectory>
       <includes>
diff --git a/phoenix-client/pom.xml b/phoenix-client/pom.xml
index 43bc9e7..da4e56c 100644
--- a/phoenix-client/pom.xml
+++ b/phoenix-client/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.phoenix</groupId>
     <artifactId>phoenix</artifactId>
-    <version>4.16.0-HBase-1.5-SNAPSHOT</version>
+    <version>4.16.0-SNAPSHOT</version>
   </parent>
   <artifactId>phoenix-client</artifactId>
   <name>Phoenix Client</name>
@@ -346,7 +346,8 @@
               <goal>shade</goal>
             </goals>
             <configuration>
-              <shadedArtifactAttached>false</shadedArtifactAttached>
+              
<shadedClassifierName>${hbase.profile.string}</shadedClassifierName>
+              <shadedArtifactAttached>true</shadedArtifactAttached>
               
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
               <shadeTestJar>false</shadeTestJar>
               <createSourcesJar>true</createSourcesJar>
@@ -382,7 +383,7 @@
               <goal>shade</goal>
             </goals>
             <configuration>
-              <shadedClassifierName>embedded</shadedClassifierName>
+              
<shadedClassifierName>${hbase.profile.string}-embedded</shadedClassifierName>
               <shadedArtifactAttached>true</shadedArtifactAttached>
               
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
               <shadeTestJar>false</shadeTestJar>
diff --git a/phoenix-core/pom.xml b/phoenix-core/pom.xml
index 1795dfd..fdec241 100644
--- a/phoenix-core/pom.xml
+++ b/phoenix-core/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <groupId>org.apache.phoenix</groupId>
     <artifactId>phoenix</artifactId>
-    <version>4.16.0-HBase-1.5-SNAPSHOT</version>
+    <version>4.16.0-SNAPSHOT</version>
   </parent>
   <artifactId>phoenix-core</artifactId>
   <name>Phoenix Core</name>
@@ -412,14 +412,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.hbase</groupId>
-      <artifactId>hbase-metrics-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.hbase</groupId>
-      <artifactId>hbase-metrics</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-common</artifactId>
       <scope>test</scope>
       <type>test-jar</type>
@@ -511,10 +503,51 @@
       <artifactId>curator-framework</artifactId>
       <version>${curator.version}</version>
     </dependency>
-
-
   </dependencies>
 
+  <profiles>
+    <!-- See the parent pom for profile selection -->
+    <profile>
+      <id>phoenix-hbase-compat-1.5.0-default</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.hbase</groupId>
+          <artifactId>hbase-metrics-api</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.hbase</groupId>
+          <artifactId>hbase-metrics</artifactId>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>phoenix-hbase-compat-1.5.0</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.hbase</groupId>
+          <artifactId>hbase-metrics-api</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.hbase</groupId>
+          <artifactId>hbase-metrics</artifactId>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>phoenix-hbase-compat-1.4.0</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.hbase</groupId>
+          <artifactId>hbase-metrics-api</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.hbase</groupId>
+          <artifactId>hbase-metrics</artifactId>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
+
   <reporting>
       <plugins>
           <plugin>
diff --git 
a/phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java
 
b/phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java
index cb293ae..995149f 100644
--- 
a/phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java
+++ 
b/phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.ipc;
 import java.io.IOException;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.phoenix.compat.hbase.CompatPhoenixRpcScheduler;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
 
@@ -29,14 +30,13 @@ import com.google.common.annotations.VisibleForTesting;
  * {@link RpcScheduler} that first checks to see if this is an index or 
metedata update before passing off the
  * call to the delegate {@link RpcScheduler}.
  */
-public class PhoenixRpcScheduler extends RpcScheduler {
+public class PhoenixRpcScheduler extends CompatPhoenixRpcScheduler {
 
     // copied from org.apache.hadoop.hbase.ipc.SimpleRpcScheduler in HBase 
0.98.4
     private static final String CALL_QUEUE_HANDLER_FACTOR_CONF_KEY = 
"ipc.server.callqueue.handler.factor";
     private static final String CALLQUEUE_LENGTH_CONF_KEY = 
"ipc.server.max.callqueue.length";
     private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
 
-    private RpcScheduler delegate;
     private int indexPriority;
     private int metadataPriority;
     private RpcExecutor indexCallExecutor;
@@ -135,49 +135,4 @@ public class PhoenixRpcScheduler extends RpcScheduler {
         this.metadataCallExecutor = executor;
     }
 
-    @Override
-    public int getReadQueueLength() {
-        return delegate.getReadQueueLength();
-    }
-
-    @Override
-    public int getWriteQueueLength() {
-        return delegate.getWriteQueueLength();
-    }
-
-    @Override
-    public int getScanQueueLength() {
-        return delegate.getScanQueueLength();
-    }
-
-    @Override
-    public int getActiveReadRpcHandlerCount() {
-        return delegate.getActiveReadRpcHandlerCount();
-    }
-
-    @Override
-    public int getActiveWriteRpcHandlerCount() {
-        return delegate.getActiveWriteRpcHandlerCount();
-    }
-
-    @Override
-    public int getActiveScanRpcHandlerCount() {
-        return delegate.getActiveScanRpcHandlerCount();
-    }
-
-    @Override
-    public int getActiveGeneralRpcHandlerCount() {
-        return delegate.getActiveGeneralRpcHandlerCount();
-    }
-
-    @Override
-    public int getActivePriorityRpcHandlerCount() {
-        return delegate.getActivePriorityRpcHandlerCount();
-    }
-
-    @Override
-    public int getActiveReplicationRpcHandlerCount() {
-        return delegate.getActiveReplicationRpcHandlerCount();
-    }
-
 }
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/DelegateRegionObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/DelegateRegionObserver.java
index 6855da9..2ebc571 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/DelegateRegionObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/DelegateRegionObserver.java
@@ -61,15 +61,14 @@ import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.CompatDelegateRegionObserver;
 
 import com.google.common.collect.ImmutableList;
 
-public class DelegateRegionObserver implements RegionObserver {
-
-    protected final RegionObserver delegate;
+public class DelegateRegionObserver extends CompatDelegateRegionObserver 
implements RegionObserver {
     
     public DelegateRegionObserver(RegionObserver delegate) {
-        this.delegate = delegate;
+        super(delegate);
     }
 
     @Override
@@ -679,37 +678,10 @@ public class DelegateRegionObserver implements 
RegionObserver {
         return delegate.postInstantiateDeleteTracker(ctx, delTracker);
     }
 
-    @Override
+    //No @Override for backwards compatibility reasons
     public void preWALAppend(ObserverContext<RegionCoprocessorEnvironment> 
ctx, WALKey key,
             WALEdit edit) throws IOException {
     }
 
-    @Override
-    public InternalScanner 
preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
-            Store store, KeyValueScanner memstoreScanner, InternalScanner s, 
long readPoint)
-            throws IOException {
-        return delegate.preFlushScannerOpen(c, store, memstoreScanner, s, 
readPoint);
-    }
-
-    @Override
-    public InternalScanner 
preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
-            Store store, List<? extends KeyValueScanner> scanners, ScanType 
scanType,
-            long earliestPutTs, InternalScanner s, CompactionRequest request, 
long readPoint)
-            throws IOException {
-      return delegate.preCompactScannerOpen(c, store, scanners, scanType, 
earliestPutTs, s, request,
-          readPoint);
-    }
-
-    @Override
-    public void 
preCommitStoreFile(ObserverContext<RegionCoprocessorEnvironment> ctx, byte[] 
family,
-            List<Pair<Path, Path>> pairs) throws IOException {
-        delegate.preCommitStoreFile(ctx, family, pairs);
-    }
-
-    @Override
-    public void 
postCommitStoreFile(ObserverContext<RegionCoprocessorEnvironment> ctx,
-            byte[] family, Path srcPath, Path dstPath) throws IOException {
-        delegate.postCommitStoreFile(ctx, family, srcPath, dstPath);
-    }
 
 }
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
index 83e9593..3564ae4 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
@@ -58,6 +58,7 @@ import org.apache.hadoop.hbase.security.access.*;
 import org.apache.hadoop.hbase.security.access.Permission.Action;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.phoenix.compat.hbase.CompatObserverContext;
 import 
org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost.PhoenixMetaDataControllerEnvironment;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
@@ -171,7 +172,9 @@ public class PhoenixAccessController extends 
BaseMetaDataEndpointObserver {
                 htd.addFamily(new HColumnDescriptor(familyName));
             }
             for (BaseMasterAndRegionObserver observer : 
getAccessControllers()) {
-                observer.preCreateTable(new 
ObserverContext<MasterCoprocessorEnvironment>(getActiveUser()), htd, null);
+                observer.preCreateTable(
+                    new 
CompatObserverContext<MasterCoprocessorEnvironment>(getActiveUser()), htd,
+                    null);
             }
         }
 
@@ -358,12 +361,15 @@ public class PhoenixAccessController extends 
BaseMetaDataEndpointObserver {
 
         for (BaseMasterAndRegionObserver observer : getAccessControllers()) {
             if (tableType != PTableType.VIEW) {
-                observer.preDeleteTable(new 
ObserverContext<MasterCoprocessorEnvironment>(getActiveUser()), 
physicalTableName);
+                observer.preDeleteTable(
+                    new 
CompatObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
+                    physicalTableName);
             }
             if (indexes != null) {
                 for (PTable index : indexes) {
-                    observer.preDeleteTable(new 
ObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
-                            
TableName.valueOf(index.getPhysicalName().getBytes()));
+                    observer.preDeleteTable(
+                        new 
CompatObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
+                        TableName.valueOf(index.getPhysicalName().getBytes()));
                 }
             }
         }
@@ -383,8 +389,9 @@ public class PhoenixAccessController extends 
BaseMetaDataEndpointObserver {
         if (!accessCheckEnabled) { return; }
         for (BaseMasterAndRegionObserver observer : getAccessControllers()) {
             if (tableType != PTableType.VIEW) {
-                observer.preModifyTable(new 
ObserverContext<MasterCoprocessorEnvironment>(getActiveUser()), 
physicalTableName,
-                    new HTableDescriptor(physicalTableName));
+                observer.preModifyTable(
+                    new 
CompatObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
+                    physicalTableName, new 
HTableDescriptor(physicalTableName));
             }
         }
         if (tableType == PTableType.VIEW) {
@@ -401,8 +408,9 @@ public class PhoenixAccessController extends 
BaseMetaDataEndpointObserver {
             throws IOException {
         if (!accessCheckEnabled) { return; }
         for (BaseMasterAndRegionObserver observer : getAccessControllers()) {
-            observer.preListNamespaceDescriptors(new 
ObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
-                    
Arrays.asList(NamespaceDescriptor.create(schemaName).build()));
+            observer.preListNamespaceDescriptors(
+                new 
CompatObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
+                Arrays.asList(NamespaceDescriptor.create(schemaName).build()));
         }
     }
 
@@ -411,8 +419,9 @@ public class PhoenixAccessController extends 
BaseMetaDataEndpointObserver {
             throws IOException {
         if (!accessCheckEnabled) { return; }
         for (BaseMasterAndRegionObserver observer : getAccessControllers()) {
-            observer.preCreateNamespace(new 
ObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
-                    NamespaceDescriptor.create(schemaName).build());
+            observer.preCreateNamespace(
+                new 
CompatObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
+                NamespaceDescriptor.create(schemaName).build());
         }
     }
 
@@ -421,7 +430,9 @@ public class PhoenixAccessController extends 
BaseMetaDataEndpointObserver {
             throws IOException {
         if (!accessCheckEnabled) { return; }
         for (BaseMasterAndRegionObserver observer : getAccessControllers()) {
-            observer.preDeleteNamespace(new 
ObserverContext<MasterCoprocessorEnvironment>(getActiveUser()), schemaName);
+            observer.preDeleteNamespace(
+                new 
CompatObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
+                schemaName);
         }
     }
 
@@ -431,8 +442,9 @@ public class PhoenixAccessController extends 
BaseMetaDataEndpointObserver {
             throws IOException {
         if (!accessCheckEnabled) { return; }
         for (BaseMasterAndRegionObserver observer : getAccessControllers()) {
-            observer.preModifyTable(new 
ObserverContext<MasterCoprocessorEnvironment>(getActiveUser()), 
physicalTableName,
-                    new HTableDescriptor(physicalTableName));
+            observer.preModifyTable(
+                new 
CompatObserverContext<MasterCoprocessorEnvironment>(getActiveUser()),
+                physicalTableName, new HTableDescriptor(physicalTableName));
         }
         // Check for read access in case of rebuild
         if (newState == PIndexState.BUILDING) {
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixMetaDataCoprocessorHost.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixMetaDataCoprocessorHost.java
index e4ee557..f7ff05c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixMetaDataCoprocessorHost.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixMetaDataCoprocessorHost.java
@@ -32,12 +32,13 @@ import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
 import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
 import org.apache.hadoop.hbase.ipc.RpcServer;
-import org.apache.hadoop.hbase.metrics.MetricRegistry;
 import org.apache.hadoop.hbase.regionserver.Region;
 import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
 import org.apache.hadoop.hbase.regionserver.RegionServerServices;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.security.UserProvider;
+import org.apache.phoenix.compat.hbase.CompatObserverContext;
+import 
org.apache.phoenix.compat.hbase.CompatPhoenixMetaDataControllerEnvironment;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
 import org.apache.phoenix.schema.PIndexState;
@@ -66,7 +67,8 @@ public class PhoenixMetaDataCoprocessorHost
         loadSystemCoprocessors(conf, PHOENIX_META_DATA_COPROCESSOR_CONF_KEY);
     }
 
-    private static abstract class CoprocessorOperation<T extends 
CoprocessorEnvironment> extends ObserverContext<T> {
+    private static abstract class CoprocessorOperation<T extends 
CoprocessorEnvironment>
+            extends CompatObserverContext<T> {
         abstract void call(MetaDataEndpointObserver oserver, 
ObserverContext<T> ctx) throws IOException;
 
         public CoprocessorOperation(User user) {
@@ -115,15 +117,13 @@ public class PhoenixMetaDataCoprocessorHost
     /**
      * Encapsulation of the environment of each coprocessor
      */
-    public static class PhoenixMetaDataControllerEnvironment extends 
CoprocessorHost.Environment
+    public static class PhoenixMetaDataControllerEnvironment 
+            extends CompatPhoenixMetaDataControllerEnvironment
             implements RegionCoprocessorEnvironment {
 
-        private RegionCoprocessorEnvironment env;
-
         PhoenixMetaDataControllerEnvironment(RegionCoprocessorEnvironment env, 
Coprocessor instance,
                 int priority, int sequence, Configuration conf) {
-            super(instance, priority, sequence, conf);
-            this.env = env;
+            super(env, instance, priority, sequence, conf);
         }
 
         @Override
@@ -150,10 +150,6 @@ public class PhoenixMetaDataCoprocessorHost
             return env.getSharedData();
         }
 
-        @Override
-        public MetricRegistry getMetricRegistryForRegionServer() {
-            return env.getMetricRegistryForRegionServer();
-        }
     }
 
     @Override
diff --git a/phoenix-hbase-compat-1.4.0/bin/pom.xml 
b/phoenix-hbase-compat-1.4.0/bin/pom.xml
new file mode 100644
index 0000000..e98c796
--- /dev/null
+++ b/phoenix-hbase-compat-1.4.0/bin/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation=
+      "http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache</groupId>
+    <artifactId>apache</artifactId>
+    <version>21</version>
+  </parent>
+  <groupId>org.apache.phoenix</groupId>
+  <artifactId>phoenix-hbase-compat-1.4.0</artifactId>
+  <version>4.16.0-SNAPSHOT</version>
+  <name>Phoenix Hbase 1.4.0 compatibility</name>
+  <description>Compatibility module for HBase 1.4.0+</description>
+
+  <build>
+    <plugins>
+      <!-- Setup eclipse -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <version>2.9</version>
+        <configuration>
+          <buildcommands>
+            <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+          </buildcommands>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-server</artifactId>
+      <version>1.4.0</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
diff --git a/phoenix-hbase-compat-1.4.0/pom.xml 
b/phoenix-hbase-compat-1.4.0/pom.xml
new file mode 100644
index 0000000..e98c796
--- /dev/null
+++ b/phoenix-hbase-compat-1.4.0/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation=
+      "http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache</groupId>
+    <artifactId>apache</artifactId>
+    <version>21</version>
+  </parent>
+  <groupId>org.apache.phoenix</groupId>
+  <artifactId>phoenix-hbase-compat-1.4.0</artifactId>
+  <version>4.16.0-SNAPSHOT</version>
+  <name>Phoenix Hbase 1.4.0 compatibility</name>
+  <description>Compatibility module for HBase 1.4.0+</description>
+
+  <build>
+    <plugins>
+      <!-- Setup eclipse -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <version>2.9</version>
+        <configuration>
+          <buildcommands>
+            <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+          </buildcommands>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-server</artifactId>
+      <version>1.4.0</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
diff --git 
a/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatDelegateRegionObserver.java
 
b/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatDelegateRegionObserver.java
new file mode 100644
index 0000000..d8b8266
--- /dev/null
+++ 
b/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatDelegateRegionObserver.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compat.hbase;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.coprocessor.RegionObserver;
+import org.apache.hadoop.hbase.regionserver.InternalScanner;
+import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
+import org.apache.hadoop.hbase.regionserver.ScanType;
+import org.apache.hadoop.hbase.regionserver.Store;
+import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
+import org.apache.hadoop.hbase.util.Pair;
+
+public abstract class CompatDelegateRegionObserver implements RegionObserver {
+
+    protected final RegionObserver delegate;
+
+    public CompatDelegateRegionObserver(RegionObserver delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public InternalScanner 
preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
+            Store store, KeyValueScanner memstoreScanner, InternalScanner s, 
long readPoint)
+            throws IOException {
+        return delegate.preFlushScannerOpen(c, store, memstoreScanner, s, 
readPoint);
+    }
+
+    @Override
+    public InternalScanner 
preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
+            Store store, List<? extends KeyValueScanner> scanners, ScanType 
scanType,
+            long earliestPutTs, InternalScanner s, CompactionRequest request, 
long readPoint)
+            throws IOException {
+        return delegate.preCompactScannerOpen(c, store, scanners, scanType, 
earliestPutTs, s,
+            request, readPoint);
+    }
+
+    @Override
+    public void 
preCommitStoreFile(ObserverContext<RegionCoprocessorEnvironment> ctx, byte[] 
family,
+            List<Pair<Path, Path>> pairs) throws IOException {
+        delegate.preCommitStoreFile(ctx, family, pairs);
+    }
+
+    @Override
+    public void 
postCommitStoreFile(ObserverContext<RegionCoprocessorEnvironment> ctx,
+            byte[] family, Path srcPath, Path dstPath) throws IOException {
+        delegate.postCommitStoreFile(ctx, family, srcPath, dstPath);
+    }
+}
\ No newline at end of file
diff --git 
a/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatObserverContext.java
 
b/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatObserverContext.java
new file mode 100644
index 0000000..d26bc6f
--- /dev/null
+++ 
b/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatObserverContext.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compat.hbase;
+
+import org.apache.hadoop.hbase.CoprocessorEnvironment;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.security.User;
+
+public class CompatObserverContext<E extends CoprocessorEnvironment>
+        extends ObserverContext {
+
+    public CompatObserverContext(User caller) {
+        // We are silently dropping the argument, instead of not pre-computing 
it
+        // This has some performance impact, but I believe that it is 
negligible
+        super();
+    }
+}
diff --git 
a/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixMetaDataControllerEnvironment.java
 
b/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixMetaDataControllerEnvironment.java
new file mode 100644
index 0000000..f716326
--- /dev/null
+++ 
b/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixMetaDataControllerEnvironment.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compat.hbase;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.Coprocessor;
+import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.metrics.MetricRegistry;
+
+public abstract class CompatPhoenixMetaDataControllerEnvironment extends 
CoprocessorHost.Environment
+        implements RegionCoprocessorEnvironment {
+
+    protected RegionCoprocessorEnvironment env;
+
+    public 
CompatPhoenixMetaDataControllerEnvironment(RegionCoprocessorEnvironment env,
+            Coprocessor instance, int priority, int sequence, Configuration 
conf) {
+        super(instance, priority, sequence, conf);
+        this.env = env;
+    }
+
+    @Override
+    public MetricRegistry getMetricRegistryForRegionServer() {
+        return env.getMetricRegistryForRegionServer();
+    }
+}
diff --git 
a/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixRpcScheduler.java
 
b/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixRpcScheduler.java
new file mode 100644
index 0000000..cf8c33f
--- /dev/null
+++ 
b/phoenix-hbase-compat-1.4.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixRpcScheduler.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compat.hbase;
+
+import org.apache.hadoop.hbase.ipc.RpcScheduler;
+
+public abstract class CompatPhoenixRpcScheduler extends RpcScheduler {
+    protected RpcScheduler delegate;
+
+    @Override
+    public int getReadQueueLength() {
+        return delegate.getReadQueueLength();
+    }
+
+    @Override
+    public int getWriteQueueLength() {
+        return delegate.getWriteQueueLength();
+    }
+
+    @Override
+    public int getScanQueueLength() {
+        return delegate.getScanQueueLength();
+    }
+
+    @Override
+    public int getActiveReadRpcHandlerCount() {
+        return delegate.getActiveReadRpcHandlerCount();
+    }
+
+    @Override
+    public int getActiveWriteRpcHandlerCount() {
+        return delegate.getActiveWriteRpcHandlerCount();
+    }
+
+    @Override
+    public int getActiveScanRpcHandlerCount() {
+        return delegate.getActiveScanRpcHandlerCount();
+    }
+
+}
diff --git a/phoenix-hbase-compat-1.5.0/pom.xml 
b/phoenix-hbase-compat-1.5.0/pom.xml
new file mode 100644
index 0000000..e125270
--- /dev/null
+++ b/phoenix-hbase-compat-1.5.0/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation=
+      "http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache</groupId>
+    <artifactId>apache</artifactId>
+    <version>21</version>
+  </parent>
+  <groupId>org.apache.phoenix</groupId>
+  <artifactId>phoenix-hbase-compat-1.5.0</artifactId>
+  <version>4.16.0-SNAPSHOT</version>
+  <name>Phoenix Hbase 1.5.0 compatibility</name>
+  <description>Compatibility module for HBase 1.5.0+</description>
+
+  <build>
+    <plugins>
+      <!-- Setup eclipse -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <version>2.9</version>
+        <configuration>
+          <buildcommands>
+            <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+          </buildcommands>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <!-- HBase dependencies -->
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-server</artifactId>
+      <version>1.5.0</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
diff --git 
a/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatDelegateRegionObserver.java
 
b/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatDelegateRegionObserver.java
new file mode 100644
index 0000000..d8b8266
--- /dev/null
+++ 
b/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatDelegateRegionObserver.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compat.hbase;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.coprocessor.RegionObserver;
+import org.apache.hadoop.hbase.regionserver.InternalScanner;
+import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
+import org.apache.hadoop.hbase.regionserver.ScanType;
+import org.apache.hadoop.hbase.regionserver.Store;
+import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
+import org.apache.hadoop.hbase.util.Pair;
+
+public abstract class CompatDelegateRegionObserver implements RegionObserver {
+
+    protected final RegionObserver delegate;
+
+    public CompatDelegateRegionObserver(RegionObserver delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public InternalScanner 
preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
+            Store store, KeyValueScanner memstoreScanner, InternalScanner s, 
long readPoint)
+            throws IOException {
+        return delegate.preFlushScannerOpen(c, store, memstoreScanner, s, 
readPoint);
+    }
+
+    @Override
+    public InternalScanner 
preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
+            Store store, List<? extends KeyValueScanner> scanners, ScanType 
scanType,
+            long earliestPutTs, InternalScanner s, CompactionRequest request, 
long readPoint)
+            throws IOException {
+        return delegate.preCompactScannerOpen(c, store, scanners, scanType, 
earliestPutTs, s,
+            request, readPoint);
+    }
+
+    @Override
+    public void 
preCommitStoreFile(ObserverContext<RegionCoprocessorEnvironment> ctx, byte[] 
family,
+            List<Pair<Path, Path>> pairs) throws IOException {
+        delegate.preCommitStoreFile(ctx, family, pairs);
+    }
+
+    @Override
+    public void 
postCommitStoreFile(ObserverContext<RegionCoprocessorEnvironment> ctx,
+            byte[] family, Path srcPath, Path dstPath) throws IOException {
+        delegate.postCommitStoreFile(ctx, family, srcPath, dstPath);
+    }
+}
\ No newline at end of file
diff --git 
a/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatObserverContext.java
 
b/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatObserverContext.java
new file mode 100644
index 0000000..1c3ccb0
--- /dev/null
+++ 
b/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatObserverContext.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compat.hbase;
+
+import org.apache.hadoop.hbase.CoprocessorEnvironment;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.security.User;
+
+public class CompatObserverContext<E extends CoprocessorEnvironment>
+        extends ObserverContext {
+
+    public CompatObserverContext(User caller) {
+        super(caller);
+    }
+}
diff --git 
a/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixMetaDataControllerEnvironment.java
 
b/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixMetaDataControllerEnvironment.java
new file mode 100644
index 0000000..f716326
--- /dev/null
+++ 
b/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixMetaDataControllerEnvironment.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compat.hbase;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.Coprocessor;
+import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.metrics.MetricRegistry;
+
+public abstract class CompatPhoenixMetaDataControllerEnvironment extends 
CoprocessorHost.Environment
+        implements RegionCoprocessorEnvironment {
+
+    protected RegionCoprocessorEnvironment env;
+
+    public 
CompatPhoenixMetaDataControllerEnvironment(RegionCoprocessorEnvironment env,
+            Coprocessor instance, int priority, int sequence, Configuration 
conf) {
+        super(instance, priority, sequence, conf);
+        this.env = env;
+    }
+
+    @Override
+    public MetricRegistry getMetricRegistryForRegionServer() {
+        return env.getMetricRegistryForRegionServer();
+    }
+}
diff --git 
a/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixRpcScheduler.java
 
b/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixRpcScheduler.java
new file mode 100644
index 0000000..ce2013d
--- /dev/null
+++ 
b/phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/CompatPhoenixRpcScheduler.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.compat.hbase;
+
+import org.apache.hadoop.hbase.ipc.RpcScheduler;
+
+public abstract class CompatPhoenixRpcScheduler extends RpcScheduler {
+    protected RpcScheduler delegate;
+
+    @Override
+    public int getActiveGeneralRpcHandlerCount() {
+        return delegate.getActiveGeneralRpcHandlerCount();
+    }
+
+    @Override
+    public int getActivePriorityRpcHandlerCount() {
+        return delegate.getActivePriorityRpcHandlerCount();
+    }
+
+    @Override
+    public int getActiveReplicationRpcHandlerCount() {
+        return delegate.getActiveReplicationRpcHandlerCount();
+    }
+
+    @Override
+    public int getReadQueueLength() {
+        return delegate.getReadQueueLength();
+    }
+
+    @Override
+    public int getWriteQueueLength() {
+        return delegate.getWriteQueueLength();
+    }
+
+    @Override
+    public int getScanQueueLength() {
+        return delegate.getScanQueueLength();
+    }
+
+    @Override
+    public int getActiveReadRpcHandlerCount() {
+        return delegate.getActiveReadRpcHandlerCount();
+    }
+
+    @Override
+    public int getActiveWriteRpcHandlerCount() {
+        return delegate.getActiveWriteRpcHandlerCount();
+    }
+
+    @Override
+    public int getActiveScanRpcHandlerCount() {
+        return delegate.getActiveScanRpcHandlerCount();
+    }
+
+}
diff --git a/phoenix-pherf/pom.xml b/phoenix-pherf/pom.xml
index 3f8422d..8296fe1ab 100644
--- a/phoenix-pherf/pom.xml
+++ b/phoenix-pherf/pom.xml
@@ -21,7 +21,7 @@
        <parent>
                <groupId>org.apache.phoenix</groupId>
                <artifactId>phoenix</artifactId>
-               <version>4.16.0-HBase-1.5-SNAPSHOT</version>
+               <version>4.16.0-SNAPSHOT</version>
        </parent>
 
        <artifactId>phoenix-pherf</artifactId>
diff --git a/phoenix-server/pom.xml b/phoenix-server/pom.xml
index 4f557fa..072d475 100644
--- a/phoenix-server/pom.xml
+++ b/phoenix-server/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.phoenix</groupId>
     <artifactId>phoenix</artifactId>
-    <version>4.16.0-HBase-1.5-SNAPSHOT</version>
+    <version>4.16.0-SNAPSHOT</version>
   </parent>
   <artifactId>phoenix-server</artifactId>
   <name>Phoenix Server</name>
@@ -93,7 +93,9 @@
               <goal>shade</goal>
             </goals>
             <configuration>
-              <finalName>phoenix-${project.version}-server</finalName>
+                <finalName>
+                  phoenix-${project.version}-${hbase.profile.string}-server
+                </finalName>
                 <shadedArtifactAttached>false</shadedArtifactAttached>
                 
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
                 <shadeTestJar>false</shadeTestJar>
diff --git a/phoenix-tracing-webapp/pom.xml b/phoenix-tracing-webapp/pom.xml
index e299991..7750a6a 100755
--- a/phoenix-tracing-webapp/pom.xml
+++ b/phoenix-tracing-webapp/pom.xml
@@ -22,7 +22,7 @@
     <parent>
       <groupId>org.apache.phoenix</groupId>
       <artifactId>phoenix</artifactId>
-      <version>4.16.0-HBase-1.5-SNAPSHOT</version>
+      <version>4.16.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>phoenix-tracing-webapp</artifactId>
diff --git a/pom.xml b/pom.xml
index 447b70c..1112ca9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.phoenix</groupId>
   <artifactId>phoenix</artifactId>
-  <version>4.16.0-HBase-1.5-SNAPSHOT</version>
+  <version>4.16.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <name>Apache Phoenix</name>
   <description>A SQL layer over HBase</description>
@@ -40,6 +40,8 @@
   </organization>
 
   <modules>
+    <module>phoenix-hbase-compat-1.5.0</module>
+    <module>phoenix-hbase-compat-1.4.0</module>
     <module>phoenix-core</module>
     <module>phoenix-pherf</module>
     <module>phoenix-client</module>
@@ -72,16 +74,20 @@
   </scm>
 
   <properties>
+    <!-- The HBase compatibility module that that will be included in
+    the shaded JARs and the assembly -->
+    <hbase.profile>1.5</hbase.profile>
+    <hbase.profile.string>hbase-${hbase.profile}</hbase.profile.string>
+
+    <!-- Hadoop Versions -->
+    <hadoop-two.version>2.7.5</hadoop-two.version>
+
     <!-- General Properties -->
     <antlr-input.dir>src/main/antlr3</antlr-input.dir>
     <antlr-output.dir>target/generated-sources/antlr3</antlr-output.dir>
     <test.output.tofile>true</test.output.tofile>
     <top.dir>${project.basedir}</top.dir>
 
-    <!-- Hadoop Versions -->
-    <hbase.version>1.5.0</hbase.version>
-    <hadoop-two.version>2.7.5</hadoop-two.version>
-
     <!-- Dependency versions -->
     <commons-cli.version>1.2</commons-cli.version>
     <hive.version>1.2.1</hive.version>
@@ -128,6 +134,7 @@
     <!-- Plugin versions -->
     <maven-eclipse-plugin.version>2.9</maven-eclipse-plugin.version>
     
<maven-build-helper-plugin.version>1.9.1</maven-build-helper-plugin.version>
+    <maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
 
     <!-- Plugin options -->
     <numForkedUT>8</numForkedUT>
@@ -147,6 +154,11 @@
       <plugins>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-enforcer-plugin</artifactId>
+          <version>${maven-enforcer-plugin.version}</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <configuration>
             <source>1.7</source>
@@ -371,12 +383,58 @@
           <artifactId>maven-bundle-plugin</artifactId>
           <version>2.5.3</version>
         </plugin>
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>exec-maven-plugin</artifactId>
+          <version>1.6.0</version>
+        </plugin>
       </plugins>
     </pluginManagement>
 
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>check-hbase-compatibility</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <evaluateBeanshell>
+                 <condition>
+                 <!-- Add check for any know incompatibilies in the below code 
-->
+                   import java.util.regex.Pattern;
+                   import java.lang.Integer;
+
+                   versionPattern = 
Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)[^.]*$");
+                   versionMatcher = versionPattern.matcher("${hbase.version}");
+                   versionMatcher.find();
+
+                   hbaseMajor = Integer.parseInt(versionMatcher.group(1));
+                   hbaseMinor = Integer.parseInt(versionMatcher.group(2));
+                   hbasePatch = Integer.parseInt(versionMatcher.group(3));
+
+                   hbaseMajor == 1 &amp;&amp; (
+                     ("${hbase.compat.version}".equals("1.5.0")
+                       &amp;&amp; hbaseMinor == 5)
+                     || ("${hbase.compat.version}".equals("1.4.0")
+                       &amp;&amp; hbaseMinor == 4)
+                     || ("${hbase.compat.version}".equals("1.3.0")
+                       &amp;&amp; hbaseMinor == 3)
+                   )
+                   </condition>
+                  </evaluateBeanshell>
+                </rules>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-checkstyle-plugin</artifactId>
         <version>3.1.0</version>
         <executions>
@@ -525,6 +583,17 @@
       </dependency>
       <dependency>
         <groupId>org.apache.phoenix</groupId>
+        <artifactId>phoenix-hbase-compat-1.5.0</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.phoenix</groupId>
+        <artifactId>phoenix-hbase-compat-1.4.0</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <!-- TODO Remove PQS and connector dependency rules -->
+      <dependency>
+        <groupId>org.apache.phoenix</groupId>
         <artifactId>phoenix-flume</artifactId>
         <version>${project.version}</version>
       </dependency>
@@ -1025,7 +1094,7 @@
   </dependencyManagement>
 
   <profiles>
-    <!-- disable doclint with 1.8+ JDKs-->
+    <!-- disable doclint with 1.8+ JDKs -->
     <profile>
       <id>java8-doclint-disabled</id>
       <activation>
@@ -1076,6 +1145,66 @@
         <scala.binary.version>2.10</scala.binary.version>
       </properties>
     </profile>
+    <!-- See BUILDING.md for profile selection -->
+    <profile>
+      <id>phoenix-hbase-compat-1.5.0-default</id>
+      <activation>
+        <property>
+          <name>!hbase.profile</name>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.phoenix</groupId>
+          <artifactId>phoenix-hbase-compat-1.5.0</artifactId>
+        </dependency>
+      </dependencies>
+      <properties>
+        <hbase.profile>1.5</hbase.profile>
+        <hbase.compat.version>1.5.0</hbase.compat.version>
+        <hbase.version>1.5.0</hbase.version>
+      </properties>
+    </profile>
+    <profile>
+      <id>phoenix-hbase-compat-1.5.0</id>
+      <activation>
+        <property>
+          <name>hbase.profile</name>
+          <value>1.5</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.phoenix</groupId>
+          <artifactId>phoenix-hbase-compat-1.5.0</artifactId>
+        </dependency>
+      </dependencies>
+      <properties>
+        <hbase.profile>1.5</hbase.profile>
+        <hbase.compat.version>1.5.0</hbase.compat.version>
+        <hbase.version>1.5.0</hbase.version>
+      </properties>
+    </profile>
+    <profile>
+      <id>phoenix-hbase-compat-1.4.0</id>
+      <activation>
+        <property>
+          <name>hbase.profile</name>
+          <value>1.4</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.phoenix</groupId>
+          <artifactId>phoenix-hbase-compat-1.4.0</artifactId>
+        </dependency>
+      </dependencies>
+      <properties>
+        <hbase.profile>1.4</hbase.profile>
+        <hbase.compat.version>1.4.0</hbase.compat.version>
+        <hbase.version>1.4.10</hbase.version>
+      </properties>
+    </profile>
   </profiles>
 
   <reporting>

Reply via email to