From 64bbd489d4ae07841d635342424ccdc2d6ecf29a Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Wed, 12 Jun 2019 14:31:03 -0700 Subject: [PATCH] HBASE-22574 hbase-filesystem does not build against HBase 1 --- hbase-oss/pom.xml | 14 ---- .../apache/hadoop/hbase/oss/EmbeddedZK.java | 26 ++++--- .../hbase/oss/sync/TestTreeLockManager.java | 4 +- pom.xml | 72 ++++++++++++++++++- 4 files changed, 89 insertions(+), 27 deletions(-) diff --git a/hbase-oss/pom.xml b/hbase-oss/pom.xml index e21c84d..35c691a 100644 --- a/hbase-oss/pom.xml +++ b/hbase-oss/pom.xml @@ -359,20 +359,6 @@ test - - org.apache.hbase - hbase-zookeeper - ${hbase.version} - test - - - org.apache.hbase - hbase-zookeeper - ${hbase.version} - test-jar - test - - diff --git a/hbase-oss/src/test/java/org/apache/hadoop/hbase/oss/EmbeddedZK.java b/hbase-oss/src/test/java/org/apache/hadoop/hbase/oss/EmbeddedZK.java index c50940c..26d3788 100644 --- a/hbase-oss/src/test/java/org/apache/hadoop/hbase/oss/EmbeddedZK.java +++ b/hbase-oss/src/test/java/org/apache/hadoop/hbase/oss/EmbeddedZK.java @@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.oss; import java.net.InetAddress; import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseZKTestingUtility; import org.apache.hadoop.hbase.oss.Constants; import org.apache.hadoop.hbase.oss.sync.TreeLockManager; import org.apache.hadoop.hbase.oss.sync.ZKTreeLockManager; @@ -32,17 +31,24 @@ import org.apache.yetus.audience.InterfaceStability; @InterfaceStability.Unstable public class EmbeddedZK { - private static HBaseZKTestingUtility util = null; + private static Object testUtil = null; public static synchronized void conditionalStart(Configuration conf) throws Exception { - Class implementation = conf.getClass(Constants.SYNC_IMPL, TreeLockManager.class); + Class implementation = conf.getClass(Constants.SYNC_IMPL, TreeLockManager.class); boolean notConfigured = StringUtils.isEmpty(conf.get(Constants.ZK_CONN_STRING)); if (implementation == ZKTreeLockManager.class && notConfigured) { - if (util == null) { - util = new HBaseZKTestingUtility(conf); - util.startMiniZKCluster(); + if (testUtil == null) { + Class testUtilImpl; + try { + testUtilImpl = Class.forName("org.apache.hadoop.hbase.HBaseZKTestingUtility"); + } catch (ClassNotFoundException ex) { + testUtilImpl = Class.forName("org.apache.hadoop.hbase.HBaseTestingUtility"); + } + testUtil = testUtilImpl.getDeclaredConstructor(Configuration.class).newInstance(conf); + testUtil.getClass().getDeclaredMethod("startMiniZKCluster").invoke(testUtil); } - int port = util.getZkCluster().getClientPort(); + Object zkCluster = testUtil.getClass().getDeclaredMethod("getZkCluster").invoke(testUtil); + int port = (int) zkCluster.getClass().getDeclaredMethod("getClientPort").invoke(zkCluster); String hostname = InetAddress.getLocalHost().getHostName(); String connectionString = hostname + ":" + port; conf.set(Constants.ZK_CONN_STRING, connectionString); @@ -50,9 +56,9 @@ public class EmbeddedZK { } public static synchronized void conditionalStop() throws Exception { - if (util != null) { - util.shutdownMiniZKCluster(); - util = null; + if (testUtil != null) { + testUtil.getClass().getDeclaredMethod("shutdownMiniZKCluster").invoke(testUtil); + testUtil = null; } } } diff --git a/hbase-oss/src/test/java/org/apache/hadoop/hbase/oss/sync/TestTreeLockManager.java b/hbase-oss/src/test/java/org/apache/hadoop/hbase/oss/sync/TestTreeLockManager.java index 6fb3285..bafc121 100644 --- a/hbase-oss/src/test/java/org/apache/hadoop/hbase/oss/sync/TestTreeLockManager.java +++ b/hbase-oss/src/test/java/org/apache/hadoop/hbase/oss/sync/TestTreeLockManager.java @@ -16,14 +16,14 @@ * limitations under the License. */ -package org.apache.hadoop.hbase.oss; +package org.apache.hadoop.hbase.oss.sync; import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.hadoop.hbase.oss.HBaseObjectStoreSemanticsTest; import org.apache.hadoop.hbase.oss.sync.AutoLock; import org.apache.hadoop.hbase.oss.sync.NullTreeLockManager; -import org.apache.hadoop.hbase.oss.sync.TreeLockManager; import org.apache.hadoop.hbase.oss.sync.TreeLockManager.Depth; import org.apache.hadoop.fs.Path; import org.junit.Assert; diff --git a/pom.xml b/pom.xml index 97c697d..87f1468 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,9 @@ 23.0 2.9.2 3.2.0 - 2.1.4 + 1.4.10 + 2.1.4 + 2.2.1 4.12 1.2.17 1.7.25 @@ -126,5 +128,73 @@ ${hadoop3.version} + + + hbase2 + + + !hbase.profile + + + + ${hbase2.version} + + + + + org.apache.hbase + hbase-zookeeper + ${hbase2.version} + test + + + org.apache.hbase + hbase-zookeeper + ${hbase2.version} + test-jar + test + + + + + hbase1 + + + hbase.profile + 1 + + + + ${hbase1.version} + + + + org.apache.hbase.thirdparty + hbase-shaded-miscellaneous + ${hbase-thirdparty.version} + + + + org.apache.hbase + hbase-testing-util + ${hbase1.version} + test + + + org.apache.hbase + hbase-testing-util + ${hbase1.version} + test-jar + test + + + org.apache.hadoop + hadoop-minikdc + ${hadoop.version} + test + + + + -- 2.21.0