Class CatalogFamilyFormat

java.lang.Object
org.apache.hadoop.hbase.CatalogFamilyFormat

@Private public class CatalogFamilyFormat extends Object
Helper class for generating/parsing "info" family cells in meta table.

The cells in catalog family are:

 For each table range ('Region'), there is a single row, formatted as:
 <tableName>,<startKey>,<regionId>,<encodedRegionName>.
 This row is the serialized regionName of the default region replica.
 Columns are:
 info:regioninfo         => contains serialized HRI for the default region replica
 info:server             => contains hostname:port (in string form) for the server hosting
                            the default regionInfo replica
 info:server_<replicaId&gt => contains hostname:port (in string form) for the server hosting
                                 the regionInfo replica with replicaId
 info:serverstartcode    => contains server start code (in binary long form) for the server
                            hosting the default regionInfo replica
 info:serverstartcode_<replicaId&gt => contains server start code (in binary long form) for
                                          the server hosting the regionInfo replica with
                                          replicaId
 info:seqnumDuringOpen   => contains seqNum (in binary long form) for the region at the time
                            the server opened the region with default replicaId
 info:seqnumDuringOpen_<replicaId&gt => contains seqNum (in binary long form) for the region
                                           at the time the server opened the region with
                                           replicaId
 info:splitA             => contains a serialized HRI for the first daughter region if the
                            region is split
 info:splitB             => contains a serialized HRI for the second daughter region if the
                            region is split
 info:merge*             => contains a serialized HRI for a merge parent region. There will be two
                            or more of these columns in a row. A row that has these columns is
                            undergoing a merge and is the result of the merge. Columns listed
                            in marge* columns are the parents of this merged region. Example
                            columns: info:merge0001, info:merge0002. You make also see 'mergeA',
                            and 'mergeB'. This is old form replaced by the new format that allows
                            for more than two parents to be merged at a time.
 
  • Field Details

  • Constructor Details

  • Method Details

    • parseRegionInfoFromRegionName

      public static RegionInfo parseRegionInfoFromRegionName(byte[] regionName) throws IOException
      Returns an HRI parsed from this regionName. Not all the fields of the HRI is stored in the name, so the returned object should only be used for the fields in the regionName.

      Since the returned object does not contain all the fields, we do not expose this method in public API, such as RegionInfo or RegionInfoBuilder.

      Throws:
      IOException
    • getRegionInfo

      @Nullable public static RegionInfo getRegionInfo(Result r, byte[] qualifier)
      Returns the RegionInfo object from the column HConstants.CATALOG_FAMILY and qualifier of the catalog table result.
      Parameters:
      r - a Result object from the catalog table scan
      qualifier - Column family qualifier
      Returns:
      An RegionInfo instance or null.
    • getRegionInfo

      public static RegionInfo getRegionInfo(Result data)
      Returns RegionInfo object from the column HConstants.CATALOG_FAMILY:HConstants.REGIONINFO_QUALIFIER of the catalog table Result.
      Parameters:
      data - a Result object from the catalog table scan
      Returns:
      RegionInfo or null
    • getRegionLocation

      public static HRegionLocation getRegionLocation(Result r, RegionInfo regionInfo, int replicaId)
      Returns the HRegionLocation parsed from the given meta row Result for the given regionInfo and replicaId. The regionInfo can be the default region info for the replica.
      Parameters:
      r - the meta row result
      regionInfo - RegionInfo for default replica
      replicaId - the replicaId for the HRegionLocation
      Returns:
      HRegionLocation parsed from the given meta row Result for the given replicaId
    • getRegionLocations

      @Nullable public static RegionLocations getRegionLocations(Result r)
      Returns an HRegionLocationList extracted from the result.
      Returns:
      an HRegionLocationList containing all locations for the region range or null if we can't deserialize the result.
    • getServerName

      @Nullable public static ServerName getServerName(Result r, int replicaId)
      Returns a ServerName from catalog table Result.
      Parameters:
      r - Result to pull from
      Returns:
      A ServerName instance or null if necessary fields not found or empty.
    • getServerColumn

      public static byte[] getServerColumn(int replicaId)
      Returns the column qualifier for server column for replicaId
      Parameters:
      replicaId - the replicaId of the region
      Returns:
      a byte[] for server column qualifier
    • getStartCodeColumn

      public static byte[] getStartCodeColumn(int replicaId)
      Returns the column qualifier for server start code column for replicaId
      Parameters:
      replicaId - the replicaId of the region
      Returns:
      a byte[] for server start code column qualifier
    • getSeqNumDuringOpen

      private static long getSeqNumDuringOpen(Result r, int replicaId)
      The latest seqnum that the server writing to meta observed when opening the region. E.g. the seqNum when the result of getServerName(org.apache.hadoop.hbase.client.Result,int) was written.
      Parameters:
      r - Result to pull the seqNum from
      Returns:
      SeqNum, or HConstants.NO_SEQNUM if there's no value written.
    • getSeqNumColumn

      public static byte[] getSeqNumColumn(int replicaId)
      Returns the column qualifier for seqNum column for replicaId
      Parameters:
      replicaId - the replicaId of the region
      Returns:
      a byte[] for seqNum column qualifier
    • parseReplicaIdFromServerColumn

      static int parseReplicaIdFromServerColumn(byte[] serverColumn)
      Parses the replicaId from the server column qualifier. See top of the class javadoc for the actual meta layout
      Parameters:
      serverColumn - the column qualifier
      Returns:
      an int for the replicaId
    • getMetaKeyForRegion

      public static byte[] getMetaKeyForRegion(RegionInfo regionInfo)
      Returns the row key to use for this regionInfo
    • getRegionStateColumn

      public static byte[] getRegionStateColumn(int replicaId)
      Returns the column qualifier for serialized region state
      Parameters:
      replicaId - the replicaId of the region
      Returns:
      a byte[] for state qualifier
    • getServerNameColumn

      public static byte[] getServerNameColumn(int replicaId)
      Returns the column qualifier for serialized region state
      Parameters:
      replicaId - the replicaId of the region
      Returns:
      a byte[] for sn column qualifier
    • getTableState

      @Nullable public static TableState getTableState(Result r) throws IOException
      Decode table state from META Result. Should contain cell from HConstants.TABLE_FAMILY
      Returns:
      null if not found
      Throws:
      IOException
    • getMergeRegionsWithName

      @Nullable public static Map<String,RegionInfo> getMergeRegionsWithName(Cell[] cells)
      Returns Deserialized values of <qualifier,regioninfo> pairs taken from column values that match the regex 'info:merge.*' in array of cells.
    • getMergeRegions

      @Nullable public static List<RegionInfo> getMergeRegions(Cell[] cells)
      Returns Deserialized regioninfo values taken from column values that match the regex 'info:merge.*' in array of cells.
    • hasMergeRegions

      public static boolean hasMergeRegions(Cell[] cells)
      Returns True if any merge regions present in cells; i.e. the column in cell matches the regex 'info:merge.*'.
    • isMergeQualifierPrefix

      public static boolean isMergeQualifierPrefix(Cell cell)
      Returns True if the column in cell matches the regex 'info:merge.*'.