org.apache.hadoop.hbase.catalog
Class MetaReader

java.lang.Object
  extended by org.apache.hadoop.hbase.catalog.MetaReader

@InterfaceAudience.Private
public class MetaReader
extends Object

Reads region and assignment information from hbase:meta.


Nested Class Summary
static interface MetaReader.Visitor
          Implementations 'visit' a catalog table row.
 
Constructor Summary
MetaReader()
           
 
Method Summary
static List<Result> fullScan(CatalogTracker catalogTracker)
          Performs a full scan of hbase:meta.
static void fullScan(CatalogTracker catalogTracker, MetaReader.Visitor visitor)
          Performs a full scan of hbase:meta.
static void fullScan(CatalogTracker catalogTracker, MetaReader.Visitor visitor, byte[] startrow)
          Performs a full scan of a catalog table.
static Map<HRegionInfo,ServerName> fullScan(CatalogTracker catalogTracker, Set<TableName> disabledTables)
          Performs a full scan of hbase:meta, skipping regions from any tables in the specified set of disabled tables.
static Map<HRegionInfo,ServerName> fullScan(CatalogTracker catalogTracker, Set<TableName> disabledTables, boolean excludeOfflinedSplitParents)
          Performs a full scan of hbase:meta, skipping regions from any tables in the specified set of disabled tables.
static void fullScanMetaAndPrint(CatalogTracker catalogTracker)
           
static List<Result> fullScanOfMeta(CatalogTracker catalogTracker)
          Performs a full scan of a hbase:meta table.
static Pair<HRegionInfo,ServerName> getRegion(CatalogTracker catalogTracker, byte[] regionName)
          Gets the region info and assignment for the specified region.
static int getRegionCount(org.apache.hadoop.conf.Configuration c, String tableName)
          Count regions in hbase:meta for passed table.
static Result getRegionResult(CatalogTracker catalogTracker, byte[] regionName)
          Gets the result in hbase:meta for the specified region.
static Pair<HRegionInfo,HRegionInfo> getRegionsFromMergeQualifier(CatalogTracker catalogTracker, 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 NavigableMap<HRegionInfo,Result> getServerUserRegions(CatalogTracker catalogTracker, ServerName serverName)
           
static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker, TableName tableName)
          Gets all of the regions of the specified table.
static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker, TableName tableName, boolean excludeOfflinedSplitParents)
          Gets all of the regions of the specified table.
static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(CatalogTracker catalogTracker, TableName tableName)
           
static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(CatalogTracker catalogTracker, TableName tableName, boolean excludeOfflinedSplitParents)
           
static boolean tableExists(CatalogTracker catalogTracker, TableName tableName)
          Checks if the specified table exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaReader

public MetaReader()
Method Detail

fullScan

public static Map<HRegionInfo,ServerName> fullScan(CatalogTracker catalogTracker,
                                                   Set<TableName> disabledTables)
                                            throws IOException
Performs a full scan of hbase:meta, skipping regions from any tables in the specified set of disabled tables.

Parameters:
catalogTracker -
disabledTables - set of disabled tables that will not be returned
Returns:
Returns a map of every region to it's currently assigned server, according to META. If the region does not have an assignment it will have a null value in the map.
Throws:
IOException

fullScan

public static Map<HRegionInfo,ServerName> fullScan(CatalogTracker catalogTracker,
                                                   Set<TableName> disabledTables,
                                                   boolean excludeOfflinedSplitParents)
                                            throws IOException
Performs a full scan of hbase:meta, skipping regions from any tables in the specified set of disabled tables.

Parameters:
catalogTracker -
disabledTables - set of disabled tables that will not be returned
excludeOfflinedSplitParents - If true, do not include offlined split parents in the return.
Returns:
Returns a map of every region to it's currently assigned server, according to META. If the region does not have an assignment it will have a null value in the map.
Throws:
IOException

fullScan

public static List<Result> fullScan(CatalogTracker catalogTracker)
                             throws IOException
Performs a full scan of hbase:meta.

Returns:
List of Result
Throws:
IOException

fullScanOfMeta

public static List<Result> fullScanOfMeta(CatalogTracker catalogTracker)
                                   throws IOException
Performs a full scan of a hbase:meta table.

Returns:
List of Result
Throws:
IOException

fullScan

