Class AsyncRegionLocationCache

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

final class AsyncRegionLocationCache extends Object
Cache of RegionLocations for use by AsyncNonMetaRegionLocator. Wrapper around ConcurrentSkipListMap ensuring proper access to cached items. Updates are synchronized, but reads are not.
  • Field Details

  • Constructor Details

  • 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). See MetaCacheUtil cleanProblematicOverlappedRegions
      Parameters:
      locs - the locations to cache
      Returns:
      the final location (possibly merged) that was added to the cache
    • isEqual

      private boolean isEqual(RegionLocations locs1, RegionLocations locs2)
    • getAll

      Returns all cached RegionLocations
    • get

      public RegionLocations get(byte[] startKey)
      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

      public RegionLocations findForRow(byte[] row, int replicaId)
      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

      public RegionLocations findForBeforeRow(byte[] row, int replicaId)
      Finds the RegionLocations for the region with the greatest startKey strictly less than the given row
      Parameters:
      row - row to find locations
    • remove

      public boolean remove(HRegionLocation loc)
      Removes the location from the cache if it exists and can be removed.
      Returns:
      true if entry was removed
    • size

      public int size()
      Returns the size of the region locations cache
    • removeForServer

      public 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.
      Parameters:
      serverName - server to remove from locations