@InterfaceAudience.Private public class MetaTableAccessor extends Object
Read/write operations on hbase:meta
region as well as assignment information stored
to hbase:meta
.
Some of the methods of this class take ZooKeeperWatcher as a param. The only reason for this is when this class is used on client-side (e.g. HBaseAdmin), we want to use short-lived connection (opened before each operation, closed right after), while when used on HM or HRS (like in AssignmentManager) we want permanent connection.
HBASE-10070 adds a replicaId to HRI, meaning more than one HRI can be defined for the same table range (table, startKey, endKey). For every range, there will be at least one HRI defined which is called default replica.
For each table there is single row named for the table with a 'table' column family. The column family currently has one column in it, the 'state' column: table:state => contains table state Then 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. TODO: Add rep_barrier for serial replication explaination. See SerialReplicationChecker.
The actual layout of meta should be encapsulated inside MetaTableAccessor methods, and should not leak out of it (through Result objects, etc)
Modifier and Type | Class and Description |
---|---|
static interface |
MetaTableAccessor.CloseableVisitor
Implementations 'visit' a catalog table row but with close() at the end.
|
(package private) static class |
MetaTableAccessor.CollectAllVisitor
Collects all returned.
|
(package private) static class |
MetaTableAccessor.CollectingVisitor<T>
A
MetaTableAccessor.Visitor that collects content out of passed Result . |
static class |
MetaTableAccessor.DefaultVisitorBase
A Visitor that skips offline regions and split parents
|
static class |
MetaTableAccessor.QueryType |
static class |
MetaTableAccessor.ReplicationBarrierResult |
static class |
MetaTableAccessor.TableVisitorBase
A Visitor for a table.
|
static interface |
MetaTableAccessor.Visitor
Implementations 'visit' a catalog table row.
|
Modifier and Type | Field and Description |
---|---|
private static byte |
ESCAPE_BYTE |
private static org.slf4j.Logger |
LOG |
(package private) static char |
META_REPLICA_ID_DELIMITER
The delimiter for meta columns for replicaIds > 0
|
private static org.slf4j.Logger |
METALOG |
static byte[] |
REPLICATION_PARENT_QUALIFIER |
private static byte |
SEPARATED_BYTE |
private static Pattern |
SERVER_COLUMN_PATTERN
A regex for parsing server columns from meta.
|
Constructor and Description |
---|
MetaTableAccessor() |
Modifier and Type | Method and Description |
---|---|
private static Put |
addDaughtersToPut(Put put,
RegionInfo splitA,
RegionInfo splitB)
Adds split daughters to the Put
|
static Put |
addEmptyLocation(Put p,
int replicaId) |
static Put |
addLocation(Put p,
ServerName sn,
long openSeqNum,
int replicaId) |
(package private) static Put |
addMergeRegions(Put put,
Collection<RegionInfo> mergeRegions) |
static Put |
addRegionInfo(Put p,
RegionInfo hri) |
private static Put |
addRegionStateToPut(Put put,
RegionState.State state) |
static void |
addRegionsToMeta(Connection connection,
List<RegionInfo> regionInfos,
int regionReplication)
Adds a hbase:meta row for each of the specified new regions.
|
private static void |
addRegionsToMeta(Connection connection,
List<RegionInfo> regionInfos,
int regionReplication,
long ts)
Adds a hbase:meta row for each of the specified new regions.
|
static void |
addRegionToMeta(Connection connection,
RegionInfo regionInfo)
Adds a (single) hbase:meta row for the specified new region and its daughters.
|
static void |
addReplicationBarrier(Put put,
long openSeqNum)
See class comment on SerialReplicationChecker
|
private static void |
addReplicationParent(Put put,
List<RegionInfo> parents) |
private static Put |
addSequenceNum(Put p,
long openSeqNum,
int replicaId) |
static void |
addSplitsToParent(Connection connection,
RegionInfo regionInfo,
RegionInfo splitA,
RegionInfo splitB)
Adds daughter region infos to hbase:meta row for the specified region.
|
private static void |
debugLogMutation(Mutation p) |
private static void |
debugLogMutations(List<? extends Mutation> mutations) |
private static void |
deleteFromMetaTable(Connection connection,
Delete d)
Delete the passed
d from the hbase:meta table. |
private static void |
deleteFromMetaTable(Connection connection,
List<Delete> deletes)
Delete the passed
deletes from the hbase:meta table. |
static void |
deleteMergeQualifiers(Connection connection,
RegionInfo mergeRegion)
Deletes merge qualifiers for the specified merge region.
|
static void |
deleteRegionInfo(Connection connection,
RegionInfo regionInfo)
Deletes the specified region from META.
|
static void |
deleteRegionInfos(Connection connection,
List<RegionInfo> regionsInfo)
Deletes the specified regions from META.
|
private static void |
deleteRegionInfos(Connection connection,
List<RegionInfo> regionsInfo,
long ts)
Deletes the specified regions from META.
|
static void |
deleteTableState(Connection connection,
TableName table)
Remove state for table from meta
|
private static List<Result> |
fullScan(Connection connection,
MetaTableAccessor.QueryType type)
Performs a full scan of
hbase:meta . |
static void |
fullScanMetaAndPrint(Connection connection) |
static List<Result> |
fullScanRegions(Connection connection)
Performs a full scan of
hbase:meta for regions. |
static void |
fullScanRegions(Connection connection,
MetaTableAccessor.Visitor visitor)
Performs a full scan of
hbase:meta for regions. |
static void |
fullScanTables(Connection connection,
MetaTableAccessor.Visitor visitor)
Performs a full scan of
hbase:meta for tables. |
private static Result |
get(Table t,
Get g) |
static List<RegionInfo> |
getAllRegions(Connection connection,
boolean excludeOfflinedSplitParents)
Lists all of the regions currently in META.
|
static byte[] |
getCatalogFamily()
Returns the column family used for meta columns.
|
static Result |
getCatalogFamilyRow(Connection connection,
RegionInfo ri)
Returns Return the
HConstants.CATALOG_FAMILY row from hbase:meta. |
private static RegionInfo |
getClosestRegionInfo(Connection connection,
TableName tableName,
byte[] row)
Returns Get closest metatable region row to passed
row |
static PairOfSameType<RegionInfo> |
getDaughterRegions(Result data)
Returns the daughter regions by reading the corresponding columns of the catalog table Result.
|
private static List<RegionInfo> |
getListOfRegionInfos(List<Pair<RegionInfo,ServerName>> pairs) |
static List<RegionInfo> |
getMergeRegions(Cell[] cells)
Returns Deserialized regioninfo values taken from column values that match the regex
'info:merge.*' in array of
cells . |
static List<RegionInfo> |
getMergeRegions(Connection connection,
byte[] regionName)
Returns Return all regioninfos listed in the 'info:merge*' columns of the
regionName row. |
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 . |
static Table |
getMetaHTable(Connection connection)
Callers should call close on the returned
Table instance. |
static byte[] |
getMetaKeyForRegion(RegionInfo regionInfo)
Returns the row key to use for this regionInfo
|
private static Scan |
getMetaScan(org.apache.hadoop.conf.Configuration conf,
int rowUpperLimit) |
static byte[] |
getParentsBytes(List<RegionInfo> parents) |
static Pair<RegionInfo,ServerName> |
getRegion(Connection connection,
byte[] regionName)
Deprecated.
use
getRegionLocation(Connection, byte[]) instead |
static 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 column
HConstants.CATALOG_FAMILY and
qualifier of the catalog table result. |
static byte[] |
getRegionInfoColumn()
Returns the column qualifier for serialized region info
|
static HRegionLocation |
getRegionLocation(Connection connection,
byte[] regionName)
Returns the HRegionLocation from meta for the given region
|
static HRegionLocation |
getRegionLocation(Connection connection,
RegionInfo regionInfo)
Returns the HRegionLocation from meta for the given region
|
private 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 |
getRegionLocations(Result r)
Returns an HRegionLocationList extracted from the result.
|
static Result |
getRegionResult(Connection connection,
byte[] regionName)
Gets the result in hbase:meta for the specified region.
|
private static byte[] |
getRegionStateColumn()
Returns the column qualifier for serialized region state
|
static byte[] |
getRegionStateColumn(int replicaId)
Returns the column qualifier for serialized region state
|
private static long |
getReplicationBarrier(Cell c) |
static long[] |
getReplicationBarrier(Connection conn,
byte[] regionName) |
static MetaTableAccessor.ReplicationBarrierResult |
getReplicationBarrierResult(Connection conn,
TableName tableName,
byte[] row,
byte[] encodedRegionName) |
private static MetaTableAccessor.ReplicationBarrierResult |
getReplicationBarrierResult(Result result) |
static long[] |
getReplicationBarriers(Result result) |
static Scan |
getScanForTableName(org.apache.hadoop.conf.Configuration conf,
TableName tableName)
This method creates a Scan object that will only scan catalog rows that belong to the specified
table.
|
static byte[] |
getSeqNumColumn(int replicaId)
Returns the column qualifier for seqNum column for replicaId
|
private 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 replicaId
|
static ServerName |
getServerName(Result r,
int replicaId)
Returns a
ServerName from catalog table Result . |
static byte[] |
getServerNameColumn(int replicaId)
Returns the column qualifier for serialized region state
|
static NavigableMap<RegionInfo,Result> |
getServerUserRegions(Connection connection,
ServerName serverName)
Get the user regions a given server is hosting.
|
static byte[] |
getStartCodeColumn(int replicaId)
Returns the column qualifier for server start code column for replicaId
|
static List<Pair<String,Long>> |
getTableEncodedRegionNameAndLastBarrier(Connection conn,
TableName tableName) |
static List<String> |
getTableEncodedRegionNamesForSerialReplication(Connection conn,
TableName tableName) |
private static byte[] |
getTableFamily()
Returns the column family used for table columns.
|
static List<RegionInfo> |
getTableRegions(Connection connection,
TableName tableName)
Gets all of the regions of the specified table.
|
static List<RegionInfo> |
getTableRegions(Connection connection,
TableName tableName,
boolean excludeOfflinedSplitParents)
Gets all of the regions of the specified table.
|
static List<Pair<RegionInfo,ServerName>> |
getTableRegionsAndLocations(Connection connection,
TableName tableName)
Do not use this method to get meta table regions, use methods in MetaTableLocator instead.
|
static List<Pair<RegionInfo,ServerName>> |
getTableRegionsAndLocations(Connection connection,
TableName tableName,
boolean excludeOfflinedSplitParents)
Do not use this method to get meta table regions, use methods in MetaTableLocator instead.
|
static byte[] |
getTableStartRowForMeta(TableName tableName,
MetaTableAccessor.QueryType type)
Returns start row for scanning META according to query type
|
static TableState |
getTableState(Connection conn,
TableName tableName)
Fetch table state for given table from META table
|
static TableState |
getTableState(Result r)
Decode table state from META Result.
|
private static byte[] |
getTableStateColumn()
Returns the column qualifier for serialized table state
|
static Map<TableName,TableState> |
getTableStates(Connection conn)
Fetch table states from META table
|
static byte[] |
getTableStopRowForMeta(TableName tableName,
MetaTableAccessor.QueryType type)
Returns stop row for scanning META according to query type
|
static ServerName |
getTargetServerName(Result r,
int replicaId)
Returns the
ServerName from catalog table Result where the region is
transitioning on. |
static boolean |
hasMergeRegions(Cell[] cells)
Returns True if any merge regions present in
cells ; i.e. |
static boolean |
hasMergeRegions(Connection conn,
byte[] regionName)
Check whether the given
regionName has any 'info:merge*' columns. |
private static boolean |
isMergeQualifierPrefix(Cell cell)
Returns True if the column in
cell matches the regex 'info:merge.*'. |
static Delete |
makeDeleteFromRegionInfo(RegionInfo regionInfo,
long ts)
Generates and returns a Delete containing the region info for the catalog table
|
static Put |
makePutForReplicationBarrier(RegionInfo regionInfo,
long openSeqNum,
long ts) |
static Put |
makePutFromRegionInfo(RegionInfo regionInfo,
long ts)
Generates and returns a Put containing the region into for the catalog table
|
static Put |
makePutFromTableState(TableState state,
long ts)
Construct PUT for given state
|
static void |
mergeRegions(Connection connection,
RegionInfo mergedRegion,
Map<RegionInfo,Long> parentSeqNum,
ServerName sn,
int regionReplication)
Merge regions into one in an atomic operation.
|
(package private) static void |
multiMutate(Table table,
byte[] row,
List<Mutation> mutations)
Performs an atomic multi-mutate operation against the given table.
|
private static void |
multiMutate(Table table,
byte[] row,
Mutation... mutations) |
static void |
overwriteRegions(Connection connection,
List<RegionInfo> regionInfos,
int regionReplication)
Overwrites the specified regions from hbase:meta.
|
private static List<byte[]> |
parseParentsBytes(byte[] bytes) |
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.
|
private static void |
put(Table t,
Put p) |
static void |
putsToMetaTable(Connection connection,
List<Put> ps)
Put the passed
ps to the hbase:meta table. |
private static void |
putToMetaTable(Connection connection,
Put p)
Put the passed
p to the hbase:meta table. |
static Result |
scanByRegionEncodedName(Connection connection,
String regionEncodedName)
Scans META table for a row whose key contains the specified regionEncodedName, returning
a single related
Result instance if any row is found, null otherwise. |
private static void |
scanMeta(Connection connection,
byte[] startRow,
byte[] stopRow,
MetaTableAccessor.QueryType type,
Filter filter,
int maxRows,
MetaTableAccessor.Visitor visitor,
CatalogReplicaMode metaReplicaMode) |
(package private) static void |
scanMeta(Connection connection,
byte[] startRow,
byte[] stopRow,
MetaTableAccessor.QueryType type,
int maxRows,
MetaTableAccessor.Visitor visitor)
Performs a scan of META table.
|
private static void |
scanMeta(Connection connection,
byte[] startRow,
byte[] stopRow,
MetaTableAccessor.QueryType type,
MetaTableAccessor.Visitor visitor) |
static void |
scanMeta(Connection connection,
MetaTableAccessor.Visitor visitor,
TableName tableName,
byte[] row,
int rowLimit)
Performs a scan of META table for given table starting from given row.
|
private static void |
scanMeta(Connection connection,
TableName table,
MetaTableAccessor.QueryType type,
int maxRows,
MetaTableAccessor.Visitor visitor,
CatalogReplicaMode metaReplicaMode) |
static void |
scanMetaForTableRegions(Connection connection,
MetaTableAccessor.Visitor visitor,
TableName tableName) |
static void |
scanMetaForTableRegions(Connection connection,
MetaTableAccessor.Visitor visitor,
TableName tableName,
CatalogReplicaMode metaReplicaMode) |
static void |
splitRegion(Connection connection,
RegionInfo parent,
long parentOpenSeqNum,
RegionInfo splitA,
RegionInfo splitB,
ServerName sn,
int regionReplication)
Splits the region into two in an atomic operation.
|
private static void |
updateLocation(Connection connection,
RegionInfo regionInfo,
ServerName sn,
long openSeqNum,
long masterSystemTime)
Updates the location of the specified region to be the specified server.
|
static void |
updateRegionLocation(Connection connection,
RegionInfo regionInfo,
ServerName sn,
long openSeqNum,
long masterSystemTime)
Updates the location of the specified region in hbase:meta to be the specified server hostname
and startcode.
|
static void |
updateRegionState(Connection connection,
RegionInfo ri,
RegionState.State state)
Update state column in hbase:meta.
|
static void |
updateTableState(Connection conn,
TableName tableName,
TableState.State actual)
Updates state in META Do not use.
|
private static void |
updateTableState(Connection connection,
TableState state)
Update state of the table in meta.
|
private static void |
writeRegionName(ByteArrayOutputStream out,
byte[] regionName) |
private static final org.slf4j.Logger LOG
private static final org.slf4j.Logger METALOG
public static final byte[] REPLICATION_PARENT_QUALIFIER
private static final byte ESCAPE_BYTE
private static final byte SEPARATED_BYTE
static final char META_REPLICA_ID_DELIMITER
private static final Pattern SERVER_COLUMN_PATTERN
public MetaTableAccessor()
public static void fullScanRegions(Connection connection, MetaTableAccessor.Visitor visitor) throws IOException
hbase:meta
for regions.connection
- connection we're usingvisitor
- Visitor invoked against each row in regions family.IOException
public static List<Result> fullScanRegions(Connection connection) throws IOException
hbase:meta
for regions.connection
- connection we're usingIOException
public static void fullScanTables(Connection connection, MetaTableAccessor.Visitor visitor) throws IOException
hbase:meta
for tables.connection
- connection we're usingvisitor
- Visitor invoked against each row in tables family.IOException
private static List<Result> fullScan(Connection connection, MetaTableAccessor.QueryType type) throws IOException
hbase:meta
.connection
- connection we're usingtype
- scanned part of metaResult
IOException
public static Table getMetaHTable(Connection connection) throws IOException
Table
instance.connection
- connection we're using to access MetaTable
for hbase:meta
IOException
private static Result get(Table t, Get g) throws IOException
t
- Table to use (will be closed when done).g
- Get to runIOException
@Deprecated public static Pair<RegionInfo,ServerName> getRegion(Connection connection, byte[] regionName) throws IOException
getRegionLocation(Connection, byte[])
insteadconnection
- connection we're usingregionName
- Region to lookup.regionName
IOException
public static HRegionLocation getRegionLocation(Connection connection, byte[] regionName) throws IOException
connection
- connection we're usingregionName
- region we're looking forIOException
public static HRegionLocation getRegionLocation(Connection connection, RegionInfo regionInfo) throws IOException
connection
- connection we're usingregionInfo
- region informationIOException
public static Result getCatalogFamilyRow(Connection connection, RegionInfo ri) throws IOException
HConstants.CATALOG_FAMILY
row from hbase:meta.IOException
public static byte[] getMetaKeyForRegion(RegionInfo regionInfo)
public static RegionInfo parseRegionInfoFromRegionName(byte[] regionName) throws IOException
IOException
public static Result getRegionResult(Connection connection, byte[] regionName) throws IOException
connection
- connection we're usingregionName
- region we're looking forIOException
public static Result scanByRegionEncodedName(Connection connection, String regionEncodedName) throws IOException
Result
instance if any row is found, null otherwise.connection
- the connection to query META table.regionEncodedName
- the region encoded name to look for at META.Result
instance with the row related info in META, null otherwise.IOException
- if any errors occur while querying META.@Nullable public static List<RegionInfo> getMergeRegions(Connection connection, byte[] regionName) throws IOException
regionName
row.IOException
public static boolean hasMergeRegions(Connection conn, byte[] regionName) throws IOException
regionName
has any 'info:merge*' columns.IOException
@Nullable public static Map<String,RegionInfo> getMergeRegionsWithName(Cell[] cells)
cells
.@Nullable public static List<RegionInfo> getMergeRegions(Cell[] cells)
cells
.public static boolean hasMergeRegions(Cell[] cells)
cells
; i.e. the column in
cell
matches the regex 'info:merge.*'.private static boolean isMergeQualifierPrefix(Cell cell)
cell
matches the regex 'info:merge.*'.public static List<RegionInfo> getAllRegions(Connection connection, boolean excludeOfflinedSplitParents) throws IOException
connection
- to connect withexcludeOfflinedSplitParents
- False if we are to include offlined/splitparents regions,
true and we'll leave out offlined regions from returned listIOException
public static List<RegionInfo> getTableRegions(Connection connection, TableName tableName) throws IOException
connection
- connection we're usingtableName
- table we're looking forRegionInfo
.IOException
public static List<RegionInfo> getTableRegions(Connection connection, TableName tableName, boolean excludeOfflinedSplitParents) throws IOException
connection
- connection we're usingtableName
- table we're looking forexcludeOfflinedSplitParents
- If true, do not include offlined split parents in the
return.RegionInfo
.IOException
private static List<RegionInfo> getListOfRegionInfos(List<Pair<RegionInfo,ServerName>> pairs)
public static byte[] getTableStartRowForMeta(TableName tableName, MetaTableAccessor.QueryType type)
public static byte[] getTableStopRowForMeta(TableName tableName, MetaTableAccessor.QueryType type)
public static Scan getScanForTableName(org.apache.hadoop.conf.Configuration conf, TableName tableName)
tableName
- bytes of table's nameprivate static Scan getMetaScan(org.apache.hadoop.conf.Configuration conf, int rowUpperLimit)
public static List<Pair<RegionInfo,ServerName>> getTableRegionsAndLocations(Connection connection, TableName tableName) throws IOException
connection
- connection we're usingtableName
- table we're looking forIOException
public static List<Pair<RegionInfo,ServerName>> getTableRegionsAndLocations(Connection connection, @Nullable TableName tableName, boolean excludeOfflinedSplitParents) throws IOException
connection
- connection we're usingtableName
- table to work with, can be null for getting all regionsexcludeOfflinedSplitParents
- don't return split parentsIOException
public static NavigableMap<RegionInfo,Result> getServerUserRegions(Connection connection, ServerName serverName) throws IOException
connection
- connection we're usingserverName
- server whose regions we're interested inIOException
public static void fullScanMetaAndPrint(Connection connection) throws IOException
IOException
public static void scanMetaForTableRegions(Connection connection, MetaTableAccessor.Visitor visitor, TableName tableName, CatalogReplicaMode metaReplicaMode) throws IOException
IOException
public static void scanMetaForTableRegions(Connection connection, MetaTableAccessor.Visitor visitor, TableName tableName) throws IOException
IOException
private static void scanMeta(Connection connection, TableName table, MetaTableAccessor.QueryType type, int maxRows, MetaTableAccessor.Visitor visitor, CatalogReplicaMode metaReplicaMode) throws IOException
IOException
private static void scanMeta(Connection connection, @Nullable byte[] startRow, @Nullable byte[] stopRow, MetaTableAccessor.QueryType type, MetaTableAccessor.Visitor visitor) throws IOException
IOException
public static void scanMeta(Connection connection, MetaTableAccessor.Visitor visitor, TableName tableName, byte[] row, int rowLimit) throws IOException
connection
- connection we're usingvisitor
- visitor to calltableName
- table withing we scanrow
- start scan from this rowrowLimit
- max number of rows to returnIOException
static void scanMeta(Connection connection, @Nullable byte[] startRow, @Nullable byte[] stopRow, MetaTableAccessor.QueryType type, int maxRows, MetaTableAccessor.Visitor visitor) throws IOException
connection
- connection we're usingstartRow
- Where to start the scan. Pass null if want to begin scan at first row.stopRow
- Where to stop the scan. Pass null if want to scan all rows from the start onetype
- scanned part of metamaxRows
- maximum rows to returnvisitor
- Visitor invoked against each row.IOException
private static void scanMeta(Connection connection, @Nullable byte[] startRow, @Nullable byte[] stopRow, MetaTableAccessor.QueryType type, @Nullable Filter filter, int maxRows, MetaTableAccessor.Visitor visitor, CatalogReplicaMode metaReplicaMode) throws IOException
IOException
@NonNull private static RegionInfo getClosestRegionInfo(Connection connection, @NonNull TableName tableName, @NonNull byte[] row) throws IOException
row
IOException
public static byte[] getCatalogFamily()
private static byte[] getTableFamily()
public static byte[] getRegionInfoColumn()
private static byte[] getTableStateColumn()
private static byte[] getRegionStateColumn()
public static byte[] getRegionStateColumn(int replicaId)
replicaId
- the replicaId of the regionpublic static byte[] getServerNameColumn(int replicaId)
replicaId
- the replicaId of the regionpublic static byte[] getServerColumn(int replicaId)
replicaId
- the replicaId of the regionpublic static byte[] getStartCodeColumn(int replicaId)
replicaId
- the replicaId of the regionpublic static byte[] getSeqNumColumn(int replicaId)
replicaId
- the replicaId of the regionstatic int parseReplicaIdFromServerColumn(byte[] serverColumn)
serverColumn
- the column qualifier@Nullable @InterfaceAudience.Private public static ServerName getServerName(Result r, int replicaId)
ServerName
from catalog table Result
.r
- Result to pull from@Nullable public static ServerName getTargetServerName(Result r, int replicaId)
ServerName
from catalog table Result
where the region is
transitioning on. It should be the same as getServerName(Result,int)
if the server is at OPEN state.r
- Result to pull the transitioning server name fromgetServerName(Result,int)
if
necessary fields not found or empty.private static long getSeqNumDuringOpen(Result r, int replicaId)
getServerName(Result, int)
was written.r
- Result to pull the seqNum frompublic static PairOfSameType<RegionInfo> getDaughterRegions(Result data)
data
- a Result object from the catalog table scan@Nullable public static RegionLocations getRegionLocations(Result r)
private static HRegionLocation getRegionLocation(Result r, RegionInfo regionInfo, int replicaId)
r
- the meta row resultregionInfo
- RegionInfo for default replicareplicaId
- the replicaId for the HRegionLocationpublic static RegionInfo getRegionInfo(Result data)
data
- a Result object from the catalog table scan@Nullable public static RegionInfo getRegionInfo(Result r, byte[] qualifier)
HConstants.CATALOG_FAMILY
and
qualifier
of the catalog table result.r
- a Result object from the catalog table scanqualifier
- Column family qualifier@Nullable public static TableState getTableState(Connection conn, TableName tableName) throws IOException
conn
- connection to usetableName
- table to fetch state forIOException
public static Map<TableName,TableState> getTableStates(Connection conn) throws IOException
conn
- connection to useIOException
public static void updateTableState(Connection conn, TableName tableName, TableState.State actual) throws IOException
conn
- connection to usetableName
- table to look forIOException
@Nullable public static TableState getTableState(Result r) throws IOException
IOException
public static Put makePutFromRegionInfo(RegionInfo regionInfo, long ts) throws IOException
IOException
public static Delete makeDeleteFromRegionInfo(RegionInfo regionInfo, long ts)
private static Put addDaughtersToPut(Put put, RegionInfo splitA, RegionInfo splitB) throws IOException
IOException
private static void putToMetaTable(Connection connection, Put p) throws IOException
p
to the hbase:meta
table.connection
- connection we're usingp
- Put to add to hbase:metaIOException
private static void put(Table t, Put p) throws IOException
t
- Table to usep
- put to makeIOException
public static void putsToMetaTable(Connection connection, List<Put> ps) throws IOException
ps
to the hbase:meta
table.connection
- connection we're usingps
- Put to add to hbase:metaIOException
private static void deleteFromMetaTable(Connection connection, Delete d) throws IOException
d
from the hbase:meta
table.connection
- connection we're usingd
- Delete to add to hbase:metaIOException
private static void deleteFromMetaTable(Connection connection, List<Delete> deletes) throws IOException
deletes
from the hbase:meta
table.connection
- connection we're usingdeletes
- Deletes to add to hbase:meta This list should support #remove.IOException
private static Put addRegionStateToPut(Put put, RegionState.State state) throws IOException
IOException
public static void updateRegionState(Connection connection, RegionInfo ri, RegionState.State state) throws IOException
IOException
public static void addSplitsToParent(Connection connection, RegionInfo regionInfo, RegionInfo splitA, RegionInfo splitB) throws IOException
splitRegion(Connection, RegionInfo, long, RegionInfo, RegionInfo, ServerName, int)
if
you want to do that.connection
- connection we're usingregionInfo
- RegionInfo of parent regionsplitA
- first split daughter of the parent regionInfosplitB
- second split daughter of the parent regionInfoIOException
- if problem connecting or updating metapublic static void addRegionToMeta(Connection connection, RegionInfo regionInfo) throws IOException
splitRegion(Connection, RegionInfo, long, RegionInfo, RegionInfo, ServerName, int)
if
you want to do that.connection
- connection we're usingregionInfo
- region informationIOException
- if problem connecting or updating metapublic static void addRegionsToMeta(Connection connection, List<RegionInfo> regionInfos, int regionReplication) throws IOException
connection
- connection we're usingregionInfos
- region information listIOException
- if problem connecting or updating metaprivate static void addRegionsToMeta(Connection connection, List<RegionInfo> regionInfos, int regionReplication, long ts) throws IOException
connection
- connection we're usingregionInfos
- region information listts
- desired timestampIOException
- if problem connecting or updating metastatic Put addMergeRegions(Put put, Collection<RegionInfo> mergeRegions) throws IOException
IOException
public static void mergeRegions(Connection connection, RegionInfo mergedRegion, Map<RegionInfo,Long> parentSeqNum, ServerName sn, int regionReplication) throws IOException
connection
- connection we're usingmergedRegion
- the merged regionparentSeqNum
- Parent regions to merge and their next open sequence id used by serial
replication. Set to -1 if not needed by this table.sn
- the location of the regionIOException
public static void splitRegion(Connection connection, RegionInfo parent, long parentOpenSeqNum, RegionInfo splitA, RegionInfo splitB, ServerName sn, int regionReplication) throws IOException
connection
- connection we're usingparent
- the parent region which is splitparentOpenSeqNum
- the next open sequence id for parent region, used by serial
replication. -1 if not necessary.splitA
- Split daughter region AsplitB
- Split daughter region Bsn
- the location of the regionIOException
private static void updateTableState(Connection connection, TableState state) throws IOException
connection
- what we use for updatestate
- new stateIOException
public static Put makePutFromTableState(TableState state, long ts)
state
- new statepublic static void deleteTableState(Connection connection, TableName table) throws IOException
connection
- to use for deletiontable
- to delete state forIOException
private static void multiMutate(Table table, byte[] row, Mutation... mutations) throws IOException
IOException
static void multiMutate(Table table, byte[] row, List<Mutation> mutations) throws IOException
IOException
- even if we encounter a RuntimeException, we'll still wrap it in an IOE.public static void updateRegionLocation(Connection connection, RegionInfo regionInfo, ServerName sn, long openSeqNum, long masterSystemTime) throws IOException
Uses passed catalog tracker to get a connection to the server hosting hbase:meta and makes edits to that region.
connection
- connection we're usingregionInfo
- region to update location ofopenSeqNum
- the latest sequence number obtained when the region was opensn
- Server namemasterSystemTime
- wall clock time from master if passed in the open region RPCIOException
private static void updateLocation(Connection connection, RegionInfo regionInfo, ServerName sn, long openSeqNum, long masterSystemTime) throws IOException
Connects to the specified server which should be hosting the specified catalog region name to perform the edit.
connection
- connection we're usingregionInfo
- region to update location ofsn
- Server nameopenSeqNum
- the latest sequence number obtained when the region was openmasterSystemTime
- wall clock time from master if passed in the open region RPCIOException
- In particular could throw ConnectException
if the server
is down on other end.public static void deleteRegionInfo(Connection connection, RegionInfo regionInfo) throws IOException
connection
- connection we're usingregionInfo
- region to be deleted from METAIOException
public static void deleteRegionInfos(Connection connection, List<RegionInfo> regionsInfo) throws IOException
connection
- connection we're usingregionsInfo
- list of regions to be deleted from METAIOException
private static void deleteRegionInfos(Connection connection, List<RegionInfo> regionsInfo, long ts) throws IOException
connection
- connection we're usingregionsInfo
- list of regions to be deleted from METAIOException
public static void overwriteRegions(Connection connection, List<RegionInfo> regionInfos, int regionReplication) throws IOException
connection
- connection we're usingregionInfos
- list of regions to be added to METAIOException
public static void deleteMergeQualifiers(Connection connection, RegionInfo mergeRegion) throws IOException
connection
- connection we're usingmergeRegion
- the merged regionIOException
public static Put addRegionInfo(Put p, RegionInfo hri) throws IOException
IOException
public static Put addLocation(Put p, ServerName sn, long openSeqNum, int replicaId) throws IOException
IOException
private static void writeRegionName(ByteArrayOutputStream out, byte[] regionName)
public static byte[] getParentsBytes(List<RegionInfo> parents)
private static List<byte[]> parseParentsBytes(byte[] bytes)
private static void addReplicationParent(Put put, List<RegionInfo> parents) throws IOException
IOException
public static Put makePutForReplicationBarrier(RegionInfo regionInfo, long openSeqNum, long ts) throws IOException
IOException
public static void addReplicationBarrier(Put put, long openSeqNum) throws IOException
IOException
public static Put addEmptyLocation(Put p, int replicaId) throws IOException
IOException
private static long getReplicationBarrier(Cell c)
public static long[] getReplicationBarriers(Result result)
private static MetaTableAccessor.ReplicationBarrierResult getReplicationBarrierResult(Result result)
public static MetaTableAccessor.ReplicationBarrierResult getReplicationBarrierResult(Connection conn, TableName tableName, byte[] row, byte[] encodedRegionName) throws IOException
IOException
public static long[] getReplicationBarrier(Connection conn, byte[] regionName) throws IOException
IOException
public static List<Pair<String,Long>> getTableEncodedRegionNameAndLastBarrier(Connection conn, TableName tableName) throws IOException
IOException
public static List<String> getTableEncodedRegionNamesForSerialReplication(Connection conn, TableName tableName) throws IOException
IOException
private static void debugLogMutations(List<? extends Mutation> mutations) throws IOException
IOException
private static void debugLogMutation(Mutation p) throws IOException
IOException
private static Put addSequenceNum(Put p, long openSeqNum, int replicaId) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.