@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); } }
/** * 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); }
/** * Start up a minicluster of hbase, dfs, and zookeeper. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @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 numSlaves, boolean createRootDir) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(numSlaves).numDataNodes(numSlaves).createRootDir(createRootDir).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 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. * @param createWALDir Whether to create a new WAL directory. * @return The mini HBase cluster created. * @see #shutdownMiniCluster() * @deprecated Use {@link #startMiniCluster(StartMiniClusterOption)} instead. */ @Deprecated public MiniHBaseCluster startMiniCluster(int numSlaves, boolean createRootDir, boolean createWALDir) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(numSlaves).numDataNodes(numSlaves).createRootDir(createRootDir) .createWALDir(createWALDir).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 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); }
/** * 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); }
@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; } }); }
@Test public void testNewCluster() throws Exception { enableMaintenanceMode(); TEST_UTIL.startMiniCluster(StartMiniClusterOption.builder() .numRegionServers(0) .numDataNodes(3) .build()); Connection conn = TEST_UTIL.getConnection(); assertTrue(conn.getAdmin().isMasterInMaintenanceMode()); try (Table table = conn.getTable(TableName.META_TABLE_NAME); ResultScanner scanner = table.getScanner(new Scan())) { assertNotNull("Could not read meta.", scanner.next()); } }
/** * Start up a minicluster of hbase, dfs and zookeeper clusters with given slave node number. * All other options will use default values, defined in {@link StartMiniClusterOption.Builder}. * @param numSlaves slave node number, for both HBase region server and HDFS data node. * @see #startMiniCluster(StartMiniClusterOption option) * @see #shutdownMiniDFSCluster() */ public MiniHBaseCluster startMiniCluster(int numSlaves) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(numSlaves).numDataNodes(numSlaves).build(); return startMiniCluster(option); }
public void setupCluster() throws Exception { setupConf(UTIL.getConfiguration()); StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(NUM_REGION_SERVERS).numDataNodes(NUM_REGION_SERVERS) .createRootDir(true).build(); UTIL.startMiniCluster(option); rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir(); fs = rootDir.getFileSystem(UTIL.getConfiguration()); }
@Before public void setup() throws Exception { setupConf(UTIL.getConfiguration()); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(2).numRegionServers(3).numDataNodes(3).build(); UTIL.startMiniCluster(option); }
@BeforeClass public static void beforeAllTests() throws Exception { // Start a cluster StartMiniClusterOption option = StartMiniClusterOption.builder() .masterClass(MyMaster.class).numRegionServers(NB_SERVERS).numDataNodes(NB_SERVERS).build(); TEST_UTIL.startMiniCluster(option); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); MASTER = cluster.getMaster(); MASTER.balanceSwitch(false); ADMIN = TEST_UTIL.getConnection().getAdmin(); }
@BeforeClass public static void setUpBeforeClass() throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(3).rsClass(MyRegionServer.class).numDataNodes(3).build(); TEST_UTIL.startMiniCluster(option); }
@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 before() throws Exception { TESTING_UTIL.getConfiguration().setInt(HConstants.HBASE_BALANCER_PERIOD, 60000); StartMiniClusterOption option = StartMiniClusterOption.builder() .masterClass(MyMaster.class).numRegionServers(NB_SERVERS).numDataNodes(NB_SERVERS).build(); TESTING_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 { // Use 2 DataNodes and default values for other StartMiniCluster options. TEST_UTIL.startMiniCluster(StartMiniClusterOption.builder().numDataNodes(2).build()); cluster = TEST_UTIL.getHBaseCluster(); dfsCluster = TEST_UTIL.getDFSCluster(); fs = TEST_UTIL.getTestFileSystem(); admin = TEST_UTIL.getAdmin(); // disable region rebalancing (interferes with log watching) cluster.getMaster().balanceSwitch(false); }
public void setupCluster() throws Exception { setupConf(UTIL.getConfiguration()); StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(NUM_REGION_SERVERS).numDataNodes(NUM_REGION_SERVERS) .createRootDir(true).build(); UTIL.startMiniCluster(option); rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir(); fs = rootDir.getFileSystem(UTIL.getConfiguration()); }