Package org.apache.hadoop.hbase
Class AsyncMetaTableAccessor
java.lang.Object
org.apache.hadoop.hbase.AsyncMetaTableAccessor
The asynchronous meta table accessor. Used to read/write region and assignment information store
in
hbase:meta
.- Since:
- 2.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
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 TypeMethodDescriptionprivate static byte[]
Returns the column family used for meta columns.private static Optional<RegionInfo>
getHRegionInfo
(Result r, byte[] qualifier) Returns the RegionInfo object from the columnHConstants.CATALOG_FAMILY
andqualifier
of the catalog table result.private static Scan
getMetaScan
(AsyncTable<?> metaTable, int rowUpperLimit) private static byte[]
Returns the column qualifier for serialized region infostatic CompletableFuture<Optional<HRegionLocation>>
getRegionLocation
(AsyncTable<?> metaTable, byte[] regionName) Returns the HRegionLocation from meta for the given regionprivate 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.private static Optional<RegionLocations>
Returns an HRegionLocationList extracted from the result.static CompletableFuture<Optional<HRegionLocation>>
getRegionLocationWithEncodedName
(AsyncTable<?> metaTable, byte[] encodedRegionName) Returns the HRegionLocation from meta for the given encoded region nameprivate static 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.private static byte[]
getServerColumn
(int replicaId) Returns the column qualifier for server column for replicaIdprivate static Optional<ServerName>
getServerName
(Result r, int replicaId) Returns aServerName
from catalog tableResult
.private static byte[]
getStartCodeColumn
(int replicaId) Returns the column qualifier for server start code column for replicaIdprivate static byte[]
Returns the column qualifier for serialized table stateprivate static byte[]
Returns the column family used for table columns.static CompletableFuture<List<HRegionLocation>>
getTableHRegionLocations
(AsyncTable<AdvancedScanResultConsumer> metaTable, TableName tableName) Used to get all region locations for the specific tableprivate static CompletableFuture<List<Pair<RegionInfo,
ServerName>>> getTableRegionsAndLocations
(AsyncTable<AdvancedScanResultConsumer> metaTable, TableName tableName, boolean excludeOfflinedSplitParents) Used to get table regions' info and server.private static byte[]
getTableStartRowForMeta
(TableName tableName, MetaTableAccessor.QueryType type) static CompletableFuture<Optional<TableState>>
getTableState
(AsyncTable<?> metaTable, TableName tableName) private static Optional<TableState>
private static byte[]
getTableStopRowForMeta
(TableName tableName, MetaTableAccessor.QueryType type) private static int
parseReplicaIdFromServerColumn
(byte[] serverColumn) Parses the replicaId from the server column qualifier.private static CompletableFuture<Void>
scanMeta
(AsyncTable<AdvancedScanResultConsumer> metaTable, byte[] startRow, byte[] stopRow, MetaTableAccessor.QueryType type, int maxRows, MetaTableAccessor.Visitor visitor) Performs a scan of META table for given table.private static CompletableFuture<Void>
scanMeta
(AsyncTable<AdvancedScanResultConsumer> metaTable, TableName tableName, MetaTableAccessor.QueryType type, MetaTableAccessor.Visitor visitor) Performs a scan of META table for given table.static CompletableFuture<Boolean>
tableExists
(AsyncTable<?> metaTable, TableName tableName)
-
Field Details
-
LOG
-
META_REPLICA_ID_DELIMITER
The delimiter for meta columns for replicaIds > 0- See Also:
-
SERVER_COLUMN_PATTERN
A regex for parsing server columns from meta. See above javadoc for meta layout
-
-
Constructor Details
-
AsyncMetaTableAccessor
public AsyncMetaTableAccessor()
-
-
Method Details
-
tableExists
-
getTableState
public static CompletableFuture<Optional<TableState>> getTableState(AsyncTable<?> metaTable, TableName tableName) -
getRegionLocation
public static CompletableFuture<Optional<HRegionLocation>> getRegionLocation(AsyncTable<?> metaTable, byte[] regionName) Returns the HRegionLocation from meta for the given region -
getRegionLocationWithEncodedName
public static CompletableFuture<Optional<HRegionLocation>> getRegionLocationWithEncodedName(AsyncTable<?> metaTable, byte[] encodedRegionName) Returns the HRegionLocation from meta for the given encoded region name -
getTableState
- Throws:
IOException
-
getTableHRegionLocations
public static CompletableFuture<List<HRegionLocation>> getTableHRegionLocations(AsyncTable<AdvancedScanResultConsumer> metaTable, TableName tableName) Used to get all region locations for the specific table- Parameters:
metaTable
- scanner over meta tabletableName
- table we're looking for, can be null for getting all regions- Returns:
- the list of region locations. The return value will be wrapped by a
CompletableFuture
.
-
getTableRegionsAndLocations
private static CompletableFuture<List<Pair<RegionInfo,ServerName>>> getTableRegionsAndLocations(AsyncTable<AdvancedScanResultConsumer> metaTable, TableName tableName, boolean excludeOfflinedSplitParents) Used to get table regions' info and server.- Parameters:
metaTable
- scanner over meta tabletableName
- table we're looking for, can be null for getting all regionsexcludeOfflinedSplitParents
- don't return split parents- Returns:
- the list of regioninfos and server. The return value will be wrapped by a
CompletableFuture
.
-
scanMeta
private static CompletableFuture<Void> scanMeta(AsyncTable<AdvancedScanResultConsumer> metaTable, TableName tableName, MetaTableAccessor.QueryType type, MetaTableAccessor.Visitor visitor) Performs a scan of META table for given table.- Parameters:
metaTable
- scanner over meta tabletableName
- table within we scantype
- scanned part of metavisitor
- Visitor invoked against each row
-
scanMeta
private static CompletableFuture<Void> scanMeta(AsyncTable<AdvancedScanResultConsumer> metaTable, byte[] startRow, byte[] stopRow, MetaTableAccessor.QueryType type, int maxRows, MetaTableAccessor.Visitor visitor) Performs a scan of META table for given table.- Parameters:
metaTable
- scanner over meta tablestartRow
- Where to start the scanstopRow
- Where to stop the scantype
- scanned part of metamaxRows
- maximum rows to returnvisitor
- Visitor invoked against each row
-
getMetaScan
-
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.
-
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
-
getServerName
Returns aServerName
from catalog tableResult
.- Parameters:
r
- Result to pull from- Returns:
- A ServerName instance.
-
getSeqNumDuringOpen
The latest seqnum that the server writing to meta observed when opening the region. E.g. the seqNum when the result ofgetServerName(Result, int)
was written.- Parameters:
r
- Result to pull the seqNum from- Returns:
- SeqNum, or HConstants.NO_SEQNUM if there's no value written.
-
getTableStartRowForMeta
private static byte[] getTableStartRowForMeta(TableName tableName, MetaTableAccessor.QueryType type) - Parameters:
tableName
- table we're working with- Returns:
- start row for scanning META according to query type
-
getTableStopRowForMeta
- Parameters:
tableName
- table we're working with- Returns:
- stop row for scanning META according to query type
-
getHRegionInfo
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.
-
getCatalogFamily
Returns the column family used for meta columns.- Returns:
- HConstants.CATALOG_FAMILY.
-
getTableFamily
Returns the column family used for table columns.- Returns:
- HConstants.TABLE_FAMILY.
-
getRegionInfoColumn
Returns the column qualifier for serialized region info- Returns:
- HConstants.REGIONINFO_QUALIFIER
-
getStateColumn
Returns the column qualifier for serialized table state- Returns:
- HConstants.TABLE_STATE_QUALIFIER
-
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
-
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
-