HBASE-2483 Some tests do not use ephemeral ports

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@946389 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Gray 2010-05-19 20:56:30 +00:00
parent 528b2c2d32
commit e6db59ae2b
2 changed files with 6 additions and 16 deletions

View File

@ -340,6 +340,7 @@ Release 0.21.0 - Unreleased
HBASE-2572 hbase/bin/set_meta_block_caching.rb:72: can't convert
Java::JavaLang::String into String (TypeError) - little
issue with script
HBASE-2483 Some tests do not use ephemeral ports
IMPROVEMENTS

View File

@ -68,6 +68,7 @@ public class MiniHBaseCluster implements HConstants {
public MiniHBaseCluster(Configuration conf, int numRegionServers)
throws IOException {
this.conf = conf;
conf.set(MASTER_PORT, "0");
init(numRegionServers);
}
@ -205,22 +206,10 @@ public class MiniHBaseCluster implements HConstants {
private void init(final int nRegionNodes) throws IOException {
try {
// start up a LocalHBaseCluster
while (true) {
try {
hbaseCluster = new LocalHBaseCluster(conf, nRegionNodes,
MiniHBaseCluster.MiniHBaseClusterMaster.class,
MiniHBaseCluster.MiniHBaseClusterRegionServer.class);
hbaseCluster.startup();
} catch (BindException e) {
//this port is already in use. try to use another (for multiple testing)
int port = conf.getInt(MASTER_PORT, DEFAULT_MASTER_PORT);
LOG.info("Failed binding Master to port: " + port, e);
port++;
conf.setInt(MASTER_PORT, port);
continue;
}
break;
}
hbaseCluster = new LocalHBaseCluster(conf, nRegionNodes,
MiniHBaseCluster.MiniHBaseClusterMaster.class,
MiniHBaseCluster.MiniHBaseClusterRegionServer.class);
hbaseCluster.startup();
} catch(IOException e) {
shutdown();
throw e;