@Override
  public List<TRegionInfo> getTableRegions(ByteBuffer tableName) throws IOError {
    try (RegionLocator locator = connectionCache.getRegionLocator(getBytes(tableName))) {
      List<HRegionLocation> regionLocations = locator.getAllRegionLocations();
      List<TRegionInfo> results = new ArrayList<>(regionLocations.size());
      for (HRegionLocation regionLocation : regionLocations) {
        RegionInfo info = regionLocation.getRegion();
        ServerName serverName = regionLocation.getServerName();
        TRegionInfo region = new TRegionInfo();
        region.serverName = ByteBuffer.wrap(Bytes.toBytes(serverName.getHostname()));
        region.port = serverName.getPort();
        region.startKey = ByteBuffer.wrap(info.getStartKey());
        region.endKey = ByteBuffer.wrap(info.getEndKey());
        region.id = info.getRegionId();
        region.name = ByteBuffer.wrap(info.getRegionName());
        region.version = HREGION_VERSION; // HRegion now not versioned, PB encoding used
        results.add(region);
      }
      return results;
    } catch (TableNotFoundException e) {
      // Return empty list for non-existing table
      return Collections.emptyList();
    } catch (IOException e) {
      LOG.warn(e.getMessage(), e);
      throw getIOError(e);
    }
  }
Returns the list of regions in the given table, or an empty list if the table does not exist
hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftHBaseServiceHandler.java