@BeforeClass public static void setUpBeforeClass() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MyObserver.class.getName()); UTIL = new HBaseTestingUtility(conf); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(MASTERS).numRegionServers(SLAVES).numDataNodes(SLAVES).build(); UTIL.startMiniCluster(option); CLUSTER = UTIL.getHBaseCluster(); CLUSTER.waitForActiveAndReadyMaster(); ADMIN = UTIL.getAdmin(); // Kill one region server List<RegionServerThread> rsts = CLUSTER.getLiveRegionServerThreads(); RegionServerThread rst = rsts.get(rsts.size() - 1); DEAD = rst.getRegionServer(); DEAD.stop("Test dead servers metrics"); while (rst.isAlive()) { Thread.sleep(500); } }
@BeforeClass public static void setUpBeforeClass() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, MyObserver.class.getName()); UTIL = new HBaseTestingUtility(conf); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(MASTERS).numRegionServers(SLAVES).numDataNodes(SLAVES).build(); UTIL.startMiniCluster(option); CLUSTER = UTIL.getHBaseCluster(); CLUSTER.waitForActiveAndReadyMaster(); ADMIN = UTIL.getAdmin(); // Kill one region server List<RegionServerThread> rsts = CLUSTER.getLiveRegionServerThreads(); RegionServerThread rst = rsts.get(rsts.size() - 1); DEAD = rst.getRegionServer(); DEAD.stop("Test dead servers status"); while (rst.isAlive()) { Thread.sleep(500); } }
@BeforeClass public static void beforeAllTests() throws Exception { int clientZkPort = 21828; clientZkCluster = new MiniZooKeeperCluster(TEST_UTIL.getConfiguration()); clientZkCluster.setDefaultClientPort(clientZkPort); clientZkCluster.startup(clientZkDir); // reduce the retry number and start log counter TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2); TEST_UTIL.getConfiguration().setInt("hbase.client.start.log.errors.counter", -1); TEST_UTIL.getConfiguration().setInt("zookeeper.recovery.retry", 1); // core settings for testing client ZK cluster TEST_UTIL.getConfiguration().set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST); TEST_UTIL.getConfiguration().setInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT, clientZkPort); // reduce zk session timeout to easier trigger session expiration TEST_UTIL.getConfiguration().setInt(HConstants.ZK_SESSION_TIMEOUT, ZK_SESSION_TIMEOUT); // Start a cluster with 2 masters and 3 regionservers. StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(2).numRegionServers(3).numDataNodes(3).build(); TEST_UTIL.startMiniCluster(option); }
@Test public void testClusterId() throws Exception { TEST_UTIL.startMiniZKCluster(); TEST_UTIL.startMiniDFSCluster(1); Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); //start region server, needs to be separate //so we get an unset clusterId rst = JVMClusterUtil.createRegionServerThread(conf, HRegionServer.class, 0); rst.start(); //Make sure RS is in blocking state Thread.sleep(10000); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(1).numRegionServers(0).build(); TEST_UTIL.startMiniHBaseCluster(option); rst.waitForServerOnline(); String clusterId = ZKClusterId.readClusterIdZNode(TEST_UTIL.getZooKeeperWatcher()); assertNotNull(clusterId); assertEquals(clusterId, rst.getRegionServer().getClusterId()); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numSlaves Slave node number, for both HBase region server and HDFS data node. * @param dataNodeHosts The hostnames of DataNodes to run on. If not null, its size will overwrite * HDFS data node number. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, String[] dataNodeHosts) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numSlaves) .numDataNodes(numSlaves).dataNodeHosts(dataNodeHosts).build(); return startMiniCluster(option); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numSlaves Slave node number, for both HBase region server and HDFS data node. * @param dataNodeHosts The hostnames of DataNodes to run on. If not null, its size will overwrite * HDFS data node number. * @param createRootDir Whether to create a new root or data directory path. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, String[] dataNodeHosts, boolean createRootDir) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numSlaves).createRootDir(createRootDir) .numDataNodes(numSlaves).dataNodeHosts(dataNodeHosts).build(); return startMiniCluster(option); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numSlaves Slave node number, for both HBase region server and HDFS data node. * @param createRootDir Whether to create a new root or data directory path. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, boolean createRootDir) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numSlaves).createRootDir(createRootDir) .numDataNodes(numSlaves).build(); return startMiniCluster(option); }
/** * Starts up mini hbase cluster. * Usually you won't want this. You'll usually want {@link #startMiniCluster()}. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numRegionServers Number of region servers. * @param rsPorts Ports that RegionServer should use. * @return The mini HBase cluster created. * @see #shutdownMiniHBaseCluster() * @deprecated Use {@link #startMiniHBaseCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniHBaseCluster(int numMasters, int numRegionServers, List<Integer> rsPorts) throws IOException, InterruptedException { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numRegionServers).rsPorts(rsPorts).build(); return startMiniHBaseCluster(option); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numRegionServers Number of region servers. * @param numDataNodes Number of datanodes. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numMasters, int numRegionServers, int numDataNodes) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numRegionServers).numDataNodes(numDataNodes) .build(); return startMiniCluster(option); }
/** * Starts up mini hbase cluster. * Usually you won't want this. You'll usually want {@link #startMiniCluster()}. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numRegionServers Number of region servers. * @return The mini HBase cluster created. * @see #shutdownMiniHBaseCluster() * @deprecated Use {@link #startMiniHBaseCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniHBaseCluster(int numMasters, int numRegionServers) throws IOException, InterruptedException { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numRegionServers).build(); return startMiniHBaseCluster(option); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numMasters Master node number. * @param numSlaves Slave node number, for both HBase region server and HDFS data node. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(numMasters).numRegionServers(numSlaves).numDataNodes(numSlaves).build(); return startMiniCluster(option); }
@Test public void testRegionServerHostnameReportedToMaster() throws Exception { TEST_UTIL.getConfiguration().setBoolean(HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build(); TEST_UTIL.startMiniCluster(option); boolean tablesOnMaster = LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration()); int expectedRS = NUM_RS + (tablesOnMaster? 1: 0); try (ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher()) { List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.getZNodePaths().rsZNode); assertEquals(expectedRS, servers.size()); } } }
@BeforeClass public static void before() throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(2).numRegionServers(3).numDataNodes(3).build(); TEST_UTIL.startMiniCluster(option); rcvr = new POJOSpanReceiver(new HBaseHTraceConfiguration(TEST_UTIL.getConfiguration())); TraceUtil.addReceiver(rcvr); TraceUtil.addSampler(new Sampler() { @Override public boolean next() { return true; } }); }
@BeforeClass public static void setUp() throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(2).numRegionServers(3).numDataNodes(3).build(); UTIL.startMiniCluster(option); }
@BeforeClass public static void setup() throws Exception { // Set master number and use default values for other options. StartMiniClusterOption option = StartMiniClusterOption.builder().numMasters(2).build(); TEST_UTIL.startMiniCluster(option); }
@BeforeClass public static void setUpBeforeClass() throws Exception { UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, MockHMaster.class, HMaster.class); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(2).numRegionServers(2).numDataNodes(2).build(); UTIL.startMiniCluster(option); UTIL.waitUntilAllSystemRegionsAssigned(); }
@Before public void setup() throws Exception { setupConf(UTIL.getConfiguration()); // Set master number and use default values for other options. StartMiniClusterOption option = StartMiniClusterOption.builder().numMasters(2).build(); UTIL.startMiniCluster(option); final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExec, false); ProcedureTestingUtility.setKillBeforeStoreUpdate(procExec, false); }
@Before public void setUp() throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(2).numRegionServers(2).build(); TEST_UTIL.startMiniHBaseCluster(option); }
@BeforeClass public static void setUp() throws Exception { UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class, HMaster.class); UTIL .startMiniCluster(StartMiniClusterOption.builder().numMasters(2).numRegionServers(2).build()); UTIL.createTable(NAME, CF); UTIL.waitTableAvailable(NAME); UTIL.getAdmin().balancerSwitch(false, true); }
@Before public void setup() throws Exception { setupConf(UTIL.getConfiguration()); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(2).numRegionServers(3).numDataNodes(3).build(); UTIL.startMiniCluster(option); }