HBASE-2305 Client port for ZK has no default

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@923368 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-03-15 18:11:29 +00:00
parent 6860cdc27c
commit 29bc8bb519
4 changed files with 24 additions and 0 deletions

View File

@ -238,6 +238,7 @@ Release 0.21.0 - Unreleased
HBASE-2287 TypeError in shell (Alexey Kovyrin via Stack)
HBASE-2023 Client sync block can cause 1 thread of a multi-threaded client
to block all others (Karthik Ranganathan via Stack)
HBASE-2305 Client port for ZK has no default (Suraj Varma via Stack)
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable

View File

@ -93,6 +93,9 @@ public interface HConstants {
/** Default ZooKeeper pause value. In milliseconds. */
static final int DEFAULT_ZOOKEEPER_PAUSE = 2 * 1000;
/** default client port that the zookeeper listens on */
static final int DEFAULT_ZOOKEPER_CLIENT_PORT = 2181;
/** Parameter name for the root dir in ZK for this cluster */
static final String ZOOKEEPER_ZNODE_PARENT = "zookeeper.znode.parent";

View File

@ -61,6 +61,8 @@ public class HQuorumPeer implements HConstants {
private static final String ZK_CFG_PROPERTY = "hbase.zookeeper.property.";
private static final int ZK_CFG_PROPERTY_SIZE = ZK_CFG_PROPERTY.length();
private static final String ZK_CLIENT_PORT_KEY = ZK_CFG_PROPERTY
+ "clientPort";
/**
* Parse ZooKeeper configuration from HBase XML config and run a QuorumPeer.
@ -196,6 +198,11 @@ public class HQuorumPeer implements HConstants {
}
}
// If clientPort is not set, assign the default
if (zkProperties.getProperty(ZK_CLIENT_PORT_KEY) == null) {
zkProperties.put(ZK_CLIENT_PORT_KEY, DEFAULT_ZOOKEPER_CLIENT_PORT);
}
// Create the server.X properties.
int peerPort = conf.getInt("hbase.zookeeper.peerport", 2888);
int leaderPort = conf.getInt("hbase.zookeeper.leaderport", 3888);

View File

@ -24,7 +24,9 @@ import java.io.InputStream;
import java.util.Map;
import java.util.Properties;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestCase;
import org.apache.hadoop.hbase.HConstants;
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
@ -136,4 +138,15 @@ public class TestHQuorumPeer extends HBaseTestCase {
server = servers.get(Long.valueOf(0));
assertEquals("foo.bar", server.addr.getHostName());
}
/**
* Test Case for HBASE-2305
*/
public void testShouldAssignDefaultZookeeperClientPort() {
Configuration config = HBaseConfiguration.create();
config.clear();
Properties p = HQuorumPeer.makeZKProps(config);
assertNotNull(p);
assertEquals(2181, p.get("hbase.zookeeper.property.clientPort"));
}
}