@Override
  public SetRegionStateInMetaResponse setRegionStateInMeta(RpcController controller,
    SetRegionStateInMetaRequest request) throws ServiceException {
    rpcPreCheck("setRegionStateInMeta");
    SetRegionStateInMetaResponse.Builder builder = SetRegionStateInMetaResponse.newBuilder();
    final AssignmentManager am = server.getAssignmentManager();
    try {
      for (RegionSpecifierAndState s : request.getStatesList()) {
        final RegionSpecifier spec = s.getRegionSpecifier();
        final RegionInfo targetRegionInfo = getRegionInfo(spec);
        final RegionState.State targetState = RegionState.State.convert(s.getState());
        final RegionState.State currentState = Optional.ofNullable(targetRegionInfo)
          .map(info -> am.getRegionStates().getRegionState(info)).map(RegionState::getState)
          .orElseThrow(
            () -> new ServiceException("No existing state known for region '" + spec + "'."));
        LOG.info("{} set region={} state from {} to {}", server.getClientIdAuditPrefix(),
          targetRegionInfo, currentState, targetState);
        if (currentState == targetState) {
          LOG.debug("Proposed state matches current state. {}, {}", targetRegionInfo, currentState);
          continue;
        }
        MetaTableAccessor.updateRegionState(server.getConnection(), targetRegionInfo, targetState);
        // Loads from meta again to refresh AM cache with the new region state
        am.populateRegionStatesFromMeta(targetRegionInfo);
        builder.addStates(RegionSpecifierAndState.newBuilder().setRegionSpecifier(spec)
          .setState(currentState.convert()));
      }
    } catch (IOException e) {
      throw new ServiceException(e);
    }
    return builder.build();
  }
Update state of the region in meta only. This is required by hbck in some situations to cleanup
stuck assign/ unassign regions procedures for the table.
@return previous states of the regions
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java