public static void fullScan(CatalogTracker catalogTracker,
                            MetaReader.Visitor visitor)
                     throws IOException
Performs a full scan of hbase:meta.

Parameters:
catalogTracker -
visitor - Visitor invoked against each row.
Throws:
IOException

getRegion

public static Pair<HRegionInfo,ServerName> getRegion(CatalogTracker catalogTracker,
                                                     byte[] regionName)
                                              throws IOException
Gets the region info and assignment for the specified region.

Parameters:
catalogTracker -
regionName - Region to lookup.
Returns:
Location and HRegionInfo for regionName
Throws:
IOException

getRegionResult

public static Result getRegionResult(CatalogTracker catalogTracker,
                                     byte[] regionName)
                              throws IOException
Gets the result in hbase:meta for the specified region.

Parameters:
catalogTracker -
regionName -
Returns:
result of the specified region
Throws:
IOException

getRegionsFromMergeQualifier

public static Pair<HRegionInfo,HRegionInfo> getRegionsFromMergeQualifier(CatalogTracker catalogTracker,
                                                                         byte[] regionName)
                                                                  throws IOException
Get regions from the merge qualifier of the specified merged region

Returns:
null if it doesn't contain merge qualifier, else two merge regions
Throws:
IOException

tableExists

public static boolean tableExists(CatalogTracker catalogTracker,
                                  TableName tableName)
                           throws IOException
Checks if the specified table exists. Looks at the hbase:meta table hosted on the specified server.

Parameters:
catalogTracker -
tableName - table to check
Returns:
true if the table exists in meta, false if not
Throws:
IOException

getTableRegions

public static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker,
                                                TableName tableName)
                                         throws IOException
Gets all of the regions of the specified table.

Parameters:
catalogTracker -
tableName -
Returns:
Ordered list of HRegionInfo.
Throws:
IOException

getTableRegions

public static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker,
                                                TableName tableName,
                                                boolean excludeOfflinedSplitParents)
                                         throws IOException
Gets all of the regions of the specified table.

Parameters:
catalogTracker -
tableName -
excludeOfflinedSplitParents - If true, do not include offlined split parents in the return.
Returns:
Ordered list of HRegionInfo.
Throws:
IOException

getScanForTableName

public static Scan getScanForTableName(TableName tableName)
This method creates a Scan object that will only scan catalog rows that belong to the specified table. It doesn't specify any columns. This is a better alternative to just using a start row and scan until it hits a new table since that requires parsing the HRI to get the table name.

Parameters:
tableName - bytes of table's name
Returns:
configured Scan object

getTableRegionsAndLocations

public static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(CatalogTracker catalogTracker,
                                                                             TableName tableName)
                                                                      throws IOException,
                                                                             InterruptedException
Parameters:
catalogTracker -
tableName -
Returns:
Return list of regioninfos and server.
Throws:
IOException
InterruptedException

getTableRegionsAndLocations

public static List<Pair<HRegionInfo,ServerName>> getTableRegionsAndLocations(CatalogTracker catalogTracker,
                                                                             TableName tableName,
                                                                             boolean excludeOfflinedSplitParents)
                                                                      throws IOException,
                                                                             InterruptedException
Parameters:
catalogTracker -
tableName -
Returns:
Return list of regioninfos and server addresses.
Throws:
IOException
InterruptedException

getServerUserRegions

public static NavigableMap<HRegionInfo,Result> getServerUserRegions(CatalogTracker catalogTracker,
                                                                    ServerName serverName)
                                                             throws IOException
Parameters:
catalogTracker -
serverName -
Returns:
List of user regions installed on this server (does not include catalog regions).
Throws:
IOException

fullScanMetaAndPrint

public static void fullScanMetaAndPrint(CatalogTracker catalogTracker)
                                 throws IOException
Throws:
IOException

fullScan

public static void fullScan(CatalogTracker catalogTracker,
                            MetaReader.Visitor visitor,
                            byte[] startrow)
                     throws IOException
Performs a full scan of a catalog table.

Parameters:
catalogTracker -
visitor - 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)
Throws:
IOException

getRegionCount

public static int getRegionCount(org.apache.hadoop.conf.Configuration c,
                                 String tableName)
                          throws IOException
Count regions in hbase:meta for passed table.

Parameters:
c -
tableName -
Returns:
Count or regions in table tableName
Throws:
IOException


Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.