All the clients need to know the master RPC end points while using master based registry for creating cluster connections. This patch amends the test cluster utility to populate these configs in the base configuration object used to spin up the cluster. The config key added here ("hbase.master.addrs") is used in the subsequent patches for HBASE-18095. Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
This commit is contained in:
parent
126ea28c80
commit
d742112ed9
|
@ -176,6 +176,11 @@ public final class HConstants {
|
||||||
/** Configuration key for master web API port */
|
/** Configuration key for master web API port */
|
||||||
public static final String MASTER_INFO_PORT = "hbase.master.info.port";
|
public static final String MASTER_INFO_PORT = "hbase.master.info.port";
|
||||||
|
|
||||||
|
/** Configuration key for the list of master host:ports **/
|
||||||
|
public static final String MASTER_ADDRS_KEY = "hbase.master.addrs";
|
||||||
|
|
||||||
|
public static final String MASTER_ADDRS_DEFAULT = "localhost:" + DEFAULT_MASTER_PORT;
|
||||||
|
|
||||||
/** Parameter name for the master type being backup (waits for primary to go inactive). */
|
/** Parameter name for the master type being backup (waits for primary to go inactive). */
|
||||||
public static final String MASTER_TYPE_BACKUP = "hbase.master.backup";
|
public static final String MASTER_TYPE_BACKUP = "hbase.master.backup";
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,14 @@ public class LocalHBaseCluster {
|
||||||
for (int i = 0; i < noMasters; i++) {
|
for (int i = 0; i < noMasters; i++) {
|
||||||
addMaster(new Configuration(conf), i);
|
addMaster(new Configuration(conf), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate the master address host ports in the config. This is needed if a master based
|
||||||
|
// registry is configured for client metadata services (HBASE-18095)
|
||||||
|
List<String> masterHostPorts = new ArrayList<>();
|
||||||
|
getMasters().forEach(masterThread ->
|
||||||
|
masterHostPorts.add(masterThread.getMaster().getServerName().getAddress().toString()));
|
||||||
|
conf.set(HConstants.MASTER_ADDRS_KEY, String.join(",", masterHostPorts));
|
||||||
|
|
||||||
// Start the HRegionServers.
|
// Start the HRegionServers.
|
||||||
this.regionServerClass =
|
this.regionServerClass =
|
||||||
(Class<? extends HRegionServer>)conf.getClass(HConstants.REGION_SERVER_IMPL,
|
(Class<? extends HRegionServer>)conf.getClass(HConstants.REGION_SERVER_IMPL,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -447,10 +447,14 @@ public class TestHBaseTestingUtility {
|
||||||
HBaseTestingUtility htu = new HBaseTestingUtility(defaultConfig);
|
HBaseTestingUtility htu = new HBaseTestingUtility(defaultConfig);
|
||||||
try {
|
try {
|
||||||
MiniHBaseCluster defaultCluster = htu.startMiniCluster();
|
MiniHBaseCluster defaultCluster = htu.startMiniCluster();
|
||||||
|
final String masterHostPort =
|
||||||
|
defaultCluster.getMaster().getServerName().getAddress().toString();
|
||||||
assertNotEquals(HConstants.DEFAULT_MASTER_INFOPORT,
|
assertNotEquals(HConstants.DEFAULT_MASTER_INFOPORT,
|
||||||
defaultCluster.getConfiguration().getInt(HConstants.MASTER_INFO_PORT, 0));
|
defaultCluster.getConfiguration().getInt(HConstants.MASTER_INFO_PORT, 0));
|
||||||
assertNotEquals(HConstants.DEFAULT_REGIONSERVER_INFOPORT,
|
assertNotEquals(HConstants.DEFAULT_REGIONSERVER_INFOPORT,
|
||||||
defaultCluster.getConfiguration().getInt(HConstants.REGIONSERVER_INFO_PORT, 0));
|
defaultCluster.getConfiguration().getInt(HConstants.REGIONSERVER_INFO_PORT, 0));
|
||||||
|
assertEquals(masterHostPort,
|
||||||
|
defaultCluster.getConfiguration().get(HConstants.MASTER_ADDRS_KEY));
|
||||||
} finally {
|
} finally {
|
||||||
htu.shutdownMiniCluster();
|
htu.shutdownMiniCluster();
|
||||||
}
|
}
|
||||||
|
@ -464,10 +468,14 @@ public class TestHBaseTestingUtility {
|
||||||
htu = new HBaseTestingUtility(altConfig);
|
htu = new HBaseTestingUtility(altConfig);
|
||||||
try {
|
try {
|
||||||
MiniHBaseCluster customCluster = htu.startMiniCluster();
|
MiniHBaseCluster customCluster = htu.startMiniCluster();
|
||||||
|
final String masterHostPort =
|
||||||
|
customCluster.getMaster().getServerName().getAddress().toString();
|
||||||
assertEquals(nonDefaultMasterInfoPort,
|
assertEquals(nonDefaultMasterInfoPort,
|
||||||
customCluster.getConfiguration().getInt(HConstants.MASTER_INFO_PORT, 0));
|
customCluster.getConfiguration().getInt(HConstants.MASTER_INFO_PORT, 0));
|
||||||
assertEquals(nonDefaultRegionServerPort,
|
assertEquals(nonDefaultRegionServerPort,
|
||||||
customCluster.getConfiguration().getInt(HConstants.REGIONSERVER_INFO_PORT, 0));
|
customCluster.getConfiguration().getInt(HConstants.REGIONSERVER_INFO_PORT, 0));
|
||||||
|
assertEquals(masterHostPort,
|
||||||
|
customCluster.getConfiguration().get(HConstants.MASTER_ADDRS_KEY));
|
||||||
} finally {
|
} finally {
|
||||||
htu.shutdownMiniCluster();
|
htu.shutdownMiniCluster();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue