org.apache.hadoop.hbase.catalog
Class MetaReader

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

public class MetaReader
extends java.lang.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 java.util.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 java.util.Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker, java.util.Set<java.lang.String> disabledTables)
          Performs a full scan of .META., skipping regions from any tables in the specified set of disabled tables.
static java.util.Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker, java.util.Set<java.lang.String> disabledTables, boolean excludeOfflinedSplitParents)
          Performs a full scan of .META., skipping regions from any tables in the specified set of disabled tables.
static java.util.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 java.util.NavigableMap<HRegionInfo,Result> getServerUserRegions(CatalogTracker catalogTracker, HServerInfo hsi)
           
static java.util.List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker, byte[] tableName)
          Gets all of the regions of the specified table.
static java.util.List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker, byte[] tableName, boolean excludeOfflinedSplitParents)
          Gets all of the regions of the specified table.
static java.util.List<Pair<HRegionInfo,HServerAddress>> getTableRegionsAndLocations(CatalogTracker catalogTracker, java.lang.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, java.lang.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 java.util.Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker)
                                                          throws java.io.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:
java.io.IOException

fullScan

public static java.util.Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker,
                                                                 java.util.Set<java.lang.String> disabledTables)
                                                          throws java.io.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:
java.io.IOException

fullScan

public static java.util.Map<HRegionInfo,HServerAddress> fullScan(CatalogTracker catalogTracker,
                                                                 java.util.Set<java.lang.String> disabledTables,
                                                                 boolean excludeOfflinedSplitParents)
                                                          throws java.io.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:
java.io.IOException

fullScanOfResults

public static java.util.List<Result> fullScanOfResults(CatalogTracker catalogTracker)
                                                throws java.io.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:
java.io.IOException

fullScan

public static void fullScan(CatalogTracker catalogTracker,
                            MetaReader.Visitor visitor)
                     throws java.io.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:
java.io.IOException

fullScan

public static void fullScan(CatalogTracker catalogTracker,
                            MetaReader.Visitor visitor,
                            byte[] startrow)
                     throws java.io.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:
java.io.IOException

readMetaLocation

public static HServerAddress readMetaLocation(HRegionInterface metaServer)
                                       throws java.io.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:
java.io.IOException

readRegionLocation

public static HServerAddress readRegionLocation(CatalogTracker catalogTracker,
                                                byte[] regionName)
                                         throws java.io.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:
java.io.IOException

getRegion

public static Pair<HRegionInfo,HServerAddress> getRegion(CatalogTracker catalogTracker,
                                                         byte[] regionName)
                                                  throws java.io.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:
java.io.IOException

metaRowToRegionPair

public static Pair<HRegionInfo,HServerAddress> metaRowToRegionPair(Result data)
                                                            throws java.io.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:
java.io.IOException

metaRowToRegionPairWithInfo

public static Pair<HRegionInfo,HServerInfo> metaRowToRegionPairWithInfo(Result data)
                                                                 throws java.io.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:
java.io.IOException

tableExists

public static boolean tableExists(CatalogTracker catalogTracker,
                                  java.lang.String tableName)
                           throws java.io.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:
java.io.IOException

getTableRegions

public static java.util.List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker,
                                                          byte[] tableName)
                                                   throws java.io.IOException
Gets all of the regions of the specified table.

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

getTableRegions

public static java.util.List<HRegionInfo> getTableRegions(CatalogTracker catalogTracker,
                                                          byte[] tableName,
                                                          boolean excludeOfflinedSplitParents)
                                                   throws java.io.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:
java.io.IOException

getTableRegionsAndLocations

public static java.util.List<Pair<HRegionInfo,HServerAddress>> getTableRegionsAndLocations(CatalogTracker catalogTracker,
                                                                                           java.lang.String tableName)
                                                                                    throws java.io.IOException,
                                                                                           java.lang.InterruptedException
Parameters:
catalogTracker -
tableName -
Returns:
Return list of regioninfos and server addresses.
Throws:
java.io.IOException
java.lang.InterruptedException

getServerUserRegions

public static java.util.NavigableMap<HRegionInfo,Result> getServerUserRegions(CatalogTracker catalogTracker,
                                                                              HServerInfo hsi)
                                                                       throws java.io.IOException
Parameters:
catalogTracker -
hsi - Server specification
Returns:
List of user regions installed on this server (does not include catalog regions).
Throws:
java.io.IOException


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