Class MetaCache

java.lang.Object
org.apache.hadoop.hbase.client.MetaCache

@Private public class MetaCache extends Object
A cache implementation for region locations from meta.
  • Field Details

  • Constructor Details

  • Method Details

    • getCachedLocation

      public RegionLocations getCachedLocation(TableName tableName, byte[] row)
      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

      public void cacheLocation(TableName tableName, ServerName source, HRegionLocation location)
      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 location
      location - the new location
    • cacheLocation

      public void cacheLocation(TableName tableName, RegionLocations locations)
      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

      private void addToCachedServers(RegionLocations locations)
    • getTableLocations

      Returns Map of cached locations for passed tableName.
      Despite being Concurrent, writes to the map should be synchronized because we have cases where we need to make multiple updates atomically.
    • isRegionCached

      public boolean isRegionCached(TableName tableName, byte[] row)
      Check the region cache to see whether a region is cached yet or not.
      Parameters:
      tableName - tableName
      row - 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

      public void clearCache()
      Delete all cached entries.
      Synchronized because of calls in cacheLocation which need to be executed atomically
    • clearCache

      public void clearCache(ServerName serverName)
      Delete all cached entries of a server.
      Synchronized because of calls in cacheLocation which need to be executed atomically
    • clearCache

      public void clearCache(TableName tableName, byte[] row)
      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

      public void clearCache(TableName tableName)
      Delete all cached entries of a table.
      Synchronized because of calls in cacheLocation which need to be executed atomically
    • clearCache

      public 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 atomically
      Parameters:
      tableName - tableName
      row - row key
      replicaId - region replica id
    • clearCache

      public void clearCache(TableName tableName, byte[] row, ServerName serverName)
      Delete a cached location for a table, row and server.
      Synchronized because of calls in cacheLocation which need to be executed atomically
    • clearCache

      public 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 atomically
      Parameters:
      hri - The region in question.