diff --git src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java index 559a2f0..8bfdbb0 100644 --- src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java +++ src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java @@ -53,11 +53,19 @@ public class MiniZooKeeperCluster { private NIOServerCnxn.Factory standaloneServerFactory; private int tickTime = 0; + private org.apache.hadoop.conf.Configuration configuration; + /** Create mini ZooKeeper cluster. */ public MiniZooKeeperCluster() { this.started = false; } + /** Create mini ZooKeeper cluster with configuration (usually from test environment) */ + public MiniZooKeeperCluster(org.apache.hadoop.conf.Configuration configuration) { + this.started = false; + this.configuration = configuration; + } + public void setClientPort(int clientPort) { this.clientPort = clientPort; } @@ -106,7 +114,8 @@ public class MiniZooKeeperCluster { while (true) { try { standaloneServerFactory = - new NIOServerCnxn.Factory(new InetSocketAddress(clientPort)); + new NIOServerCnxn.Factory(new InetSocketAddress(clientPort), this.configuration.getInt("hbase.zookeeper.property.maxClientCnxns",2000)); + } catch (BindException e) { LOG.info("Failed binding ZK Server to client port: " + clientPort); //this port is already in use. try to use another diff --git src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 2dc621c..999b8b2 100644 --- src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -260,7 +260,7 @@ public class HBaseTestingUtility { if (this.zkCluster != null) { throw new IOException("Cluster already running at " + dir); } - this.zkCluster = new MiniZooKeeperCluster(); + this.zkCluster = new MiniZooKeeperCluster(this.getConfiguration()); int clientPort = this.zkCluster.startup(dir); this.conf.set("hbase.zookeeper.property.clientPort", Integer.toString(clientPort)); diff --git src/test/resources/hbase-site.xml src/test/resources/hbase-site.xml index 576eac2..8e9c47c 100644 --- src/test/resources/hbase-site.xml +++ src/test/resources/hbase-site.xml @@ -133,4 +133,14 @@ The port at which the clients will connect. + + hbase.zookeeper.property.maxClientCnxns + 2000 + Property from ZooKeeper's config zoo.cfg. + Limit on number of concurrent connections (at the socket level) that a + single client, identified by IP address, may make to a single member of + the ZooKeeper ensemble. Set high to avoid zk connection issues running + standalone and pseudo-distributed. + +