Java Code Examples for org.apache.hadoop.hbase.master.HMaster#abort()
The following examples show how to use
org.apache.hadoop.hbase.master.HMaster#abort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MiniHBaseCluster.java From hbase with Apache License 2.0 | 5 votes |
/** * Cause a master to exit without shutting down entire cluster. * @param serverNumber Used as index into a list. */ public String abortMaster(int serverNumber) { HMaster server = getMaster(serverNumber); LOG.info("Aborting " + server.toString()); server.abort("Aborting for tests", new Exception("Trace info")); return server.toString(); }
Example 2
Source File: TestZooKeeper.java From hbase with Apache License 2.0 | 5 votes |
/** * Master recovery when the znode already exists. Internally, this * test differs from {@link #testMasterSessionExpired} because here * the master znode will exist in ZK. */ @Test public void testMasterZKSessionRecoveryFailure() throws Exception { LOG.info("Starting " + name.getMethodName()); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); HMaster m = cluster.getMaster(); m.abort("Test recovery from zk session expired", new KeeperException.SessionExpiredException()); assertTrue(m.isStopped()); // Master doesn't recover any more testSanity(name.getMethodName()); }
Example 3
Source File: TestZooKeeper.java From hbase with Apache License 2.0 | 5 votes |
/** * Tests that the master does not call retainAssignment after recovery from expired zookeeper * session. Without the HBASE-6046 fix master always tries to assign all the user regions by * calling retainAssignment. */ @Test public void testRegionAssignmentAfterMasterRecoveryDueToZKExpiry() throws Exception { MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); cluster.startRegionServer(); cluster.waitForActiveAndReadyMaster(10000); HMaster m = cluster.getMaster(); final ZKWatcher zkw = m.getZooKeeper(); // now the cluster is up. So assign some regions. try (Admin admin = TEST_UTIL.getAdmin()) { byte[][] SPLIT_KEYS = new byte[][] { Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c"), Bytes.toBytes("d"), Bytes.toBytes("e"), Bytes.toBytes("f"), Bytes.toBytes("g"), Bytes.toBytes("h"), Bytes.toBytes("i"), Bytes.toBytes("j") }; TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(HConstants.CATALOG_FAMILY)).build(); admin.createTable(htd, SPLIT_KEYS); TEST_UTIL.waitUntilNoRegionsInTransition(60000); m.getZooKeeper().close(); MockLoadBalancer.retainAssignCalled = false; final int expectedNumOfListeners = countPermanentListeners(zkw); m.abort("Test recovery from zk session expired", new KeeperException.SessionExpiredException()); assertTrue(m.isStopped()); // Master doesn't recover any more // The recovered master should not call retainAssignment, as it is not a // clean startup. assertFalse("Retain assignment should not be called", MockLoadBalancer.retainAssignCalled); // number of listeners should be same as the value before master aborted // wait for new master is initialized cluster.waitForActiveAndReadyMaster(120000); final HMaster newMaster = cluster.getMasterThread().getMaster(); assertEquals(expectedNumOfListeners, countPermanentListeners(newMaster.getZooKeeper())); } }
Example 4
Source File: TestZooKeeper.java From hbase with Apache License 2.0 | 5 votes |
/** * Tests whether the logs are split when master recovers from a expired zookeeper session and an * RS goes down. */ @Test public void testLogSplittingAfterMasterRecoveryDueToZKExpiry() throws Exception { MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); cluster.startRegionServer(); TableName tableName = TableName.valueOf(name.getMethodName()); byte[] family = Bytes.toBytes("col"); try (Admin admin = TEST_UTIL.getAdmin()) { byte[][] SPLIT_KEYS = new byte[][] { Bytes.toBytes("1"), Bytes.toBytes("2"), Bytes.toBytes("3"), Bytes.toBytes("4"), Bytes.toBytes("5") }; TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(family)).build(); admin.createTable(htd, SPLIT_KEYS); } TEST_UTIL.waitUntilNoRegionsInTransition(60000); HMaster m = cluster.getMaster(); try (Table table = TEST_UTIL.getConnection().getTable(tableName)) { int numberOfPuts; for (numberOfPuts = 0; numberOfPuts < 6; numberOfPuts++) { Put p = new Put(Bytes.toBytes(numberOfPuts)); p.addColumn(Bytes.toBytes("col"), Bytes.toBytes("ql"), Bytes.toBytes("value" + numberOfPuts)); table.put(p); } m.abort("Test recovery from zk session expired", new KeeperException.SessionExpiredException()); assertTrue(m.isStopped()); // Master doesn't recover any more cluster.killRegionServer(TEST_UTIL.getRSForFirstRegionInTable(tableName).getServerName()); // Without patch for HBASE-6046 this test case will always timeout // with patch the test case should pass. int numberOfRows = 0; try (ResultScanner scanner = table.getScanner(new Scan())) { while (scanner.next() != null) { numberOfRows++; } } assertEquals("Number of rows should be equal to number of puts.", numberOfPuts, numberOfRows); } }
Example 5
Source File: TestRegionAssignedToMultipleRegionServers.java From hbase with Apache License 2.0 | 5 votes |
@Test public void test() throws Exception { RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(NAME).get(0).getRegionInfo(); AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager(); RegionStateNode rsn = am.getRegionStates().getRegionStateNode(region); ServerName sn = rsn.getRegionLocation(); ARRIVE = new CountDownLatch(1); HALT = true; am.moveAsync(new RegionPlan(region, sn, sn)); ARRIVE.await(); // let's restart the master EXCLUDE_SERVERS.add(rsn.getRegionLocation()); KILL = true; HMaster activeMaster = UTIL.getMiniHBaseCluster().getMaster(); activeMaster.abort("For testing"); activeMaster.join(); KILL = false; // sleep a while to reproduce the problem, as after the fix in HBASE-21472 the execution logic // is changed so the old code to reproduce the problem can not compile... Thread.sleep(10000); HALT = false; Thread.sleep(5000); HRegionServer rs = UTIL.getMiniHBaseCluster().getRegionServer(sn); assertNotNull(rs.getRegion(region.getEncodedName())); assertNull(UTIL.getOtherRegionServer(rs).getRegion(region.getEncodedName())); }