@BeforeClass public static void beforeClass() throws Exception { UTIL.startMiniCluster(); if (!UTIL.getHBaseCluster().waitForActiveAndReadyMaster(30000)) { throw new RuntimeException("Active master not ready"); } }
@BeforeClass public static void beforeClass() throws Exception { // The info servers do not run in tests by default. // Set them to ephemeral ports so they will start UTIL.getConfiguration().setInt(HConstants.MASTER_INFO_PORT, 0); UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_INFO_PORT, 0); //We need to make sure that the server can be started as read only. UTIL.getConfiguration().setBoolean("hbase.master.ui.readonly", true); UTIL.startMiniCluster(); if (!UTIL.getHBaseCluster().waitForActiveAndReadyMaster(30000)) { throw new RuntimeException("Active master not ready"); } }
@BeforeClass public static void setupBeforeClass() throws Exception { Configuration conf = TEST_UTIL.getConfiguration(); // Setting FavoredNodeBalancer will enable favored nodes conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, LoadOnlyFavoredStochasticBalancer.class, LoadBalancer.class); conf.set(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, "" + SLAVES); // This helps test if RS get the appropriate FN updates. conf.set(BaseLoadBalancer.TABLES_ON_MASTER, "none"); TEST_UTIL.startMiniCluster(SLAVES); TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(WAIT_TIMEOUT); }
private HMaster abortAndWaitForMaster() throws IOException, InterruptedException { cluster.abortMaster(0); cluster.waitOnMaster(0); HMaster master = cluster.startMaster().getMaster(); cluster.waitForActiveAndReadyMaster(); return master; }
@BeforeClass public static void startCluster() throws Exception { metricsHelper = CompatibilityFactory.getInstance(MetricsAssertHelper.class); TEST_UTIL = new HBaseTestingUtility(); conf = TEST_UTIL.getConfiguration(); conf.getLong("hbase.splitlog.max.resubmit", 0); // Make the failure test faster conf.setInt("zookeeper.recovery.retry", 0); conf.setInt(HConstants.REGIONSERVER_INFO_PORT, -1); TEST_UTIL.startMiniCluster(2); cluster = TEST_UTIL.getHBaseCluster(); cluster.waitForActiveAndReadyMaster(); while (cluster.getLiveRegionServerThreads().size() < 2) { Threads.sleep(100); } }
@BeforeClass public static void startCluster() throws Exception { LOG.info("Starting cluster"); // Set master class and use default values for other options. StartMiniClusterOption option = StartMiniClusterOption.builder().masterClass(MyMaster.class) .rsClass(MyRegionServer.class).build(); TEST_UTIL.startMiniCluster(option); cluster = TEST_UTIL.getHBaseCluster(); LOG.info("Waiting for active/ready master"); cluster.waitForActiveAndReadyMaster(); master = cluster.getMaster(); }
private void startCluster(int numRS) throws Exception { SplitLogCounters.resetCounters(); LOG.info("Starting cluster"); conf.setLong("hbase.splitlog.max.resubmit", 0); // Make the failure test faster conf.setInt("zookeeper.recovery.retry", 0); conf.setInt(HConstants.REGIONSERVER_INFO_PORT, -1); conf.setFloat(HConstants.LOAD_BALANCER_SLOP_KEY, (float) 100.0); // no load balancing conf.setInt(HBASE_SPLIT_WAL_MAX_SPLITTER, 3); conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10); conf.set("hbase.wal.provider", getWalProvider()); StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(NUM_MASTERS).numRegionServers(numRS).build(); TEST_UTIL.startMiniHBaseCluster(option); cluster = TEST_UTIL.getHBaseCluster(); LOG.info("Waiting for active/ready master"); cluster.waitForActiveAndReadyMaster(); master = cluster.getMaster(); TEST_UTIL.waitFor(120000, 200, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return cluster.getLiveRegionServerThreads().size() >= numRS; } }); }
@BeforeClass public static void setupBeforeClass() throws Exception { TEST_UTIL = new HBaseTestingUtility(); conf = TEST_UTIL.getConfiguration(); // Try to frequently clean up compacted files conf.setInt("hbase.hfile.compaction.discharger.interval", 1000); conf.setInt("hbase.master.hfilecleaner.ttl", 1000); TEST_UTIL.startMiniCluster(1); TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(); TEST_UTIL.waitUntilAllRegionsAssigned(TableName.META_TABLE_NAME); rootDir = FSUtils.getRootDir(conf); fs = TEST_UTIL.getTestFileSystem(); }
@BeforeClass public static void startCluster() throws Exception { LOG.info("Starting cluster"); TEST_UTIL = new HBaseTestingUtility(); // Set master class and use default values for other options. StartMiniClusterOption option = StartMiniClusterOption.builder() .masterClass(TestMasterMetrics.MyMaster.class).build(); TEST_UTIL.startMiniCluster(option); cluster = TEST_UTIL.getHBaseCluster(); LOG.info("Waiting for active/ready master"); cluster.waitForActiveAndReadyMaster(); master = cluster.getMaster(); }
/** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { Configuration conf = TEST_UTIL.getConfiguration(); conf.setStrings(HConstants.REGION_SERVER_IMPL, RegionServerWithFakeRpcServices.class.getName()); TEST_UTIL.startMiniCluster(1); TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(); TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME.META_TABLE_NAME); badRS = TEST_UTIL.getHBaseCluster().getRegionServer(0); assertTrue(badRS.getRSRpcServices() instanceof FakeRSRpcServices); HTableDescriptor table = new HTableDescriptor(TABLE_NAME); HColumnDescriptor fam = new HColumnDescriptor(FAMILY); fam.setMaxVersions(2); table.addFamily(fam); TEST_UTIL.createTable(table, null); }
@BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(1); TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(); TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME.META_TABLE_NAME); TEST_UTIL.createTable(TABLE_NAME, FAMILY); }
@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); } }
@Test public void testEnableRSGroup() throws IOException, InterruptedException { TEST_UTIL.getMiniHBaseCluster().stopMaster(0); TEST_UTIL.getMiniHBaseCluster().waitOnMaster(0); LOG.info("stopped master..."); final Configuration conf = TEST_UTIL.getMiniHBaseCluster().getConfiguration(); conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, RSGroupAdminEndpoint.class.getName()); conf.set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, RSGroupBasedLoadBalancer.class.getName()); TEST_UTIL.getMiniHBaseCluster().startMaster(); TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(60000); LOG.info("started master..."); // check if master started successfully assertTrue(TEST_UTIL.getMiniHBaseCluster().getMaster() != null); // wait RSGroupBasedLoadBalancer online RSGroupBasedLoadBalancer loadBalancer = (RSGroupBasedLoadBalancer) TEST_UTIL.getMiniHBaseCluster().getMaster().getLoadBalancer(); long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start <= 60000 && !loadBalancer.isOnline()) { LOG.info("waiting for rsgroup load balancer onLine..."); sleep(200); } assertTrue(loadBalancer.isOnline()); }
@BeforeClass public static void startCluster() throws Exception { metricsHelper = CompatibilityFactory.getInstance(MetricsAssertHelper.class); TEST_UTIL = new HBaseTestingUtility(); TABLES_ON_MASTER = LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration()); conf = TEST_UTIL.getConfiguration(); conf.getLong("hbase.splitlog.max.resubmit", 0); // Make the failure test faster conf.setInt("zookeeper.recovery.retry", 0); // testMobMetrics creates few hfiles and manages compaction manually. conf.setInt("hbase.hstore.compactionThreshold", 100); conf.setInt("hbase.hstore.compaction.max", 100); conf.setInt("hbase.regionserver.periodicmemstoreflusher.rangeofdelayseconds", 4*60); conf.setInt(HConstants.REGIONSERVER_INFO_PORT, -1); TEST_UTIL.startMiniCluster(); cluster = TEST_UTIL.getHBaseCluster(); cluster.waitForActiveAndReadyMaster(); admin = TEST_UTIL.getAdmin(); connection = TEST_UTIL.getConnection(); while (cluster.getLiveRegionServerThreads().isEmpty() && cluster.getRegionServer(0) == null && rs.getRegionServerMetrics() == null) { Threads.sleep(100); } rs = cluster.getRegionServer(0); metricsRegionServer = rs.getRegionServerMetrics(); serverSource = metricsRegionServer.getMetricsSource(); }
@After public void after() throws Exception { try { TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(10000); // Some regionserver could fail to delete its znode. // So shutdown could hang. Let's kill them all instead. TEST_UTIL.getHBaseCluster().killAll(); // Still need to clean things up TEST_UTIL.shutdownMiniHBaseCluster(); } finally { TEST_UTIL.getTestFileSystem().delete(FSUtils.getRootDir(TEST_UTIL.getConfiguration()), true); ZKUtil.deleteNodeRecursively(TEST_UTIL.getZooKeeperWatcher(), "/hbase"); } }
@Before public void startCluster() throws Exception { TEST_UTIL.startMiniCluster(SLAVES); TEST_UTIL.getDFSCluster().waitClusterUp(); TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(120*1000); cluster = TEST_UTIL.getMiniHBaseCluster(); admin = TEST_UTIL.getAdmin(); admin.setBalancerRunning(false, true); }
@Test public void testMasterRestart() throws Exception { Table table = TEST_UTIL.createTable(TABLE_NAME, FAMILY, TEST_UTIL.KEYS_FOR_HBA_CREATE_TABLE); for (int i = 0; i < 10; i++) { TEST_UTIL.loadTable(table, FAMILY); } HRegionServer testServer = TEST_UTIL.getHBaseCluster().getRegionServer(0); List<FileStatus> wals = splitWALManager.getWALsToSplit(testServer.getServerName(), false); Assert.assertEquals(1, wals.size()); SplitWALProcedure splitWALProcedure = new SplitWALProcedure(wals.get(0).getPath().toString(), testServer.getServerName()); long pid = ProcedureTestingUtility.submitProcedure(master.getMasterProcedureExecutor(), splitWALProcedure, HConstants.NO_NONCE, HConstants.NO_NONCE); TEST_UTIL.waitFor(5000, () -> splitWALProcedure.getWorker() != null); // Kill master TEST_UTIL.getHBaseCluster().killMaster(master.getServerName()); TEST_UTIL.getHBaseCluster().waitForMasterToStop(master.getServerName(), 20000); // restart master TEST_UTIL.getHBaseCluster().startMaster(); TEST_UTIL.getHBaseCluster().waitForActiveAndReadyMaster(); this.master = TEST_UTIL.getHBaseCluster().getMaster(); ProcedureTestingUtility.waitProcedure(master.getMasterProcedureExecutor(), pid); Optional<Procedure<?>> procedure = master.getProcedures().stream().filter(p -> p.getProcId() == pid).findAny(); // make sure procedure is successful and wal is deleted Assert.assertTrue(procedure.isPresent()); Assert.assertTrue(procedure.get().isSuccess()); Assert.assertFalse(TEST_UTIL.getTestFileSystem().exists(wals.get(0).getPath())); }
/** * Kill the master and wait for a new active master to show up * * @param cluster * @return the new active master * @throws InterruptedException * @throws java.io.IOException */ private HMaster killActiveAndWaitForNewActive(MiniHBaseCluster cluster) throws InterruptedException, IOException { int activeIndex = getActiveMasterIndex(cluster); HMaster active = cluster.getMaster(); cluster.stopMaster(activeIndex); cluster.waitOnMaster(activeIndex); assertTrue(cluster.waitForActiveAndReadyMaster()); // double check this is actually a new master HMaster newActive = cluster.getMaster(); assertFalse(active == newActive); return newActive; }
@BeforeClass public static void setupCluster() throws Exception { UTIL.startMiniCluster(RS_NUMBER); UTIL.getHBaseCluster().waitForActiveAndReadyMaster(); conf = UTIL.getConfiguration(); HMaster master = UTIL.getHBaseCluster().getMaster(); fs = master.getMasterFileSystem().getWALFileSystem(); syncReplicationReplayWALManager = master.getSyncReplicationReplayWALManager(); procExec = master.getMasterProcedureExecutor(); }