@Override public void startMaster(String hostname, int port) throws IOException { this.startMaster(); }
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 beforeClass() throws Exception { // enable store file refreshing HTU.getConfiguration().setInt(StorefileRefresherChore.REGIONSERVER_STOREFILE_REFRESH_PERIOD, REFRESH_PERIOD); HTU.getConfiguration().setFloat("hbase.regionserver.logroll.multiplier", 0.0001f); HTU.getConfiguration().setInt("replication.source.size.capacity", 10240); HTU.getConfiguration().setLong("replication.source.sleepforretries", 100); HTU.getConfiguration().setInt("hbase.regionserver.maxlogs", 2); HTU.getConfiguration().setLong("hbase.master.logcleaner.ttl", 10); HTU.getConfiguration().setInt("zookeeper.recovery.retry", 1); HTU.getConfiguration().setInt("zookeeper.recovery.retry.intervalmill", 10); // Wait for primary call longer so make sure that it will get exception from the primary call HTU.getConfiguration().setInt("hbase.client.primaryCallTimeout.get", 1000000); HTU.getConfiguration().setInt("hbase.client.primaryCallTimeout.scan", 1000000); // Retry less so it can fail faster HTU.getConfiguration().setInt("hbase.client.retries.number", 1); // Enable meta replica at server side HTU.getConfiguration().setInt("hbase.meta.replica.count", 2); // Make sure master does not host system tables. HTU.getConfiguration().set("hbase.balancer.tablesOnMaster", "none"); // Set system coprocessor so it can be applied to meta regions HTU.getConfiguration().set("hbase.coprocessor.region.classes", RegionServerHostingPrimayMetaRegionSlowOrStopCopro.class.getName()); HTU.getConfiguration().setInt(HConstants.HBASE_CLIENT_META_REPLICA_SCAN_TIMEOUT, META_SCAN_TIMEOUT_IN_MILLISEC * 1000); HTU.startMiniCluster(NB_SERVERS); HTU.getHBaseCluster().startMaster(); }
@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()); }
private void restartMaster() throws Exception { UTIL.getHBaseCluster().getMaster(0).stop("Stopping to start again"); UTIL.getHBaseCluster().waitOnMaster(0); UTIL.getHBaseCluster().startMaster(); waitForQuotaInitialize(UTIL); }
killMaster(TEST_UTIL.getMiniHBaseCluster().getMaster().getServerName()); assertTrue(fs.exists(hbckLockPath)); TEST_UTIL.getMiniHBaseCluster().startMaster(); TEST_UTIL.waitFor(30000, () -> TEST_UTIL.getMiniHBaseCluster().getMaster() != null && TEST_UTIL.getMiniHBaseCluster().getMaster().isInitialized()); assertTrue(fs.exists(hbckLockPath)); TEST_UTIL.getMiniHBaseCluster().startMaster(); assertTrue(fs.exists(hbckLockPath)); fs.delete(hbckLockPath, true); TEST_UTIL.getMiniHBaseCluster().startMaster(); TEST_UTIL.waitFor(30000, () -> TEST_UTIL.getMiniHBaseCluster().getMaster() != null && TEST_UTIL.getMiniHBaseCluster().getMaster().isInitialized());
@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())); }
@Test public void test() throws InterruptedException, IOException { HMaster master = UTIL.getMiniHBaseCluster().stopMaster(0).getMaster(); // Shutdown master before shutting down rs UTIL.waitFor(30000, () -> !master.isAlive()); RegionServerThread thread = null; for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) { if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) { thread = t; break; } } // shutdown rs thread.getRegionServer().abort("For testing"); thread.join(); // restart master UTIL.getMiniHBaseCluster().startMaster(); // make sure that we can schedule a SCP for the crashed server which WAL is disabled and bring // the region online. try (Table table = UTIL.getConnection().getTableBuilder(TABLE_NAME, null).setOperationTimeout(30000).build()) { table.put(new Put(Bytes.toBytes(1)).addColumn(CF, CQ, Bytes.toBytes(1))); assertEquals(1, Bytes.toInt(table.get(new Get(Bytes.toBytes(1))).getValue(CF, CQ))); } } }
UTIL.getMiniHBaseCluster().startMaster(); t.join();
cluster.getConf().setInt( ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 3); master = cluster.startMaster().getMaster(); for (int i = 0; i < 3; i++) { cluster.getConf().setInt(HConstants.REGIONSERVER_PORT, rsPorts[i]);
UTIL.getMiniHBaseCluster().startMaster(); waitNoMaster(); UTIL.getMiniHBaseCluster().startMaster(); waitNoMaster(); FAIL_LOAD = false; HMaster master = UTIL.getMiniHBaseCluster().startMaster().getMaster(); UTIL.waitFor(30000, () -> master.isActiveMaster() && master.isInitialized());
activeMaster = cluster.startMaster().getMaster(); LOG.info("Waiting for master to be ready"); cluster.waitForActiveAndReadyMaster();
@Test public void testMigration() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY_STR); TEST_UTIL.getAdmin().disableTable(tableName); // Table is disabled. Now remove the DISABLED column from the hbase:meta for this table's // region. We want to see if Master will read the DISABLED from zk and make use of it as // though it were reading the zk table state written by a hbase-1.x cluster. TableState state = MetaTableAccessor.getTableState(TEST_UTIL.getConnection(), tableName); assertTrue("State=" + state, state.getState().equals(TableState.State.DISABLED)); MetaTableAccessor.deleteTableState(TEST_UTIL.getConnection(), tableName); assertTrue(MetaTableAccessor.getTableState(TEST_UTIL.getConnection(), tableName) == null); // Now kill Master so a new one can come up and run through the zk migration. HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); master.stop("Restarting"); while (!master.isStopped()) { Threads.sleep(1); } assertTrue(master.isStopped()); JVMClusterUtil.MasterThread newMasterThread = TEST_UTIL.getMiniHBaseCluster().startMaster(); master = newMasterThread.getMaster(); while (!master.isInitialized()) { Threads.sleep(1); } assertTrue(MetaTableAccessor.getTableState(TEST_UTIL.getConnection(), tableName).getState().equals(TableState.State.DISABLED)); } }
/** * test of that unmanaged HConnections are able to reconnect * properly (see HBASE-5058) */ @Test public void testUnmanagedHConnectionReconnect() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); Table t = conn.getTable(tableName); try (Admin admin = conn.getAdmin()) { assertTrue(admin.tableExists(tableName)); assertTrue(t.get(new Get(ROW)).isEmpty()); } // stop the master MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); cluster.stopMaster(0, false); cluster.waitOnMaster(0); // start up a new master cluster.startMaster(); assertTrue(cluster.waitForActiveAndReadyMaster()); // test that the same unmanaged connection works with a new // Admin and can connect to the new master; boolean tablesOnMaster = LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration()); try (Admin admin = conn.getAdmin()) { assertTrue(admin.tableExists(tableName)); assertTrue(admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)) .getLiveServerMetrics().size() == SLAVES + (tablesOnMaster ? 1 : 0)); } }
cluster.waitForMasterToStop(master.getServerName(), 60000); cluster.startMaster(); cluster.waitForActiveAndReadyMaster(); master = cluster.getMaster();
@Test public void test() throws Exception { List<RegionInfo> regionInfos = admin.getRegions(TABLE_NAME); MergeTableRegionsProcedure mergeTableRegionsProcedure = new MergeTableRegionsProcedure( UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor() .getEnvironment(), regionInfos.get(0), regionInfos.get(1)); long procID = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor() .submitProcedure(mergeTableRegionsProcedure); mergeCommitArrive.await(); UTIL.getMiniHBaseCluster().stopMaster(0); UTIL.getMiniHBaseCluster().startMaster(); //wait until master initialized UTIL.waitFor(30000, () -> UTIL.getMiniHBaseCluster().getMaster() != null && UTIL .getMiniHBaseCluster().getMaster().isInitialized()); UTIL.waitFor(30000, () -> UTIL.getMiniHBaseCluster().getMaster() .getMasterProcedureExecutor().isFinished(procID)); Assert.assertTrue("Found region RIT, that's impossible!", UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager() .getRegionsInTransition().size() == 0); }
@Test public void testWorkerReloadWhenMasterRestart() throws Exception { List<FakeServerProcedure> testProcedures = new ArrayList<>(); for (int i = 0; i < 3; i++) { FakeServerProcedure procedure = new FakeServerProcedure(TEST_UTIL.getHBaseCluster().getRegionServer(i).getServerName()); testProcedures.add(procedure); ProcedureTestingUtility.submitProcedure(master.getMasterProcedureExecutor(), procedure, HConstants.NO_NONCE, HConstants.NO_NONCE); } TEST_UTIL.waitFor(10000, () -> testProcedures.get(2).isWorkerAcquired()); // 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(); FakeServerProcedure failedProcedure = new FakeServerProcedure(TEST_UTIL.getHBaseCluster().getServerHoldingMeta()); ProcedureTestingUtility.submitProcedure(master.getMasterProcedureExecutor(), failedProcedure, HConstants.NO_NONCE, HConstants.NO_NONCE); TEST_UTIL.waitFor(20000, () -> failedProcedure.isTriedToAcquire()); Assert.assertFalse(failedProcedure.isWorkerAcquired()); for (int i = 0; i < 3; i++) { testProcedures.get(i).countDown(); } failedProcedure.countDown(); }
@Test public void test() throws Exception { JVMClusterUtil.RegionServerThread rsThread = null; for (JVMClusterUtil.RegionServerThread t : UTIL.getMiniHBaseCluster() .getRegionServerThreads()) { if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) { rsThread = t; break; } } // find the rs and hri of the table HRegionServer rs = rsThread.getRegionServer(); RegionInfo hri = rs.getRegions(TABLE_NAME).get(0).getRegionInfo(); TransitRegionStateProcedure moveRegionProcedure = TransitRegionStateProcedure.reopen( UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment(), hri); RegionStateNode regionNode = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager() .getRegionStates().getOrCreateRegionStateNode(hri); regionNode.setProcedure(moveRegionProcedure); UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor() .submitProcedure(moveRegionProcedure); countDownLatch.await(); UTIL.getMiniHBaseCluster().stopMaster(0); UTIL.getMiniHBaseCluster().startMaster(); // wait until master initialized UTIL.waitFor(30000, () -> UTIL.getMiniHBaseCluster().getMaster() != null && UTIL.getMiniHBaseCluster().getMaster().isInitialized()); Assert.assertTrue("Should be 3 RS after master restart", UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size() == 3); }
activeMaster = cluster.startMaster(); cluster.waitForActiveAndReadyMaster(); backupMaster = cluster.startMaster();
masterThread.getMaster().stop("For testing"); masterThread.join(); UTIL.getMiniHBaseCluster().startMaster(); masterThread.join(); UTIL.getMiniHBaseCluster().startMaster();