Package org.apache.hadoop.hbase.client
Class AsyncRegionLocationCache
java.lang.Object
org.apache.hadoop.hbase.client.AsyncRegionLocationCache
Cache of RegionLocations for use by
AsyncNonMetaRegionLocator
. Wrapper around
ConcurrentSkipListMap ensuring proper access to cached items. Updates are synchronized, but reads
are not.-
Field Summary
Modifier and TypeFieldDescriptionprivate final ConcurrentNavigableMap<byte[],
RegionLocations> private static final org.slf4j.Logger
private final TableName
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(RegionLocations locs) Add the given locations to the cache, merging with existing if necessary.findForBeforeRow
(byte[] row, int replicaId) Finds the RegionLocations for the region with the greatest startKey strictly less than the given rowfindForRow
(byte[] row, int replicaId) Finds the RegionLocations for the region with the greatest startKey less than or equal to the given rowget
(byte[] startKey) Gets the RegionLocations for a given region's startKey.getAll()
Returns all cached RegionLocationsprivate boolean
isEqual
(RegionLocations locs1, RegionLocations locs2) boolean
remove
(HRegionLocation loc) Removes the location from the cache if it exists and can be removed.void
removeForServer
(ServerName serverName) Removes serverName from all locations in the cache, fully removing any RegionLocations which are empty after removing the server from it.int
size()
Returns the size of the region locations cache
-
Field Details
-
LOG
-
cache
-
tableName
-
-
Constructor Details
-
AsyncRegionLocationCache
-
-
Method Details
-
add
Add the given locations to the cache, merging with existing if necessary. Also cleans out any previously cached locations which may have been superseded by this one (i.e. in case of merged regions). SeeMetaCacheUtil
cleanProblematicOverlappedRegions- Parameters:
locs
- the locations to cache- Returns:
- the final location (possibly merged) that was added to the cache
-
isEqual
-
getAll
Returns all cached RegionLocations -
get
Gets the RegionLocations for a given region's startKey. This is a direct lookup, if the key does not exist in the cache it will return null.- Parameters:
startKey
- region start key to directly look up
-
findForRow
Finds the RegionLocations for the region with the greatest startKey less than or equal to the given row- Parameters:
row
- row to find locations
-
findForBeforeRow
Finds the RegionLocations for the region with the greatest startKey strictly less than the given row- Parameters:
row
- row to find locations
-
remove
Removes the location from the cache if it exists and can be removed.- Returns:
- true if entry was removed
-
size
Returns the size of the region locations cache -
removeForServer
Removes serverName from all locations in the cache, fully removing any RegionLocations which are empty after removing the server from it.- Parameters:
serverName
- server to remove from locations
-