@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(HConnection hConnection,
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 |
addLocation(Put p,
ServerName sn,
long openSeqNum,
int replicaId) |
static void |
addRegionsToMeta(HConnection hConnection,
List<HRegionInfo> regionInfos)
Adds a hbase:meta row for each of the specified new regions.
|
static void |
addRegionToMeta(HConnection hConnection,
HRegionInfo regionInfo)
Adds a hbase:meta row for the specified new region.
|
static void |
addRegionToMeta(HConnection hConnection,
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 void |
deleteFromMetaTable(HConnection hConnection,
List<Delete> deletes)
Delete the passed
deletes from the hbase:meta table. |
static void |
deleteMergeQualifiers(HConnection hConnection,
HRegionInfo mergedRegion)
Deletes merge qualifiers for the specified merged region.
|
static void |
deleteRegion(HConnection hConnection,
HRegionInfo regionInfo)
Deletes the specified region from META.
|
static void |
deleteRegions(HConnection hConnection,
List<HRegionInfo> regionsInfo)
Deletes the specified regions from META.
|
static List<Result> |
fullScan(HConnection hConnection)
Performs a full scan of
hbase:meta . |
static void |
fullScan(HConnection hConnection,
MetaTableAccessor.Visitor visitor)
Performs a full scan of
hbase:meta . |
static void |
fullScan(HConnection hConnection,
MetaTableAccessor.Visitor visitor,
byte[] startrow)
Performs a full scan of a catalog table.
|
static void |
fullScanMetaAndPrint(HConnection hConnection) |
static List<Result> |
fullScanOfMeta(HConnection hConnection)
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(HConnection hConnection,
byte[] regionName)
Deprecated.
use
getRegionLocation(HConnection, byte[]) instead |
static int |
getRegionCount(org.apache.hadoop.conf.Configuration c,
String tableName)
Count regions in
hbase:meta for passed table. |
protected static byte[] |
getRegionInfoColumn()
Returns the column qualifier for serialized region info
|
static HRegionLocation |
getRegionLocation(HConnection hConnection,
byte[] regionName)
Returns the HRegionLocation from meta for the given region
|
static HRegionLocation |
getRegionLocation(HConnection hConnection,
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(HConnection hConnection,
byte[] regionName)
Gets the result in hbase:meta for the specified region.
|
static Pair<HRegionInfo,HRegionInfo> |
getRegionsFromMergeQualifier(HConnection hConnection,
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(HConnection hConnection,
ServerName serverName) |
static byte[] |
getStartCodeColumn(int replicaId)
Returns the column qualifier for server start code column for replicaId
|
static List<HRegionInfo> |
getTableRegions(ZooKeeperWatcher zkw,
HConnection hConnection,
TableName tableName)
Gets all of the regions of the specified table.
|
static List<HRegionInfo> |
getTableRegions(ZooKeeperWatcher zkw,
HConnection hConnection,
TableName tableName,
boolean excludeOfflinedSplitParents)
Gets all of the regions of the specified table.
|
static List<Pair<HRegionInfo,ServerName>> |
getTableRegionsAndLocations(ZooKeeperWatcher zkw,
HConnection hConnection,
TableName tableName) |
static List<Pair<HRegionInfo,ServerName>> |
getTableRegionsAndLocations(ZooKeeperWatcher zkw,
HConnection hConnection,
TableName tableName,
boolean excludeOfflinedSplitParents) |
static Delete |
makeDeleteFromRegionInfo(HRegionInfo regionInfo)
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 void |
mergeRegions(HConnection hConnection,
HRegionInfo mergedRegion,
HRegionInfo regionA,
HRegionInfo regionB,
ServerName sn)
Merge the two regions into one in an atomic operation.
|
static void |
mutateMetaTable(HConnection hConnection,
List<Mutation> mutations)
Execute the passed
mutations against hbase:meta table. |
static void |
mutateRegions(HConnection hConnection,
List<HRegionInfo> regionsToRemove,
List<HRegionInfo> regionsToAdd)
Adds and Removes the specified regions from hbase:meta
|
static void |
overwriteRegions(HConnection hConnection,
List<HRegionInfo> regionInfos)
Overwrites the specified regions from hbase:meta
|
protected static HRegionInfo |
parseRegionInfoFromRegionName(byte[] regionName)
Returns an HRI parsed from this regionName.
|
static void |
putsToMetaTable(HConnection hConnection,
List<Put> ps)
Put the passed
ps to the hbase:meta table. |
static void |
removeRegionReplicasFromMeta(Set<byte[]> metaRows,
int replicaIndexToDeleteFrom,
int numReplicasToRemove,
HConnection hConnection)
Deletes some replica columns corresponding to replicas for the passed rows
|
static void |
splitRegion(HConnection hConnection,
HRegionInfo parent,
HRegionInfo splitA,
HRegionInfo splitB,
ServerName sn)
Splits the region into two in an atomic operation.
|
static boolean |
tableExists(HConnection hConnection,
TableName tableName)
Checks if the specified table exists.
|
static void |
updateRegionLocation(HConnection hConnection,
HRegionInfo regionInfo,
ServerName sn,
long updateSeqNum)
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(HConnection hConnection) throws IOException
hbase:meta
table.Result
IOException
public static void fullScan(HConnection hConnection, MetaTableAccessor.Visitor visitor) throws IOException
hbase:meta
.hConnection
- connection we're usingvisitor
- Visitor invoked against each row.IOException
public static List<Result> fullScan(HConnection hConnection) throws IOException
hbase:meta
.hConnection
- connection we're usingResult
IOException
@Deprecated public static Pair<HRegionInfo,ServerName> getRegion(HConnection hConnection, byte[] regionName) throws IOException
getRegionLocation(HConnection, byte[])
insteadhConnection
- connection we're usingregionName
- Region to lookup.regionName
IOException
public static HRegionLocation getRegionLocation(HConnection hConnection, byte[] regionName) throws IOException
hConnection
- connection we're usingregionName
- region we're looking forIOException
public static HRegionLocation getRegionLocation(HConnection hConnection, HRegionInfo regionInfo) throws IOException
hConnection
- 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(HConnection hConnection, byte[] regionName) throws IOException
hConnection
- connection we're usingregionName
- region we're looking forIOException
public static Pair<HRegionInfo,HRegionInfo> getRegionsFromMergeQualifier(HConnection hConnection, byte[] regionName) throws IOException
IOException
public static boolean tableExists(HConnection hConnection, TableName tableName) throws IOException
hConnection
- connection we're usingtableName
- table to checkIOException
public static List<HRegionInfo> getTableRegions(ZooKeeperWatcher zkw, HConnection hConnection, TableName tableName) throws IOException
zkw
- zookeeper connection to access meta tablehConnection
- connection we're usingtableName
- table we're looking forHRegionInfo
.IOException
public static List<HRegionInfo> getTableRegions(ZooKeeperWatcher zkw, HConnection hConnection, TableName tableName, boolean excludeOfflinedSplitParents) throws IOException
zkw
- zookeeper connection to access meta tablehConnection
- connection we're usingtableName
- table we're looking forexcludeOfflinedSplitParents
- If true, do not include offlined split
parents in the return.HRegionInfo
.IOException
public static Scan getScanForTableName(TableName tableName)
tableName
- bytes of table's namepublic static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(ZooKeeperWatcher zkw, HConnection hConnection, TableName tableName) throws IOException, InterruptedException
zkw
- zookeeper connection to access meta tablehConnection
- connection we're usingtableName
- table we're looking forIOException
InterruptedException
public static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(ZooKeeperWatcher zkw, HConnection hConnection, TableName tableName, boolean excludeOfflinedSplitParents) throws IOException, InterruptedException
zkw
- ZooKeeperWatcher instance we're using to get hbase:meta locationhConnection
- connection we're usingtableName
- table to work withIOException
InterruptedException
public static NavigableMap<HRegionInfo,Result> getServerUserRegions(HConnection hConnection, ServerName serverName) throws IOException
hConnection
- connection we're usingserverName
- server whose regions we're interested inIOException
public static void fullScanMetaAndPrint(HConnection hConnection) throws IOException
IOException
public static void fullScan(HConnection hConnection, MetaTableAccessor.Visitor visitor, byte[] startrow) throws IOException
hConnection
- 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) throws IOException
data
- a Result object from the catalog table scanIOException
public static PairOfSameType<HRegionInfo> getMergeRegions(Result data) throws IOException
data
- a Result object from the catalog table scanIOException
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 Put makePutFromRegionInfo(HRegionInfo regionInfo) throws IOException
IOException
public static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo)
public static Put addDaughtersToPut(Put put, HRegionInfo splitA, HRegionInfo splitB)
public static void putsToMetaTable(HConnection hConnection, List<Put> ps) throws IOException
ps
to the hbase:meta
table.hConnection
- connection we're usingps
- Put to add to hbase:metaIOException
public static void deleteFromMetaTable(HConnection hConnection, List<Delete> deletes) throws IOException
deletes
from the hbase:meta
table.hConnection
- 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, HConnection hConnection) throws IOException
metaRows
- rows in hbase:metareplicaIndexToDeleteFrom
- the replica ID we would start deleting fromnumReplicasToRemove
- how many replicas to removehConnection
- connection we're using to access meta tableIOException
public static void mutateMetaTable(HConnection hConnection, List<Mutation> mutations) throws IOException
mutations
against hbase:meta
table.hConnection
- connection we're usingmutations
- Puts and Deletes to execute on hbase:metaIOException
public static void addRegionToMeta(HConnection hConnection, HRegionInfo regionInfo) throws IOException
hConnection
- connection we're usingregionInfo
- region informationIOException
- if problem connecting or updating metapublic static void addRegionToMeta(Table meta, HRegionInfo regionInfo) throws IOException
meta
- the HTable for METAregionInfo
- region informationIOException
- if problem connecting or updating metapublic static void addRegionToMeta(Table meta, HRegionInfo regionInfo, HRegionInfo splitA, HRegionInfo splitB) throws IOException
splitRegion(org.apache.hadoop.hbase.client.HConnection,
HRegionInfo, HRegionInfo, HRegionInfo, ServerName)
if you want to do that.meta
- the HTable 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(HConnection hConnection, HRegionInfo regionInfo, HRegionInfo splitA, HRegionInfo splitB) throws IOException
splitRegion(HConnection, HRegionInfo, HRegionInfo, HRegionInfo, ServerName)
if you want to do that.hConnection
- 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(HConnection hConnection, List<HRegionInfo> regionInfos) throws IOException
hConnection
- connection we're usingregionInfos
- region information listIOException
- if problem connecting or updating metapublic static void addDaughter(HConnection hConnection, 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(HConnection hConnection, HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB, ServerName sn) throws IOException
hConnection
- connection we're usingmergedRegion
- the merged regionregionA
- regionB
- sn
- the location of the regionIOException
public static void splitRegion(HConnection hConnection, HRegionInfo parent, HRegionInfo splitA, HRegionInfo splitB, ServerName sn) throws IOException
hConnection
- 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(HConnection hConnection, HRegionInfo regionInfo, ServerName sn, long updateSeqNum) throws IOException
Uses passed catalog tracker to get a connection to the server hosting hbase:meta and makes edits to that region.
hConnection
- connection we're usingregionInfo
- region to update location ofsn
- Server nameIOException
public static void deleteRegion(HConnection hConnection, HRegionInfo regionInfo) throws IOException
hConnection
- connection we're usingregionInfo
- region to be deleted from METAIOException
public static void deleteRegions(HConnection hConnection, List<HRegionInfo> regionsInfo) throws IOException
hConnection
- connection we're usingregionsInfo
- list of regions to be deleted from METAIOException
public static void mutateRegions(HConnection hConnection, List<HRegionInfo> regionsToRemove, List<HRegionInfo> regionsToAdd) throws IOException
hConnection
- connection we're usingregionsToRemove
- list of regions to be deleted from METAregionsToAdd
- list of regions to be added to METAIOException
public static void overwriteRegions(HConnection hConnection, List<HRegionInfo> regionInfos) throws IOException
hConnection
- connection we're usingregionInfos
- list of regions to be added to METAIOException
public static void deleteMergeQualifiers(HConnection hConnection, HRegionInfo mergedRegion) throws IOException
hConnection
- connection we're usingmergedRegion
- IOException
public static Put addLocation(Put p, ServerName sn, long openSeqNum, int replicaId)
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.