public HRegionServer getRSForFirstRegionInTable(TableName tableName)
    throws IOException, InterruptedException {
    List<RegionInfo> regions = getRegions(tableName);
    if (regions == null || regions.isEmpty()) {
      return null;
    }
    LOG.debug("Found " + regions.size() + " regions for table " + tableName);

    byte[] firstRegionName =
      regions.stream().filter(r -> !r.isOffline()).map(RegionInfo::getRegionName).findFirst()
        .orElseThrow(() -> new IOException("online regions not found in table " + tableName));

    LOG.debug("firstRegionName=" + Bytes.toString(firstRegionName));
    long pause = getConfiguration().getLong(HConstants.HBASE_CLIENT_PAUSE,
      HConstants.DEFAULT_HBASE_CLIENT_PAUSE);
    int numRetries = getConfiguration().getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
      HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
    RetryCounter retrier = new RetryCounter(numRetries + 1, (int) pause, TimeUnit.MICROSECONDS);
    while (retrier.shouldRetry()) {
      int index = getMiniHBaseCluster().getServerWith(firstRegionName);
      if (index != -1) {
        return getMiniHBaseCluster().getRegionServerThreads().get(index).getRegionServer();
      }
      // Came back -1. Region may not be online yet. Sleep a while.
      retrier.sleepUntilNextRetry();
    }
    return null;
  }
Tool to get the reference to the region server object that holds the region of the specified
user table.
@param tableName user table to lookup in hbase:meta
@return region server that holds it, null if the row doesn't exist
hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseTestingUtility.java