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
This commit is contained in:
nkeywal 2012-10-04 07:36:31 +00:00
parent 610ea30534
commit 07e97d2b32
1 changed files with 9 additions and 0 deletions

View File

@ -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));