public long assign(RegionInfo regionInfo) throws IOException { return assign(regionInfo, null); }
protected void setUpMeta() throws Exception { rsDispatcher.setMockRsExecutor(new GoodRsExecutor()); am.assign(RegionInfoBuilder.FIRST_META_REGIONINFO); am.wakeMetaLoadedEvent(); }
/** * Uses directly the assignment manager to assign the region. and waits until the specified region * has completed assignment. * @return true if the region is assigned false otherwise. */ public boolean assignRegion(final RegionInfo regionInfo) throws IOException, InterruptedException { final AssignmentManager am = getHBaseCluster().getMaster().getAssignmentManager(); am.assign(regionInfo); return AssignmentTestingUtil.waitForAssignment(am, regionInfo); }
@Override public AssignRegionResponse assignRegion(RpcController controller, AssignRegionRequest req) throws ServiceException { try { master.checkInitialized(); final RegionSpecifierType type = req.getRegion().getType(); if (type != RegionSpecifierType.REGION_NAME) { LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME + " actual: " + type); } final byte[] regionName = req.getRegion().getValue().toByteArray(); final RegionInfo regionInfo = master.getAssignmentManager().getRegionInfo(regionName); if (regionInfo == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName)); final AssignRegionResponse arr = AssignRegionResponse.newBuilder().build(); if (master.cpHost != null) { master.cpHost.preAssign(regionInfo); } LOG.info(master.getClientIdAuditPrefix() + " assign " + regionInfo.getRegionNameAsString()); master.getAssignmentManager().assign(regionInfo); if (master.cpHost != null) { master.cpHost.postAssign(regionInfo); } return arr; } catch (IOException ioe) { throw new ServiceException(ioe); } }
/** * It is possible that when AM send assign meta request to a RS successfully, but RS can not send * back any response, which cause master startup hangs forever */ @Test public void testAssignMetaAndCrashBeforeResponse() throws Exception { tearDown(); // See setUp(), start HBase until set up meta util = new HBaseTestingUtility(); this.executor = Executors.newSingleThreadScheduledExecutor(); setupConfiguration(util.getConfiguration()); master = new MockMasterServices(util.getConfiguration(), this.regionsToRegionServers); rsDispatcher = new MockRSProcedureDispatcher(master); master.start(NSERVERS, rsDispatcher); am = master.getAssignmentManager(); // Assign meta rsDispatcher.setMockRsExecutor(new HangThenRSRestartExecutor()); am.assign(RegionInfoBuilder.FIRST_META_REGIONINFO); assertEquals(true, am.isMetaAssigned()); // set it back as default, see setUpMeta() am.wakeMetaLoadedEvent(); } }
@Test public void testWholesomeMerge() throws Exception { LOG.info("Starting " + name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName()); // Create table and load data. Table table = createTableAndLoadData(MASTER, tableName); // Merge 1st and 2nd region mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1); // Merge 2nd and 3th region PairOfSameType<RegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2); verifyRowCount(table, ROWSIZE); // Randomly choose one of the two merged regions RegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond(); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); AssignmentManager am = cluster.getMaster().getAssignmentManager(); RegionStates regionStates = am.getRegionStates(); // We should not be able to assign it again am.assign(hri); assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri)); // We should not be able to unassign it either am.unassign(hri); assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri)); table.close(); }
am.assign(hri); } catch (DoNotRetryIOException e) {
cluster.getMaster().getAssignmentManager().assign(region.getRegionInfo());
private void setUpMeta() throws Exception { rsDispatcher.setMockRsExecutor(new GoodRsExecutor()); am.assign(RegionInfoBuilder.FIRST_META_REGIONINFO); am.wakeMetaLoadedEvent(); }
/** * Uses directly the assignment manager to assign the region. and waits until the specified region * has completed assignment. * @return true if the region is assigned false otherwise. */ public boolean assignRegion(final RegionInfo regionInfo) throws IOException, InterruptedException { final AssignmentManager am = getHBaseCluster().getMaster().getAssignmentManager(); am.assign(regionInfo); return AssignmentTestingUtil.waitForAssignment(am, regionInfo); }
/** * It is possible that when AM send assign meta request to a RS successfully, * but RS can not send back any response, which cause master startup hangs forever */ @Test public void testAssignMetaAndCrashBeforeResponse() throws Exception { tearDown(); // See setUp(), start HBase until set up meta UTIL = new HBaseTestingUtility(); this.executor = Executors.newSingleThreadScheduledExecutor(); setupConfiguration(UTIL.getConfiguration()); master = new MockMasterServices(UTIL.getConfiguration(), this.regionsToRegionServers); rsDispatcher = new MockRSProcedureDispatcher(master); master.start(NSERVERS, rsDispatcher); am = master.getAssignmentManager(); // Assign meta rsDispatcher.setMockRsExecutor(new HangThenRSRestartExecutor()); am.assign(RegionInfoBuilder.FIRST_META_REGIONINFO); assertEquals(true, am.isMetaAssigned()); // set it back as default, see setUpMeta() am.wakeMetaLoadedEvent(); }
@Test public void testWholesomeMerge() throws Exception { LOG.info("Starting " + name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName()); // Create table and load data. Table table = createTableAndLoadData(MASTER, tableName); // Merge 1st and 2nd region mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1); // Merge 2nd and 3th region PairOfSameType<RegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2); verifyRowCount(table, ROWSIZE); // Randomly choose one of the two merged regions RegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond(); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); AssignmentManager am = cluster.getMaster().getAssignmentManager(); RegionStates regionStates = am.getRegionStates(); // We should not be able to assign it again am.assign(hri); assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri)); // We should not be able to unassign it either am.unassign(hri); assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri)); table.close(); }
am.assign(hri); assertFalse("Split region can't be assigned", regionStates.isRegionInTransition(hri));