org.apache.hadoop.hbase.catalog
Class MetaReader

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

public class MetaReader
extends Object

Reads region and assignment information from .META..

Uses the CatalogTracker to obtain locations and connections to catalogs.


Nested Class Summary
static interface MetaReader.Visitor
          Implementations 'visit' a catalog table row.
 
Field Summary
static byte[] META_REGION_PREFIX
           
 
Constructor Summary
MetaReader()
           
 
Method Summary
static Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker)
          Performs a full scan of .META..
static void fullScan(CatalogTracker catalogTracker, MetaReader.Visitor visitor)
          Performs a full scan of .META..
static void fullScan(CatalogTracker catalogTracker, MetaReader.Visitor visitor, byte[] startrow)
          Performs a full scan of .META..
static Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker, Set<String> disabledTables)
          Performs a full scan of .META., skipping regions from any tables in the specified set of disabled tables.
static Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker, Set<String> disabledTables, boolean excludeOfflinedSplitParents)
          Performs a full scan of .META., skipping regions from any tables in the specified set of disabled tables.
static List<Result> fullScanOfResults(CatalogTracker catalogTracker)
          Performs a full scan of .META..
static Pair<HRegionInfo,HServerAddress> getRegion(CatalogTracker catalogTracker, byte[] regionName)
          Gets the region info and assignment for the specified region from META.
static Scan getScanForTableName(byte[] 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, HServerInfo hsi)
           
static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker, byte[] tableName)
          Gets all of the regions of the specified table.
static List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker, byte[] tableName, boolean excludeOfflinedSplitParents)
          Gets all of the regions of the specified table.
static List<Pair<HRegionInfo,HServerAddress>> getTableRegionsAndLocations(CatalogTracker catalogTracker, String tableName)
           
static Pair<HRegionInfo,HServerAddress> metaRowToRegionPair(Result data)
           
static Pair<HRegionInfo,HServerInfo> metaRowToRegionPairWithInfo(Result data)
           
static HServerAddress readMetaLocation(HRegionInterface metaServer)
          Reads the location of META from ROOT.
static HServerAddress readRegionLocation(CatalogTracker catalogTracker, byte[] regionName)
          Reads the location of the specified region from META.
static boolean tableExists(CatalogTracker catalogTracker, String 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
 

Field Detail

META_REGION_PREFIX

public static final byte[] META_REGION_PREFIX
Constructor Detail

MetaReader

public MetaReader()
Method Detail

fullScan

public static Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker)
                                                throws IOException
Performs a full scan of .META..

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.

Returns:
map of regions to their currently assigned server
Throws:
IOException

fullScan

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

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.

Parameters:
catalogTracker -
disabledTables - set of disabled tables that will not be returned
Returns:
map of regions to their currently assigned server
Throws:
IOException

fullScan

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

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.

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:
map of regions to their currently assigned server
Throws:
IOException

fullScanOfResults

public static List<Result> fullScanOfResults(CatalogTracker catalogTracker)
                                      throws IOException
Performs a full scan of .META..

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.

Returns HServerInfo which includes server startcode.

Returns:
map of regions to their currently assigned server
Throws:
IOException

fullScan

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

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.

Parameters:
catalogTracker -
visitor -
Throws:
IOException

fullScan

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

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.

Parameters:
catalogTracker -
visitor -
startrow - Where to start the scan. Pass null if want to begin scan at first row.
Throws:
IOException

readMetaLocation

public static HServerAddress readMetaLocation(HRegionInterface metaServer)
                                       throws IOException
Reads the location of META from ROOT.

Parameters:
metaServer - connection to server hosting ROOT
Returns:
location of META in ROOT, null if not available
Throws:
IOException

readRegionLocation

public static HServerAddress readRegionLocation(CatalogTracker catalogTracker,
                                                byte[] regionName)
                                         throws IOException
Reads the location of the specified region from META.

Parameters:
catalogTracker -
regionName - region to read location of
Returns:
location of region in META, null if not available
Throws:
IOException

getRegion

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

Parameters:
catalogTracker -
regionName -
Returns:
region info and assignment from META, null if not available
Throws:
IOException

metaRowToRegionPair

public static Pair<HRegionInfo,HServerAddress> metaRowToRegionPair(Result data)
                                                            throws IOException
Parameters:
data - A .META. table row.
Returns:
A pair of the regioninfo and the server address from data or null for server address if no address set in .META. or null for a result if no HRegionInfo found.
Throws:
IOException

metaRowToRegionPairWithInfo

public static Pair<HRegionInfo,HServerInfo> metaRowToRegionPairWithInfo(Result data)
                                                                 throws IOException
Parameters:
data - A .META. table row.
Returns:
A pair of the regioninfo and the server info from data (or null for server address if no address set in .META.).
Throws:
IOException

tableExists

public static boolean tableExists(CatalogTracker catalogTracker,
                                  String tableName)
                           throws IOException
Checks if the specified table exists. Looks at the 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,
                                                byte[] 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,
                                                byte[] 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(byte[] 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,HServerAddress>> getTableRegionsAndLocations(CatalogTracker catalogTracker,
                                                                                 String tableName)
                                                                          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,
                                                                    HServerInfo hsi)
                                                             throws IOException
Parameters:
catalogTracker -
hsi - Server specification
Returns:
List of user regions installed on this server (does not include catalog regions).
Throws:
IOException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.