Search in sources :

Example 36 with StartTestingClusterOption

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);
}
Also used : StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) BeforeClass(org.junit.BeforeClass)

Example 37 with StartTestingClusterOption

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);
}
Also used : HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) Before(org.junit.Before)

Example 38 with StartTestingClusterOption

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());
    }
}
Also used : ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) Test(org.junit.Test)

Example 39 with StartTestingClusterOption

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();
            }
        }
    }
}
Also used : ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) NetworkInterface(java.net.NetworkInterface) InetAddress(java.net.InetAddress) StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) Test(org.junit.Test)

Example 40 with StartTestingClusterOption

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);
        }
    }
}
Also used : NetworkInterface(java.net.NetworkInterface) InetAddress(java.net.InetAddress) StartTestingClusterOption(org.apache.hadoop.hbase.StartTestingClusterOption) Test(org.junit.Test)

Aggregations

StartTestingClusterOption (org.apache.hadoop.hbase.StartTestingClusterOption)42 BeforeClass (org.junit.BeforeClass)21 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)13 Test (org.junit.Test)13 Configuration (org.apache.hadoop.conf.Configuration)10 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)8 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)5 TableName (org.apache.hadoop.hbase.TableName)5 Table (org.apache.hadoop.hbase.client.Table)5 MasterThread (org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread)5 ServerName (org.apache.hadoop.hbase.ServerName)4 RegionLocator (org.apache.hadoop.hbase.client.RegionLocator)4 Path (org.apache.hadoop.fs.Path)3 ClusterMetrics (org.apache.hadoop.hbase.ClusterMetrics)3 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)3 Before (org.junit.Before)3 InetAddress (java.net.InetAddress)2 NetworkInterface (java.net.NetworkInterface)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2