HBASE-26098 Support passing a customized Configuration object when creating TestingHBaseCluster (#3540)
Signed-off-by: Yulin Niu <niuyulin@apache.org>
This commit is contained in:
parent
8fbc2d2400
commit
90f23d4743
|
@ -35,7 +35,7 @@ import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFacto
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
class TestingHBaseClusterImpl implements TestingHBaseCluster {
|
class TestingHBaseClusterImpl implements TestingHBaseCluster {
|
||||||
|
|
||||||
private final HBaseTestingUtil util = new HBaseTestingUtil();
|
private final HBaseTestingUtil util;
|
||||||
|
|
||||||
private final StartTestingClusterOption option;
|
private final StartTestingClusterOption option;
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ class TestingHBaseClusterImpl implements TestingHBaseCluster {
|
||||||
private boolean miniHBaseClusterRunning = false;
|
private boolean miniHBaseClusterRunning = false;
|
||||||
|
|
||||||
TestingHBaseClusterImpl(TestingHBaseClusterOption option) {
|
TestingHBaseClusterImpl(TestingHBaseClusterOption option) {
|
||||||
|
this.util = new HBaseTestingUtil(option.conf());
|
||||||
this.option = option.convert();
|
this.option = option.convert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.testing;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.StartTestingClusterOption;
|
import org.apache.hadoop.hbase.StartTestingClusterOption;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
|
||||||
|
@ -39,6 +40,11 @@ import org.apache.yetus.audience.InterfaceAudience;
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
public final class TestingHBaseClusterOption {
|
public final class TestingHBaseClusterOption {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for this testing cluster. Can be {@code null}.
|
||||||
|
*/
|
||||||
|
private final Configuration conf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of masters to start up. We'll start this many hbase masters.
|
* Number of masters to start up. We'll start this many hbase masters.
|
||||||
*/
|
*/
|
||||||
|
@ -95,9 +101,10 @@ public final class TestingHBaseClusterOption {
|
||||||
/**
|
/**
|
||||||
* Private constructor. Use {@link Builder#build()}.
|
* Private constructor. Use {@link Builder#build()}.
|
||||||
*/
|
*/
|
||||||
private TestingHBaseClusterOption(int numMasters, int numAlwaysStandByMasters,
|
private TestingHBaseClusterOption(Configuration conf, int numMasters, int numAlwaysStandByMasters,
|
||||||
int numRegionServers, List<Integer> rsPorts, int numDataNodes, String[] dataNodeHosts,
|
int numRegionServers, List<Integer> rsPorts, int numDataNodes, String[] dataNodeHosts,
|
||||||
int numZkServers, boolean createRootDir, boolean createWALDir) {
|
int numZkServers, boolean createRootDir, boolean createWALDir) {
|
||||||
|
this.conf = conf;
|
||||||
this.numMasters = numMasters;
|
this.numMasters = numMasters;
|
||||||
this.numAlwaysStandByMasters = numAlwaysStandByMasters;
|
this.numAlwaysStandByMasters = numAlwaysStandByMasters;
|
||||||
this.numRegionServers = numRegionServers;
|
this.numRegionServers = numRegionServers;
|
||||||
|
@ -109,6 +116,10 @@ public final class TestingHBaseClusterOption {
|
||||||
this.createWALDir = createWALDir;
|
this.createWALDir = createWALDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Configuration conf() {
|
||||||
|
return conf;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNumMasters() {
|
public int getNumMasters() {
|
||||||
return numMasters;
|
return numMasters;
|
||||||
}
|
}
|
||||||
|
@ -176,6 +187,7 @@ public final class TestingHBaseClusterOption {
|
||||||
* tests fail.
|
* tests fail.
|
||||||
*/
|
*/
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
private Configuration conf;
|
||||||
private int numMasters = 1;
|
private int numMasters = 1;
|
||||||
private int numAlwaysStandByMasters = 0;
|
private int numAlwaysStandByMasters = 0;
|
||||||
private int numRegionServers = 1;
|
private int numRegionServers = 1;
|
||||||
|
@ -193,8 +205,14 @@ public final class TestingHBaseClusterOption {
|
||||||
if (dataNodeHosts != null && dataNodeHosts.length != 0) {
|
if (dataNodeHosts != null && dataNodeHosts.length != 0) {
|
||||||
numDataNodes = dataNodeHosts.length;
|
numDataNodes = dataNodeHosts.length;
|
||||||
}
|
}
|
||||||
return new TestingHBaseClusterOption(numMasters, numAlwaysStandByMasters, numRegionServers,
|
return new TestingHBaseClusterOption(conf, numMasters, numAlwaysStandByMasters,
|
||||||
rsPorts, numDataNodes, dataNodeHosts, numZkServers, createRootDir, createWALDir);
|
numRegionServers, rsPorts, numDataNodes, dataNodeHosts, numZkServers, createRootDir,
|
||||||
|
createWALDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder conf(Configuration conf) {
|
||||||
|
this.conf = conf;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder numMasters(int numMasters) {
|
public Builder numMasters(int numMasters) {
|
||||||
|
|
Loading…
Reference in New Issue