use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.
the class TestMetaAssignmentWithStopMaster method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
StartTestingClusterOption option = StartTestingClusterOption.builder().numMasters(2).numRegionServers(3).numDataNodes(3).build();
UTIL.startMiniCluster(option);
}
use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.
the class TestRegionServerAbort method setup.
@Before
public void setup() throws Exception {
testUtil = new HBaseTestingUtil();
conf = testUtil.getConfiguration();
conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, StopBlockingRegionObserver.class.getName());
conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, StopBlockingRegionObserver.class.getName());
// make sure we have multiple blocks so that the client does not prefetch all block locations
conf.set("dfs.blocksize", Long.toString(100 * 1024));
// prefetch the first block
conf.set(DFSConfigKeys.DFS_CLIENT_READ_PREFETCH_SIZE_KEY, Long.toString(100 * 1024));
conf.set(HConstants.REGION_IMPL, ErrorThrowingHRegion.class.getName());
testUtil.startMiniZKCluster();
dfsCluster = testUtil.startMiniDFSCluster(2);
StartTestingClusterOption option = StartTestingClusterOption.builder().numRegionServers(2).build();
cluster = testUtil.startMiniHBaseCluster(option);
}
use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.
the class TestRegionServerHostname method testRegionServerHostnameReportedToMaster.
@Test
public void testRegionServerHostnameReportedToMaster() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true);
StartTestingClusterOption option = StartTestingClusterOption.builder().numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
TEST_UTIL.startMiniCluster(option);
int expectedRS = NUM_RS;
try (ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher()) {
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode);
assertEquals(expectedRS, servers.size());
}
}
use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.
the class TestRegionServerHostname method testRegionServerHostname.
@Test
public void testRegionServerHostname() throws Exception {
Enumeration<NetworkInterface> netInterfaceList = NetworkInterface.getNetworkInterfaces();
while (netInterfaceList.hasMoreElements()) {
NetworkInterface ni = netInterfaceList.nextElement();
Enumeration<InetAddress> addrList = ni.getInetAddresses();
// iterate through host addresses and use each as hostname
while (addrList.hasMoreElements()) {
InetAddress addr = addrList.nextElement();
if (addr.isLoopbackAddress() || addr.isLinkLocalAddress() || addr.isMulticastAddress() || !addr.isSiteLocalAddress()) {
continue;
}
String hostName = addr.getHostName();
LOG.info("Found " + hostName + " on " + ni + ", addr=" + addr);
TEST_UTIL.getConfiguration().set(DNS.MASTER_HOSTNAME_KEY, hostName);
TEST_UTIL.getConfiguration().set(DNS.UNSAFE_RS_HOSTNAME_KEY, hostName);
StartTestingClusterOption option = StartTestingClusterOption.builder().numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
TEST_UTIL.startMiniCluster(option);
try {
ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode);
assertEquals(NUM_RS, servers.size());
for (String server : servers) {
assertTrue("From zookeeper: " + server + " hostname: " + hostName, server.startsWith(hostName.toLowerCase(Locale.ROOT) + ","));
}
zkw.close();
} finally {
TEST_UTIL.shutdownMiniCluster();
}
}
}
}
use of org.apache.hadoop.hbase.StartTestingClusterOption in project hbase by apache.
the class TestRegionServerHostname method testConflictRegionServerHostnameConfigurationsAbortServer.
@Test
public void testConflictRegionServerHostnameConfigurationsAbortServer() throws Exception {
Enumeration<NetworkInterface> netInterfaceList = NetworkInterface.getNetworkInterfaces();
while (netInterfaceList.hasMoreElements()) {
NetworkInterface ni = netInterfaceList.nextElement();
Enumeration<InetAddress> addrList = ni.getInetAddresses();
// iterate through host addresses and use each as hostname
while (addrList.hasMoreElements()) {
InetAddress addr = addrList.nextElement();
if (addr.isLoopbackAddress() || addr.isLinkLocalAddress() || addr.isMulticastAddress()) {
continue;
}
String hostName = addr.getHostName();
LOG.info("Found " + hostName + " on " + ni);
TEST_UTIL.getConfiguration().set(DNS.MASTER_HOSTNAME_KEY, hostName);
// "hbase.unsafe.regionserver.hostname" and "hbase.unsafe.regionserver.hostname.disable.master.reversedns"
// are mutually exclusive. Exception should be thrown if both are used.
TEST_UTIL.getConfiguration().set(DNS.UNSAFE_RS_HOSTNAME_KEY, hostName);
TEST_UTIL.getConfiguration().setBoolean(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true);
try {
StartTestingClusterOption option = StartTestingClusterOption.builder().numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
TEST_UTIL.startMiniCluster(option);
} catch (Exception e) {
Throwable t1 = e.getCause();
Throwable t2 = t1.getCause();
assertTrue(t1.getMessage() + " - " + t2.getMessage(), t2.getMessage().contains(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY + " and " + DNS.UNSAFE_RS_HOSTNAME_KEY + " are mutually exclusive"));
return;
} finally {
TEST_UTIL.shutdownMiniCluster();
}
assertTrue("Failed to validate against conflict hostname configurations", false);
}
}
}
Aggregations