Package org.apache.hadoop.hbase.client
Interface RegionLocator
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
RegionLocatorOverAsyncTableRegionLocator,SnapshotRegionLocator
Used to view region location information for a single HBase table. Obtain an instance from an
Connection.- Since:
- 0.99.0
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidClear all the entries in the region location cache.Retrieves all of the regions associated with this table.default byte[][]Gets the ending row key for every region in the currently open table.getName()Gets the fully qualified table name instance of this table.default HRegionLocationgetRegionLocation(byte[] row) Finds the region on which the given row is being served.default HRegionLocationgetRegionLocation(byte[] row, boolean reload) Finds the region on which the given row is being served.default HRegionLocationgetRegionLocation(byte[] row, int replicaId) Finds the region with the given replica id on which the given row is being served.getRegionLocation(byte[] row, int replicaId, boolean reload) Finds the region with the given replica id on which the given row is being served.default List<HRegionLocation>getRegionLocations(byte[] row) Find all the replicas for the region on which the given row is being served.getRegionLocations(byte[] row, boolean reload) Find all the replicas for the region on which the given row is being served.default List<HRegionLocation>getRegionLocationsPage(byte[] startKey, int limit) Bulk lookup of region locations fromhbase:metain a single RPC, starting atstartKey(region start-key boundary, inclusive) and returning at mostlimitregions in start-key order.default Pair<byte[][],byte[][]> Gets the starting and ending row keys for every region in the currently open table.default byte[][]Gets the starting row key for every region in the currently open table.
-
Field Details
-
LOCATOR_META_REPLICAS_MODE
Configuration for Region Locator's mode when meta replica is configured. Valid values are: HedgedRead, LoadBalance, None- See Also:
-
LOCATOR_META_REPLICAS_MODE_LOADBALANCE_SELECTOR
Configuration for meta replica selector when Region Locator's LoadBalance mode is configured. The default value is org.apache.hadoop.hbase.client.CatalogReplicaLoadBalanceSimpleSelector.- See Also:
-
-
Method Details
-
getRegionLocation
Finds the region on which the given row is being served. Does not reload the cache.- Parameters:
row- Row to find.- Returns:
- Location of the row.
- Throws:
IOException- if a remote or network exception occurs
-
getRegionLocation
Finds the region on which the given row is being served.- Parameters:
row- Row to find.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
-
getRegionLocation
Finds the region with the given replica id on which the given row is being served.- Parameters:
row- Row to find.replicaId- the replica id- Returns:
- Location of the row.
- Throws:
IOException- if a remote or network exception occurs
-
getRegionLocation
Finds the region with the given replica id on which the given row is being served.- Parameters:
row- Row to find.replicaId- the replica idreload- 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
Find all the replicas for the region on which the given row is being served.- Parameters:
row- Row to find.- Returns:
- Locations for all the replicas of the row.
- Throws:
IOException- if a remote or network exception occurs
-
getRegionLocations
Find all the replicas for the region on which the given row is being served.- 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
void clearRegionLocationCache()Clear all the entries in the region location cache. This may cause performance issue so use it with caution. -
getAllRegionLocations
Retrieves all of the regions associated with this table. Usually we will go to meta table directly in this method so there is noreloadparameter. Notice that the location for region replicas other than the default replica are also returned.- Returns:
- a
Listof all regions associated with this table. - Throws:
IOException- if a remote or network exception occurs
-
getRegionLocationsPage
Bulk lookup of region locations fromhbase:metain a single RPC, starting atstartKey(region start-key boundary, inclusive) and returning at mostlimitregions in start-key order. The returned list includes all replicas of each region (matchinggetAllRegionLocations()), 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 ofhbase:metarows 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 thanlimitregions but never disturbs ordering of the survivors. To page through all regions of a table, call repeatedly passinglast.getRegion().getEndKey()as the nextstartKey, wherelastis the final element of the previous response. All replicas of a region share the sameRegionInfo, so the last entry's end key is the correct cursor regardless of which replica it is. Passnullfor the first call. Stop paging when the returned list is empty or when the last region's end key isHConstants.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". UnlikegetAllRegionLocations(), this method performs at most one RPC againsthbase:metaper invocation, so its latency is bounded bylimitrather than table size. The single-RPC behavior is best-effort: if the response would exceedhbase.client.scanner.max.result.size(default 2 MB), the server may split the slice across multipleScannerNextRPCs. For typical meta row sizes and default caching this rarely fires, but callers passing largelimitvalues 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 throwUnsupportedOperationException(the default behavior); callers should fall back togetAllRegionLocations()in that case.- Parameters:
startKey- region start-key to begin scanning from (inclusive);nullor empty starts from the first regionlimit- maximum number of regions to return. If <= 0, falls back tohbase.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 vialast.getRegion().getEndKey().- Returns:
- up to
limitHRegionLocations in start-key order, possibly empty when no more regions exist - Throws:
IOException- if a remote or network exception occursUnsupportedOperationException- if this implementation does not support paginated lookups
-
getStartKeys
Gets the starting row key for every region in the currently open table.This is mainly useful for the MapReduce integration.
- Returns:
- Array of region starting row keys
- Throws:
IOException- if a remote or network exception occurs
-
getEndKeys
Gets the ending row key for every region in the currently open table.This is mainly useful for the MapReduce integration.
- Returns:
- Array of region ending row keys
- Throws:
IOException- if a remote or network exception occurs
-
getStartEndKeys
Gets the starting and ending row keys for every region in the currently open table.This is mainly useful for the MapReduce integration.
- Returns:
- Pair of arrays of region starting and ending row keys
- Throws:
IOException- if a remote or network exception occurs
-
getName
Gets the fully qualified table name instance of this table.
-