Package org.apache.hadoop.hbase
Class CatalogFamilyFormat
java.lang.Object
org.apache.hadoop.hbase.CatalogFamilyFormat
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> => 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> => 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> => 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 Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
(package private) static final char
The delimiter for meta columns for replicaIds > 0private static final Pattern
A regex for parsing server columns from meta. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<RegionInfo>
getMergeRegions
(Cell[] cells) Returns Deserialized regioninfo values taken from column values that match the regex 'info:merge.*' in array ofcells
.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 ofcells
.static byte[]
getMetaKeyForRegion
(RegionInfo regionInfo) Returns the row key to use for this regionInfostatic RegionInfo
getRegionInfo
(Result data) Returns RegionInfo object from the column HConstants.CATALOG_FAMILY:HConstants.REGIONINFO_QUALIFIER of the catalog table Result.static RegionInfo
getRegionInfo
(Result r, byte[] qualifier) Returns the RegionInfo object from the columnHConstants.CATALOG_FAMILY
andqualifier
of the catalog table result.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.static RegionLocations
Returns an HRegionLocationList extracted from the result.static byte[]
getRegionStateColumn
(int replicaId) Returns the column qualifier for serialized region statestatic byte[]
getSeqNumColumn
(int replicaId) Returns the column qualifier for seqNum column for replicaIdprivate static long
getSeqNumDuringOpen
(Result r, int replicaId) The latest seqnum that the server writing to meta observed when opening the region.static byte[]
getServerColumn
(int replicaId) Returns the column qualifier for server column for replicaIdstatic ServerName
getServerName
(Result r, int replicaId) Returns aServerName
from catalog tableResult
.static byte[]
getServerNameColumn
(int replicaId) Returns the column qualifier for serialized region statestatic byte[]
getStartCodeColumn
(int replicaId) Returns the column qualifier for server start code column for replicaIdstatic TableState
Decode table state from META Result.static boolean
hasMergeRegions
(Cell[] cells) Returns True if any merge regions present incells
; i.e.static boolean
isMergeQualifierPrefix
(Cell cell) Returns True if the column incell
matches the regex 'info:merge.*'.static RegionInfo
parseRegionInfoFromRegionName
(byte[] regionName) Returns an HRI parsed from this regionName.(package private) static int
parseReplicaIdFromServerColumn
(byte[] serverColumn) Parses the replicaId from the server column qualifier.
-
Field Details
-
LOG
-
SERVER_COLUMN_PATTERN
A regex for parsing server columns from meta. See above javadoc for meta layout -
META_REPLICA_ID_DELIMITER
The delimiter for meta columns for replicaIds > 0- See Also:
-
-
Constructor Details
-
CatalogFamilyFormat
public CatalogFamilyFormat()
-
-
Method Details
-
parseRegionInfoFromRegionName
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 asRegionInfo
orRegionInfoBuilder
.- Throws:
IOException
-
getRegionInfo
Returns the RegionInfo object from the columnHConstants.CATALOG_FAMILY
andqualifier
of the catalog table result.- Parameters:
r
- a Result object from the catalog table scanqualifier
- Column family qualifier- Returns:
- An RegionInfo instance or null.
-
getRegionInfo
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
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 resultregionInfo
- RegionInfo for default replicareplicaId
- the replicaId for the HRegionLocation- Returns:
- HRegionLocation parsed from the given meta row Result for the given replicaId
-
getRegionLocations
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
Returns aServerName
from catalog tableResult
.- Parameters:
r
- Result to pull from- Returns:
- A ServerName instance or null if necessary fields not found or empty.
-
getServerColumn
Returns the column qualifier for server column for replicaId- Parameters:
replicaId
- the replicaId of the region- Returns:
- a byte[] for server column qualifier
-
getStartCodeColumn
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
The latest seqnum that the server writing to meta observed when opening the region. E.g. the seqNum when the result ofgetServerName(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
Returns the column qualifier for seqNum column for replicaId- Parameters:
replicaId
- the replicaId of the region- Returns:
- a byte[] for seqNum column qualifier
-
parseReplicaIdFromServerColumn
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
Returns the row key to use for this regionInfo -
getRegionStateColumn
Returns the column qualifier for serialized region state- Parameters:
replicaId
- the replicaId of the region- Returns:
- a byte[] for state qualifier
-
getServerNameColumn
Returns the column qualifier for serialized region state- Parameters:
replicaId
- the replicaId of the region- Returns:
- a byte[] for sn column qualifier
-
getTableState
Decode table state from META Result. Should contain cell from HConstants.TABLE_FAMILY- Returns:
- null if not found
- Throws:
IOException
-
getMergeRegionsWithName
Returns Deserialized values of <qualifier,regioninfo> pairs taken from column values that match the regex 'info:merge.*' in array ofcells
. -
getMergeRegions
Returns Deserialized regioninfo values taken from column values that match the regex 'info:merge.*' in array ofcells
. -
hasMergeRegions
Returns True if any merge regions present incells
; i.e. the column incell
matches the regex 'info:merge.*'. -
isMergeQualifierPrefix
Returns True if the column incell
matches the regex 'info:merge.*'.
-