Package org.apache.hadoop.hbase.client
Class MetaCache
java.lang.Object
org.apache.hadoop.hbase.client.MetaCache
A cache implementation for region locations from meta.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ConcurrentMap<TableName,
ConcurrentNavigableMap<byte[], RegionLocations>> Map of table to tableHRegionLocation
s.private final Set<ServerName>
private static final org.slf4j.Logger
private final MetricsConnection
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
addToCachedServers
(RegionLocations locations) void
cacheLocation
(TableName tableName, RegionLocations locations) Put a newly discovered HRegionLocation into the cache.void
cacheLocation
(TableName tableName, ServerName source, HRegionLocation location) Put a newly discovered HRegionLocation into the cache.void
Delete all cached entries.void
clearCache
(RegionInfo hri) Deletes the cached location of the region if necessary, based on some error from source.
Synchronized because of calls in cacheLocation which need to be executed atomicallyvoid
clearCache
(ServerName serverName) Delete all cached entries of a server.void
clearCache
(TableName tableName) Delete all cached entries of a table.
Synchronized because of calls in cacheLocation which need to be executed atomicallyvoid
clearCache
(TableName tableName, byte[] row) Delete a cached location, no matter what it is.void
clearCache
(TableName tableName, byte[] row, int replicaId) Delete a cached location with specific replicaId.
Synchronized because of calls in cacheLocation which need to be executed atomicallyvoid
clearCache
(TableName tableName, byte[] row, ServerName serverName) Delete a cached location for a table, row and server.getCachedLocation
(TableName tableName, byte[] row) Search the cache for a location that fits our table and row key.int
getNumberOfCachedRegionLocations
(TableName tableName) Return the number of cached region for a table.private ConcurrentNavigableMap<byte[],
RegionLocations> getTableLocations
(TableName tableName) Returns Map of cached locations for passedtableName
.
Despite being Concurrent, writes to the map should be synchronized because we have cases where we need to make multiple updates atomically.boolean
isRegionCached
(TableName tableName, byte[] row) Check the region cache to see whether a region is cached yet or not.
-
Field Details
-
LOG
-
cachedRegionLocations
private final ConcurrentMap<TableName,ConcurrentNavigableMap<byte[], cachedRegionLocationsRegionLocations>> Map of table to tableHRegionLocation
s.
Despite being Concurrent, writes to the map should be synchronized because we have cases where we need to make multiple updates atomically. -
cachedServers
-
metrics
-
-
Constructor Details
-
MetaCache
-
-
Method Details
-
getCachedLocation
Search the cache for a location that fits our table and row key. Return null if no suitable region is located.- Returns:
- Null or region location found in cache.
-
cacheLocation
Put a newly discovered HRegionLocation into the cache. Synchronize here because we may need to make multiple modifications in cleanProblematicOverlappedRegions, and we want them to be atomic.- Parameters:
tableName
- The table name.source
- the source of the new locationlocation
- the new location
-
cacheLocation
Put a newly discovered HRegionLocation into the cache. Synchronize here because we may need to make multiple modifications in cleanProblematicOverlappedRegions, and we want them to be atomic.- Parameters:
tableName
- The table name.locations
- the new locations
-
addToCachedServers
-
getTableLocations
Returns Map of cached locations for passedtableName
.
Despite being Concurrent, writes to the map should be synchronized because we have cases where we need to make multiple updates atomically. -
isRegionCached
Check the region cache to see whether a region is cached yet or not.- Parameters:
tableName
- tableNamerow
- row- Returns:
- Region cached or not.
-
getNumberOfCachedRegionLocations
Return the number of cached region for a table. It will only be called from a unit test. -
clearCache
Delete all cached entries.
Synchronized because of calls in cacheLocation which need to be executed atomically -
clearCache
Delete all cached entries of a server.
Synchronized because of calls in cacheLocation which need to be executed atomically -
clearCache
Delete a cached location, no matter what it is. Called when we were told to not use cache.
Synchronized because of calls in cacheLocation which need to be executed atomically- Parameters:
tableName
- tableName
-
clearCache
Delete all cached entries of a table.
Synchronized because of calls in cacheLocation which need to be executed atomically -
clearCache
Delete a cached location with specific replicaId.
Synchronized because of calls in cacheLocation which need to be executed atomically- Parameters:
tableName
- tableNamerow
- row keyreplicaId
- region replica id
-
clearCache
Delete a cached location for a table, row and server.
Synchronized because of calls in cacheLocation which need to be executed atomically -
clearCache
Deletes the cached location of the region if necessary, based on some error from source.
Synchronized because of calls in cacheLocation which need to be executed atomically- Parameters:
hri
- The region in question.
-