From 07e97d2b32550e3d71cf7ba30c5025fa48286e89 Mon Sep 17 00:00:00 2001 From: nkeywal Date: Thu, 4 Oct 2012 07:36:31 +0000 Subject: [PATCH] HBASE-6939 Add the possibility to set the ZK port in HBaseTestingUtility git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1393940 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/hadoop/hbase/HBaseTestingUtility.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 4c813bbfce7..ed2a453a09b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -571,6 +571,10 @@ public class HBaseTestingUtility { return startMiniZKCluster(dir,1); } + /** + * Start a mini ZK cluster. If the property "test.hbase.zookeeper.property.clientPort" is set + * the port mentionned is used as the default port for ZooKeeper. + */ private MiniZooKeeperCluster startMiniZKCluster(final File dir, int zooKeeperServerNum) throws Exception { @@ -579,6 +583,11 @@ public class HBaseTestingUtility { } this.passedZkCluster = false; this.zkCluster = new MiniZooKeeperCluster(this.getConfiguration()); + final int defPort = this.conf.getInt("test.hbase.zookeeper.property.clientPort", 0); + if (defPort > 0){ + // If there is a port in the config file, we use it. + this.zkCluster.setDefaultClientPort(defPort); + } int clientPort = this.zkCluster.startup(dir,zooKeeperServerNum); this.conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(clientPort));