@InterfaceAudience.Private public class MetaTableAccessor extends Object
hbase:meta
.
Some of the methods of this class take ZooKeeperWatcher as a param. The only reason
for this is because when used on client-side (like from HBaseAdmin), we want to use
short-living connection (opened before each operation, closed right after), while
when used on HM or HRS (like in AssignmentManager) we want permanent connection.Modifier and Type | Class and Description |
---|---|
static interface |
MetaTableAccessor.Visitor
Implementations 'visit' a catalog table row.
|
Modifier and Type | Field and Description |
---|---|
protected static char |
META_REPLICA_ID_DELIMITER
The delimiter for meta columns for replicaIds > 0
|
Constructor and Description |
---|
MetaTableAccessor() |
Modifier and Type | Method and Description |
---|---|
static void |
addDaughter(Connection connection,
HRegionInfo regionInfo,
ServerName sn,
long openSeqNum)
Adds a daughter region entry to meta.
|
static Put |
addDaughtersToPut(Put put,
HRegionInfo splitA,
HRegionInfo splitB)
Adds split daughters to the Put
|
static Put |
addEmptyLocation(Put p,
int replicaId) |
static Put |
addLocation(Put p,
ServerName sn,
long openSeqNum,
long time,
int replicaId) |
static void |
addRegionsToMeta(Connection connection,
List<HRegionInfo> regionInfos,
int regionReplication)
Adds a hbase:meta row for each of the specified new regions.
|
static void |
addRegionsToMeta(Connection connection,
List<HRegionInfo> regionInfos,
int regionReplication,
long ts)
Adds a hbase:meta row for each of the specified new regions.
|
static void |
addRegionToMeta(Connection connection,
HRegionInfo regionInfo)
Adds a hbase:meta row for the specified new region.
|
static void |
addRegionToMeta(Connection connection,
HRegionInfo regionInfo,
HRegionInfo splitA,
HRegionInfo splitB)
Adds a (single) hbase:meta row for the specified new region and its daughters.
|
static void |
addRegionToMeta(Table meta,
HRegionInfo regionInfo)
Adds a hbase:meta row for the specified new region to the given catalog table.
|
static void |
addRegionToMeta(Table meta,
HRegionInfo regionInfo,
HRegionInfo splitA,
HRegionInfo splitB)
Adds a (single) hbase:meta row for the specified new region and its daughters.
|
static Put |
addSequenceNum(Put p,
long openSeqNum,
long time,
int replicaId) |
static void |
deleteFromMetaTable(Connection connection,
List<Delete> deletes)
Delete the passed
deletes from the hbase:meta table. |
static void |
deleteMergeQualifiers(Connection connection,
HRegionInfo mergedRegion)
Deletes merge qualifiers for the specified merged region.
|
static void |
deleteRegion(Connection connection,
HRegionInfo regionInfo)
Deletes the specified region from META.
|
static void |
deleteRegions(Connection connection,
List<HRegionInfo> regionsInfo)
Deletes the specified regions from META.
|
static void |
deleteRegions(Connection connection,
List<HRegionInfo> regionsInfo,
long ts)
Deletes the specified regions from META.
|
static List<Result> |
fullScan(Connection connection)
Performs a full scan of
hbase:meta . |
static void |
fullScan(Connection connection,
MetaTableAccessor.Visitor visitor)
Performs a full scan of
hbase:meta . |
static void |
fullScan(Connection connection,
MetaTableAccessor.Visitor visitor,
byte[] startrow)
Performs a full scan of a catalog table.
|
static void |
fullScanMetaAndPrint(Connection connection) |
static List<Result> |
fullScanOfMeta(Connection connection)
Performs a full scan of a
hbase:meta table. |
static PairOfSameType<HRegionInfo> |
getDaughterRegions(Result data)
Returns the daughter regions by reading the corresponding columns of the catalog table
Result.
|
protected static byte[] |
getFamily()
Returns the column family used for meta columns.
|
static HRegionInfo |
getHRegionInfo(Result data)
Returns HRegionInfo object from the column
HConstants.CATALOG_FAMILY:HConstants.REGIONINFO_QUALIFIER of the catalog
table Result.
|
static PairOfSameType<HRegionInfo> |
getMergeRegions(Result data)
Returns the merge regions by reading the corresponding columns of the catalog table
Result.
|
static byte[] |
getMetaKeyForRegion(HRegionInfo regionInfo)
Returns the row key to use for this regionInfo
|
static Pair<HRegionInfo,ServerName> |
getRegion(Connection connection,
byte[] regionName)
Deprecated.
use
getRegionLocation(Connection, byte[]) instead |
static int |
getRegionCount(org.apache.hadoop.conf.Configuration c,
String tableName)
Deprecated.
|
static int |
getRegionCount(org.apache.hadoop.conf.Configuration c,
TableName tableName)
Count regions in
hbase:meta for passed table. |
static int |
getRegionCount(Connection connection,
TableName tableName)
Count regions in
hbase:meta for passed table. |
protected 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,
HRegionInfo regionInfo)
Returns the HRegionLocation from meta for the given region
|
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.
|
static Pair<HRegionInfo,HRegionInfo> |
getRegionsFromMergeQualifier(Connection connection,
byte[] regionName)
Get regions from the merge qualifier of the specified merged region
|
static Scan |
getScanForTableName(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
|
static byte[] |
getServerColumn(int replicaId)
Returns the column qualifier for server column for replicaId
|
static NavigableMap<HRegionInfo,Result> |
getServerUserRegions(Connection connection,
ServerName serverName) |
static byte[] |
getStartCodeColumn(int replicaId)
Returns the column qualifier for server start code column for replicaId
|
static List<HRegionInfo> |
getTableRegions(ZooKeeperWatcher zkw,
Connection connection,
TableName tableName)
Gets all of the regions of the specified table.
|
static List<HRegionInfo> |
getTableRegions(ZooKeeperWatcher zkw,
Connection connection,
TableName tableName,
boolean excludeOfflinedSplitParents)
Gets all of the regions of the specified table.
|
static List<HRegionInfo> |
getTableRegions(ZooKeeperWatcher zkw,
Connection connection,
TableName tableName,
boolean excludeOfflinedSplitParents,
boolean excludeReplicaRegions)
Gets all of the regions of the specified table.
|
static List<Pair<HRegionInfo,ServerName>> |
getTableRegionsAndLocations(ZooKeeperWatcher zkw,
Connection connection,
TableName tableName) |
static List<Pair<HRegionInfo,ServerName>> |
getTableRegionsAndLocations(ZooKeeperWatcher zkw,
Connection connection,
TableName tableName,
boolean excludeOfflinedSplitParents) |
static List<Pair<HRegionInfo,ServerName>> |
getTableRegionsAndLocations(ZooKeeperWatcher zkw,
Connection connection,
TableName tableName,
boolean excludeOfflinedSplitParents,
boolean excludeReplicaRegions) |
static boolean |
infoServerExists(Connection connection)
Checks whether hbase:meta contains any info:server entry.
|
static Delete |
makeDeleteFromRegionInfo(HRegionInfo regionInfo)
Generates and returns a Delete containing the region info for the catalog
table
|
static Delete |
makeDeleteFromRegionInfo(HRegionInfo regionInfo,
long ts)
Generates and returns a Delete containing the region info for the catalog
table
|
static Put |
makePutFromRegionInfo(HRegionInfo regionInfo)
Generates and returns a Put containing the region into for the catalog table
|
static Put |
makePutFromRegionInfo(HRegionInfo regionInfo,
long ts)
Generates and returns a Put containing the region into for the catalog table
|
static void |
mergeRegions(Connection connection,
HRegionInfo mergedRegion,
HRegionInfo regionA,
HRegionInfo regionB,
ServerName sn,
int regionReplication,
long masterSystemTime)
Merge the two regions into one in an atomic operation.
|
static void |
mutateMetaTable(Connection connection,
List<Mutation> mutations)
Execute the passed
mutations against hbase:meta table. |
static void |
mutateRegions(Connection connection,
List<HRegionInfo> regionsToRemove,
List<HRegionInfo> regionsToAdd)
Adds and Removes the specified regions from hbase:meta
|
static void |
overwriteRegions(Connection connection,
List<HRegionInfo> regionInfos,
int regionReplication)
Overwrites the specified regions from hbase:meta
|
protected static HRegionInfo |
parseRegionInfoFromRegionName(byte[] regionName)
Returns an HRI parsed from this regionName.
|
static void |
putsToMetaTable(Connection connection,
List<Put> ps)
Put the passed
ps to the hbase:meta table. |
static void |
removeRegionReplicasFromMeta(Set<byte[]> metaRows,
int replicaIndexToDeleteFrom,
int numReplicasToRemove,
Connection connection)
Deletes some replica columns corresponding to replicas for the passed rows
|
static void |
splitRegion(Connection connection,
HRegionInfo parent,
HRegionInfo splitA,
HRegionInfo splitB,
ServerName sn,
int regionReplication)
Splits the region into two in an atomic operation.
|
static boolean |
tableExists(Connection connection,
TableName tableName)
Checks if the specified table exists.
|
static void |
updateRegionLocation(Connection connection,
HRegionInfo 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.
|
protected static final char META_REPLICA_ID_DELIMITER
public static List<Result> fullScanOfMeta(Connection connection) throws IOException
hbase:meta
table.Result
IOException
public static void fullScan(Connection connection, MetaTableAccessor.Visitor visitor) throws IOException
hbase:meta
.connection
- connection we're usingvisitor
- Visitor invoked against each row.IOException
public static List<Result> fullScan(Connection connection) throws IOException
hbase:meta
.connection
- connection we're usingResult
IOException
@Deprecated public static Pair<HRegionInfo,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, HRegionInfo regionInfo) throws IOException
connection
- connection we're usingregionInfo
- region informationIOException
public static byte[] getMetaKeyForRegion(HRegionInfo regionInfo)
protected static HRegionInfo 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 Pair<HRegionInfo,HRegionInfo> getRegionsFromMergeQualifier(Connection connection, byte[] regionName) throws IOException
IOException
public static boolean tableExists(Connection connection, TableName tableName) throws IOException
connection
- connection we're usingtableName
- table to checkIOException
public static List<HRegionInfo> getTableRegions(ZooKeeperWatcher zkw, Connection connection, TableName tableName) throws IOException
zkw
- zookeeper connection to access meta tableconnection
- connection we're usingtableName
- table we're looking forHRegionInfo
.IOException
public static List<HRegionInfo> getTableRegions(ZooKeeperWatcher zkw, Connection connection, TableName tableName, boolean excludeOfflinedSplitParents) throws IOException
zkw
- zookeeper connection to access meta tableconnection
- connection we're usingtableName
- table we're looking forexcludeOfflinedSplitParents
- If true, do not include offlined split
parents in the return.HRegionInfo
.IOException
public static List<HRegionInfo> getTableRegions(ZooKeeperWatcher zkw, Connection connection, TableName tableName, boolean excludeOfflinedSplitParents, boolean excludeReplicaRegions) throws IOException
zkw
- zookeeper connection to access meta tableconnection
- connection we're usingtableName
- table we're looking forexcludeOfflinedSplitParents
- If true, do not include offlined split parents in the
return.excludeReplicaRegions
- If true, do not include replica regions in the result.HRegionInfo
.IOException
public static Scan getScanForTableName(TableName tableName)
tableName
- bytes of table's namepublic static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(ZooKeeperWatcher zkw, Connection connection, TableName tableName) throws IOException
zkw
- zookeeper connection to access meta tableconnection
- connection we're usingtableName
- table we're looking forIOException
public static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(ZooKeeperWatcher zkw, Connection connection, TableName tableName, boolean excludeOfflinedSplitParents) throws IOException
zkw
- ZooKeeperWatcher instance we're using to get hbase:meta locationconnection
- connection we're usingtableName
- table to work withIOException
public static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(ZooKeeperWatcher zkw, Connection connection, TableName tableName, boolean excludeOfflinedSplitParents, boolean excludeReplicaRegions) throws IOException
zkw
- ZooKeeperWatcher instance we're using to get hbase:meta locationconnection
- connection we're usingtableName
- table to work withexcludeOfflinedSplitParents
- Exclude offline regionsexcludeReplicaRegions
- If true, do not include replica regions in the result.IOException
public static NavigableMap<HRegionInfo,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 fullScan(Connection connection, MetaTableAccessor.Visitor visitor, byte[] startrow) throws IOException
connection
- connection we're usingvisitor
- Visitor invoked against each row.startrow
- Where to start the scan. Pass null if want to begin scan
at first row.
hbase:meta
, the default (pass false to scan hbase:meta)IOException
protected static byte[] getFamily()
protected static byte[] getRegionInfoColumn()
public 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 regionpublic static RegionLocations getRegionLocations(Result r)
public static HRegionInfo getHRegionInfo(Result data)
data
- a Result object from the catalog table scanpublic static PairOfSameType<HRegionInfo> getDaughterRegions(Result data)
data
- a Result object from the catalog table scanpublic static PairOfSameType<HRegionInfo> getMergeRegions(Result data)
data
- a Result object from the catalog table scan@Deprecated public static int getRegionCount(org.apache.hadoop.conf.Configuration c, String tableName) throws IOException
hbase:meta
for passed table.c
- Configuration objecttableName
- table name to count regions fortableName
IOException
public static int getRegionCount(org.apache.hadoop.conf.Configuration c, TableName tableName) throws IOException
hbase:meta
for passed table.c
- Configuration objecttableName
- table name to count regions fortableName
IOException
public static int getRegionCount(Connection connection, TableName tableName) throws IOException
hbase:meta
for passed table.connection
- Connection objecttableName
- table name to count regions fortableName
IOException
public static Put makePutFromRegionInfo(HRegionInfo regionInfo) throws IOException
IOException
public static Put makePutFromRegionInfo(HRegionInfo regionInfo, long ts) throws IOException
IOException
public static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo)
public static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo, long ts)
public static Put addDaughtersToPut(Put put, HRegionInfo splitA, HRegionInfo splitB)
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
public 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
public static void removeRegionReplicasFromMeta(Set<byte[]> metaRows, int replicaIndexToDeleteFrom, int numReplicasToRemove, Connection connection) throws IOException
metaRows
- rows in hbase:metareplicaIndexToDeleteFrom
- the replica ID we would start deleting fromnumReplicasToRemove
- how many replicas to removeconnection
- connection we're using to access meta tableIOException
public static void mutateMetaTable(Connection connection, List<Mutation> mutations) throws IOException
mutations
against hbase:meta
table.connection
- connection we're usingmutations
- Puts and Deletes to execute on hbase:metaIOException
public static void addRegionToMeta(Connection connection, HRegionInfo regionInfo) throws IOException
connection
- connection we're usingregionInfo
- region informationIOException
- if problem connecting or updating metapublic static void addRegionToMeta(Table meta, HRegionInfo regionInfo) throws IOException
meta
- the Table for METAregionInfo
- region informationIOException
- if problem connecting or updating metapublic static void addRegionToMeta(Table meta, HRegionInfo regionInfo, HRegionInfo splitA, HRegionInfo splitB) throws IOException
splitRegion(Connection, HRegionInfo, HRegionInfo, HRegionInfo, ServerName, int)
if you want to do that.meta
- the Table for METAregionInfo
- region informationsplitA
- 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, HRegionInfo regionInfo, HRegionInfo splitA, HRegionInfo splitB) throws IOException
splitRegion(Connection, HRegionInfo, HRegionInfo, HRegionInfo, ServerName, int)
if you want to do that.connection
- connection we're usingregionInfo
- region informationsplitA
- first split daughter of the parent regionInfosplitB
- second split daughter of the parent regionInfoIOException
- if problem connecting or updating metapublic static void addRegionsToMeta(Connection connection, List<HRegionInfo> regionInfos, int regionReplication) throws IOException
connection
- connection we're usingregionInfos
- region information listIOException
- if problem connecting or updating metapublic static void addRegionsToMeta(Connection connection, List<HRegionInfo> regionInfos, int regionReplication, long ts) throws IOException
connection
- connection we're usingregionInfos
- region information listregionReplication
- ts
- desired timestampIOException
- if problem connecting or updating metapublic static void addDaughter(Connection connection, HRegionInfo regionInfo, ServerName sn, long openSeqNum) throws NotAllMetaRegionsOnlineException, IOException
regionInfo
- the region to putsn
- the location of the regionopenSeqNum
- the latest sequence number obtained when the region was openNotAllMetaRegionsOnlineException
IOException
public static void mergeRegions(Connection connection, HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB, ServerName sn, int regionReplication, long masterSystemTime) throws IOException
connection
- connection we're usingmergedRegion
- the merged regionregionA
- regionB
- sn
- the location of the regionmasterSystemTime
- IOException
public static void splitRegion(Connection connection, HRegionInfo parent, HRegionInfo splitA, HRegionInfo splitB, ServerName sn, int regionReplication) throws IOException
connection
- connection we're usingparent
- the parent region which is splitsplitA
- Split daughter region AsplitB
- Split daughter region Asn
- the location of the regionIOException
public static void updateRegionLocation(Connection connection, HRegionInfo 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 RPC or -1IOException
public static void deleteRegion(Connection connection, HRegionInfo regionInfo) throws IOException
connection
- connection we're usingregionInfo
- region to be deleted from METAIOException
public static void deleteRegions(Connection connection, List<HRegionInfo> regionsInfo, long ts) throws IOException
connection
- connection we're usingregionsInfo
- list of regions to be deleted from METAts
- desired timestampIOException
public static void deleteRegions(Connection connection, List<HRegionInfo> regionsInfo) throws IOException
connection
- connection we're usingregionsInfo
- list of regions to be deleted from METAIOException
public static void mutateRegions(Connection connection, List<HRegionInfo> regionsToRemove, List<HRegionInfo> regionsToAdd) throws IOException
connection
- connection we're usingregionsToRemove
- list of regions to be deleted from METAregionsToAdd
- list of regions to be added to METAIOException
public static void overwriteRegions(Connection connection, List<HRegionInfo> regionInfos, int regionReplication) throws IOException
connection
- connection we're usingregionInfos
- list of regions to be added to METAIOException
public static void deleteMergeQualifiers(Connection connection, HRegionInfo mergedRegion) throws IOException
connection
- connection we're usingmergedRegion
- IOException
public static Put addLocation(Put p, ServerName sn, long openSeqNum, long time, int replicaId)
public static boolean infoServerExists(Connection connection) throws IOException
connection
- connection we're usingIOException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.