Class RegionLocatorOverAsyncTableRegionLocator

java.lang.Object
org.apache.hadoop.hbase.client.RegionLocatorOverAsyncTableRegionLocator
All Implemented Interfaces:
Closeable, AutoCloseable, RegionLocator

The RegionLocator implementation based on AsyncTableRegionLocator.
  • Field Details

  • Constructor Details

  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getRegionLocation

      public HRegionLocation getRegionLocation(byte[] row, int replicaId, boolean reload) throws IOException
      Description copied from interface: RegionLocator
      Finds the region with the given replica id on which the given row is being served.
      Specified by:
      getRegionLocation in interface RegionLocator
      Parameters:
      row - Row to find.
      replicaId - the replica id
      reload - true to reload information or false to use cached information
      Returns:
      Location of the row.
      Throws:
      IOException - if a remote or network exception occurs
    • getRegionLocations

      public List<HRegionLocation> getRegionLocations(byte[] row, boolean reload) throws IOException
      Description copied from interface: RegionLocator
      Find all the replicas for the region on which the given row is being served.
      Specified by:
      getRegionLocations in interface RegionLocator
      Parameters:
      row - Row to find.
      reload - true to reload information or false to use cached information
      Returns:
      Locations for all the replicas of the row.
      Throws:
      IOException - if a remote or network exception occurs
    • clearRegionLocationCache

      public void clearRegionLocationCache()
      Description copied from interface: RegionLocator
      Clear all the entries in the region location cache.

      This may cause performance issue so use it with caution.

      Specified by:
      clearRegionLocationCache in interface RegionLocator
    • getAllRegionLocations

      Description copied from interface: RegionLocator
      Retrieves all of the regions associated with this table.

      Usually we will go to meta table directly in this method so there is no reload parameter.

      Notice that the location for region replicas other than the default replica are also returned.

      Specified by:
      getAllRegionLocations in interface RegionLocator
      Returns:
      a List of all regions associated with this table.
      Throws:
      IOException - if a remote or network exception occurs
    • getRegionLocationsPage

      public List<HRegionLocation> getRegionLocationsPage(byte[] startKey, int limit) throws IOException
      Description copied from interface: RegionLocator
      Bulk lookup of region locations from hbase:meta in a single RPC, starting at startKey (region start-key boundary, inclusive) and returning at most limit regions in start-key order.

      The returned list includes all replicas of each region (matching RegionLocator.getAllRegionLocations()), and the result is also written to the connection's region location cache.

      Ordering: regions are returned in ascending region start-key order (the natural order of hbase:meta rows for a single table). Within each region, replicas are returned in ascending replica-id order (replica 0, then 1, then 2, ...). Split parents are filtered out, which may cause a page to contain fewer than limit regions but never disturbs ordering of the survivors.

      To page through all regions of a table, call repeatedly passing last.getRegion().getEndKey() as the next startKey, where last is the final element of the previous response. All replicas of a region share the same RegionInfo, so the last entry's end key is the correct cursor regardless of which replica it is. Pass null for the first call. Stop paging when the returned list is empty or when the last region's end key is HConstants.EMPTY_END_ROW (zero-length) - that signals the end of the table; passing it back in would re-scan from the beginning since by convention an empty start key means "from the first region".

      Unlike RegionLocator.getAllRegionLocations(), this method performs at most one RPC against hbase:meta per invocation, so its latency is bounded by limit rather than table size. The single-RPC behavior is best-effort: if the response would exceed hbase.client.scanner.max.result.size (default 2 MB), the server may split the slice across multiple ScannerNext RPCs. For typical meta row sizes and default caching this rarely fires, but callers passing large limit values against clusters with replicas or heavy meta rows should treat single-RPC as a soft guarantee, not absolute.

      This method is optional. Implementations that cannot support paginated lookups should throw UnsupportedOperationException (the default behavior); callers should fall back to RegionLocator.getAllRegionLocations() in that case.

      Specified by:
      getRegionLocationsPage in interface RegionLocator
      Parameters:
      startKey - region start-key to begin scanning from (inclusive); null or empty starts from the first region
      limit - maximum number of regions to return. If <= 0, falls back to hbase.meta.scanner.caching - this is a SOFT cap on a single page, NOT "all regions"; tables larger than the cap still require the caller to keep paging via last.getRegion().getEndKey().
      Returns:
      up to limit HRegionLocations in start-key order, possibly empty when no more regions exist
      Throws:
      IOException - if a remote or network exception occurs
    • getName

      public TableName getName()
      Description copied from interface: RegionLocator
      Gets the fully qualified table name instance of this table.
      Specified by:
      getName in interface RegionLocator