org.apache.hadoop.hbase.regionserver
Class HRegion

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.HRegion
All Implemented Interfaces:
HConstants, HeapSize
Direct Known Subclasses:
TransactionalRegion

public class HRegion
extends Object
implements HConstants, HeapSize

HRegion stores data for a certain region of a table. It stores all columns for each row. A given table consists of one or more HRegions.

We maintain multiple HStores for a single HRegion.

An Store is a set of rows with some column data; together, they make up all the data for the rows.

Each HRegion has a 'startKey' and 'endKey'.

The first is inclusive, the second is exclusive (except for the final region) The endKey of region 0 is the same as startKey for region 1 (if it exists). The startKey for the first region is null. The endKey for the final region is null.

Locking at the HRegion level serves only one purpose: preventing the region from being closed (and consequently split) while other operations are ongoing. Each row level operation obtains both a row lock and a region read lock for the duration of the operation. While a scanner is being constructed, getScanner holds a read lock. If the scanner is successfully constructed, it holds a read lock until it is closed. A close takes out a write lock and consequently will block for ongoing operations and will block new operations from starting while the close is in progress.

An HRegion is defined by its table and its key extent.

It consists of at least one Store. The number of Stores should be configurable, so that data which is accessed together is stored in the same Store. Right now, we approximate that by building a single Store for each column family. (This config info will be communicated via the tabledesc.)

The HTableDescriptor contains metainfo about the HRegion's table. regionName is a unique identifier for this HRegion. (startKey, endKey] defines the keyspace for this HRegion.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.HConstants
HConstants.Modify
 
Field Summary
static long DEEP_OVERHEAD
           
static long FIXED_OVERHEAD
           
static String REGIONINFO_FILE
          Name of the region info file that resides just under the region directory.
static byte[] REGIONINFO_FILE_BYTES
          REGIONINFO_FILE as byte array.
protected  ReadWriteConsistencyControl rwcc
           
protected  Map<byte[],Store> stores
           
 
Fields inherited from interface org.apache.hadoop.hbase.HConstants
ALL_VERSIONS, CATALOG_FAMILY, CATALOG_FAMILY_STR, CATALOG_HISTORIAN_FAMILY, CLUSTER_DISTRIBUTED, CLUSTER_IS_DISTRIBUTED, CLUSTER_IS_LOCAL, DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE, DEFAULT_HOST, DEFAULT_MASTER_INFOPORT, DEFAULT_MASTER_PORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_REGION_SERVER_CLASS, DEFAULT_REGIONSERVER_INFOPORT, DEFAULT_REGIONSERVER_PORT, DEFAULT_SIZE_RESERVATION_BLOCK, DEFAULT_ZOOKEEPER_PAUSE, DEFAULT_ZOOKEEPER_RETRIES, EMPTY_BYTE_ARRAY, EMPTY_END_ROW, EMPTY_START_ROW, FILE_SYSTEM_VERSION, FOREVER, HBASE_CLIENT_RETRIES_NUMBER_KEY, HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, HBASE_DIR, HREGION_COMPACTIONDIR_NAME, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, IN_MEMORY, LAST_ROW, LATEST_TIMESTAMP, LATEST_TIMESTAMP_BYTES, MAJOR_COMPACTION_PERIOD, MASTER_PORT, MAX_ROW_LENGTH, MAXIMUM_VALUE_LENGTH, META_ROW_DELIMITER, META_TABLE_NAME, NAME, NINES, REGION_IMPL, REGION_SERVER_CLASS, REGION_SERVER_IMPL, REGIONINFO_QUALIFIER, REGIONSERVER_PORT, RETRY_BACKOFF, ROOT_TABLE_NAME, SERVER_QUALIFIER, SPLITA_QUALIFIER, SPLITB_QUALIFIER, STARTCODE_QUALIFIER, THREAD_WAKE_FREQUENCY, UTF8_ENCODING, VERSION_FILE_NAME, VERSIONS, WEEK_IN_SECONDS, ZERO_L, ZEROES, ZOOKEEPER_CONFIG_NAME, ZOOKEEPER_PAUSE, ZOOKEEPER_QUORUM, ZOOKEEPER_RETRIES
 
Constructor Summary
HRegion()
          Should only be used for testing purposes
HRegion(org.apache.hadoop.fs.Path basedir, HLog log, org.apache.hadoop.fs.FileSystem fs, HBaseConfiguration conf, HRegionInfo regionInfo, FlushRequester flushListener)
          HRegion constructor.
 
Method Summary
static void addRegionToMETA(HRegion meta, HRegion r)
          Inserts a new region's meta information into the passed meta region.
 boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] expectedValue, Put put, Integer lockId, boolean writeToWAL)
           
protected  void checkReadOnly()
           
static void cleanRegionInMETA(HRegionInterface srvr, byte[] metaRegionName, HRegionInfo info)
          Clean COL_SERVER and COL_STARTCODE for passed info in .META.
 List<StoreFile> close()
          Close down this HRegion.
 List<StoreFile> close(boolean abort)
          Close down this HRegion.
 byte[] compactStores()
          Called by compaction thread and after region is opened to compact the HStores if necessary.
static HRegion createHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, HBaseConfiguration conf)
          Convenience method creating new HRegions.
 void delete(Delete delete, Integer lockid, boolean writeToWAL)
           
 void delete(Map<byte[],List<KeyValue>> familyMap, boolean writeToWAL)
           
static void deleteRegion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, HRegionInfo info)
          Deletes all the files for a HRegion
protected  void doReconstructionLog(org.apache.hadoop.fs.Path oldLogFile, long minSeqId, long maxSeqId, org.apache.hadoop.util.Progressable reporter)
           
 boolean equals(Object o)
           
 boolean flushcache()
          Flush the cache.
 Result get(Get get, Integer ignoredLockId)
           
 org.apache.hadoop.fs.Path getBaseDir()
           
 Result getClosestRowBefore(byte[] row, byte[] family)
          Return all the data for the row that matches row exactly, or the one that immediately preceeds it, at or immediately before ts.
protected  long getCompleteCacheFlushSequenceId(long currentSequenceId)
          Get the sequence number to be associated with this cache flush.
 HBaseConfiguration getConf()
           
 byte[] getEndKey()
           
 org.apache.hadoop.fs.FileSystem getFilesystem()
           
 long getLargestHStoreSize()
           
 long getLastFlushTime()
           
 HLog getLog()
           
 org.apache.hadoop.fs.Path getRegionDir()
           
static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path rootdir, HRegionInfo info)
          Computes the Path of the HRegion
static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path tabledir, int name)
          Computes the Path of the HRegion
 long getRegionId()
           
 HRegionInfo getRegionInfo()
           
 byte[] getRegionName()
           
 String getRegionNameAsString()
           
 InternalScanner getScanner(Scan scan)
          Return an iterator that scans over the HRegion, returning the indicated columns and rows specified by the Scan.
protected  InternalScanner getScanner(Scan scan, List<KeyValueScanner> additionalScanners)
           
 byte[] getStartKey()
           
 Store getStore(byte[] column)
          Return HStore instance.
 HTableDescriptor getTableDesc()
           
 int hashCode()
           
 boolean hasTooManyStoreFiles()
          Checks every store to see if one has too many store files
 long heapSize()
           
 long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, boolean writeToWAL)
           
 void initialize(org.apache.hadoop.fs.Path initialFiles, org.apache.hadoop.util.Progressable reporter)
          Initialize this region and get it ready to roll.
protected  Store instantiateHStore(org.apache.hadoop.fs.Path baseDir, HColumnDescriptor c, org.apache.hadoop.fs.Path oldLogFile, org.apache.hadoop.util.Progressable reporter)
           
protected  InternalScanner instantiateInternalScanner(Scan scan, List<KeyValueScanner> additionalScanners)
           
protected  boolean internalFlushcache()
          Flushing the cache is a little tricky.
protected  Callable<Void> internalPreFlushcacheCommit()
          A hook for sub classed wishing to perform operations prior to the cache flush commit stage.
 boolean isClosed()
           
 boolean isClosing()
           
static void main(String[] args)
          Facility for dumping and compacting catalog tables.
static void makeColumnFamilyDirs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tabledir, HRegionInfo hri, byte[] colFamily)
          Make the directories for a specific column family
static HRegion merge(HRegion a, HRegion b)
          Merge two regions whether they are adjacent or not.
static HRegion mergeAdjacent(HRegion srcA, HRegion srcB)
          Merge two HRegions.
static HRegion newHRegion(org.apache.hadoop.fs.Path basedir, HLog log, org.apache.hadoop.fs.FileSystem fs, HBaseConfiguration conf, HRegionInfo regionInfo, FlushRequester flushListener)
          A utility method to create new instances of HRegion based on the HConstants.REGION_IMPL configuration property.
 Integer obtainRowLock(byte[] row)
          Obtain a lock on the given row.
static void offlineRegionInMETA(HRegionInterface srvr, byte[] metaRegionName, HRegionInfo info)
          Utility method used by HMaster marking regions offlined.
static HRegion openHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, HLog log, HBaseConfiguration conf)
          Convenience method to open a HRegion outside of an HRegionServer context.
protected  void prepareToSplit()
           
 void put(Put put)
           
 void put(Put put, boolean writeToWAL)
           
 void put(Put put, Integer lockid)
           
 void put(Put put, Integer lockid, boolean writeToWAL)
           
static void removeRegionFromMETA(HRegionInterface srvr, byte[] metaRegionName, byte[] regionName)
          Delete a region's meta information from the passed meta region.
static boolean rowIsInRange(HRegionInfo info, byte[] row)
          Determines if the specified row is within the row range specified by the specified HRegionInfo
 boolean shouldSplit(boolean b)
          For internal use in forcing splits ahead of file size limit.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

stores

protected final Map<byte[],Store> stores

rwcc

protected final ReadWriteConsistencyControl rwcc

REGIONINFO_FILE

public static final String REGIONINFO_FILE
Name of the region info file that resides just under the region directory.

See Also:
Constant Field Values

REGIONINFO_FILE_BYTES

public static final byte[] REGIONINFO_FILE_BYTES
REGIONINFO_FILE as byte array.


FIXED_OVERHEAD

public static final long FIXED_OVERHEAD

DEEP_OVERHEAD

public static final long DEEP_OVERHEAD
Constructor Detail

HRegion

public HRegion()
Should only be used for testing purposes


HRegion

public HRegion(org.apache.hadoop.fs.Path basedir,
               HLog log,
               org.apache.hadoop.fs.FileSystem fs,
               HBaseConfiguration conf,
               HRegionInfo regionInfo,
               FlushRequester flushListener)
HRegion constructor. This constructor should only be used for testing and extensions. Instances of HRegion should be instantiated with the newHRegion( org.apache.hadoop.fs.Path, HLog, org.apache.hadoop.fs.FileSystem, org.apache.hadoop.hbase.HBaseConfiguration, org.apache.hadoop.hbase.HRegionInfo, FlushRequester) method.

Parameters:
basedir - qualified path of directory where region should be located, usually the table directory.
log - The HLog is the outbound log for any updates to the HRegion (There's a single HLog for all the HRegions on a single HRegionServer.) The log file is a logfile from the previous execution that's custom-computed for this HRegion. The HRegionServer computes and sorts the appropriate log info for this HRegion. If there is a previous log file (implying that the HRegion has been written-to before), then read it from the supplied path.
fs - is the filesystem.
conf - is global configuration settings.
regionInfo - - HRegionInfo that describes the region is new), then read them from the supplied path.
flushListener - an object that implements CacheFlushListener or null making progress to master -- otherwise master might think region deploy failed. Can be null.
See Also:
newHRegion(org.apache.hadoop.fs.Path, HLog, org.apache.hadoop.fs.FileSystem, org.apache.hadoop.hbase.HBaseConfiguration, org.apache.hadoop.hbase.HRegionInfo, FlushRequester)
Method Detail

initialize

public void initialize(org.apache.hadoop.fs.Path initialFiles,
                       org.apache.hadoop.util.Progressable reporter)
                throws IOException
Initialize this region and get it ready to roll. Called after construction.

Parameters:
initialFiles - path
reporter - progressable
Throws:
IOException - e

getRegionInfo

public HRegionInfo getRegionInfo()
Returns:
a HRegionInfo object for this region

isClosed

public boolean isClosed()
Returns:
true if region is closed

isClosing

public boolean isClosing()
Returns:
True if closing process has started.

close

public List<StoreFile> close()
                      throws IOException
Close down this HRegion. Flush the cache, shut down each HStore, don't service any more calls.

This method could take some time to execute, so don't call it from a time-sensitive thread.

Returns:
Vector of all the storage files that the HRegion's component HStores make use of. It's a list of all HStoreFile objects. Returns empty vector if already closed and null if judged that it should not close.
Throws:
IOException - e

close

public List<StoreFile> close(boolean abort)
                      throws IOException
Close down this HRegion. Flush the cache unless abort parameter is true, Shut down each HStore, don't service any more calls. This method could take some time to execute, so don't call it from a time-sensitive thread.

Parameters:
abort - true if server is aborting (only during testing)
Returns:
Vector of all the storage files that the HRegion's component HStores make use of. It's a list of HStoreFile objects. Can be null if we are not to close at this time or we are already closed.
Throws:
IOException - e

getStartKey

public byte[] getStartKey()
Returns:
start key for region

getEndKey

public byte[] getEndKey()
Returns:
end key for region

getRegionId

public long getRegionId()
Returns:
region id

getRegionName

public byte[] getRegionName()
Returns:
region name

getRegionNameAsString

public String getRegionNameAsString()
Returns:
region name as string for logging

getTableDesc

public HTableDescriptor getTableDesc()
Returns:
HTableDescriptor for this region

getLog

public HLog getLog()
Returns:
HLog in use for this region

getConf

public HBaseConfiguration getConf()
Returns:
Configuration object

getRegionDir

public org.apache.hadoop.fs.Path getRegionDir()
Returns:
region directory Path

getFilesystem

public org.apache.hadoop.fs.FileSystem getFilesystem()
Returns:
FileSystem being used by this region

getLastFlushTime

public long getLastFlushTime()
Returns:
the last time the region was flushed

getLargestHStoreSize

public long getLargestHStoreSize()
Returns:
returns size of largest HStore.

prepareToSplit

protected void prepareToSplit()

compactStores

public byte[] compactStores()
                     throws IOException
Called by compaction thread and after region is opened to compact the HStores if necessary.

This operation could block for a long time, so don't call it from a time-sensitive thread. Note that no locking is necessary at this level because compaction only conflicts with a region split, and that cannot happen because the region server does them sequentially and not in parallel.

Returns:
mid key if split is needed
Throws:
IOException - e

flushcache

public boolean flushcache()
                   throws IOException
Flush the cache. When this method is called the cache will be flushed unless:
  1. the cache is empty
  2. the region is closed.
  3. a flush is already in progress
  4. writes are disabled

This method may block for some time, so it should not be called from a time-sensitive thread.

Returns:
true if cache was flushed
Throws:
IOException - general io exceptions
DroppedSnapshotException - Thrown when replay of hlog is required because a Snapshot was not properly persisted.

internalFlushcache

protected boolean internalFlushcache()
                              throws IOException
Flushing the cache is a little tricky. We have a lot of updates in the memstore, all of which have also been written to the log. We need to write those updates in the memstore out to disk, while being able to process reads/writes as much as possible during the flush operation. Also, the log has to state clearly the point in time at which the memstore was flushed. (That way, during recovery, we know when we can rely on the on-disk flushed structures and when we have to recover the memstore from the log.)

So, we have a three-step process:

This method is protected, but can be accessed via several public routes.

This method may block for some time.

Returns:
true if the region needs compacting
Throws:
IOException - general io exceptions
DroppedSnapshotException - Thrown when replay of hlog is required because a Snapshot was not properly persisted.

internalPreFlushcacheCommit

protected Callable<Void> internalPreFlushcacheCommit()
                                              throws IOException
A hook for sub classed wishing to perform operations prior to the cache flush commit stage. If a subclass wishes that an atomic update of their work and the flush commit stage happens, they should return a callable. The new scanner lock will be acquired and released.

Throws:
IOException - allow children to throw exception

getCompleteCacheFlushSequenceId

protected long getCompleteCacheFlushSequenceId(long currentSequenceId)
Get the sequence number to be associated with this cache flush. Used by TransactionalRegion to not complete pending transactions.

Parameters:
currentSequenceId -
Returns:
sequence id to complete the cache flush with

getClosestRowBefore

public Result getClosestRowBefore(byte[] row,
                                  byte[] family)
                           throws IOException
Return all the data for the row that matches row exactly, or the one that immediately preceeds it, at or immediately before ts.

Parameters:
row - row key
family - column family to find on
Returns:
map of values
Throws:
IOException - read exceptions

getScanner

public InternalScanner getScanner(Scan scan)
                           throws IOException
Return an iterator that scans over the HRegion, returning the indicated columns and rows specified by the Scan.

This Iterator must be closed by the caller.

Parameters:
scan - configured Scan
Returns:
InternalScanner
Throws:
IOException - read exceptions

getScanner

protected InternalScanner getScanner(Scan scan,
                                     List<KeyValueScanner> additionalScanners)
                              throws IOException
Throws:
IOException

instantiateInternalScanner

protected InternalScanner instantiateInternalScanner(Scan scan,
                                                     List<KeyValueScanner> additionalScanners)
                                              throws IOException
Throws:
IOException

delete

public void delete(Delete delete,
                   Integer lockid,
                   boolean writeToWAL)
            throws IOException
Parameters:
delete - delete object
lockid - existing lock id, or null for grab a lock
writeToWAL - append to the write ahead lock or not
Throws:
IOException - read exceptions

delete

public void delete(Map<byte[],List<KeyValue>> familyMap,
                   boolean writeToWAL)
            throws IOException
Parameters:
familyMap -
writeToWAL -
Throws:
IOException

put

public void put(Put put)
         throws IOException
Parameters:
put -
Throws:
IOException

put

public void put(Put put,
                boolean writeToWAL)
         throws IOException
Parameters:
put -
writeToWAL -
Throws:
IOException

put

public void put(Put put,
                Integer lockid)
         throws IOException
Parameters:
put -
lockid -
Throws:
IOException

put

public void put(Put put,
                Integer lockid,
                boolean writeToWAL)
         throws IOException
Parameters:
put -
lockid -
writeToWAL -
Throws:
IOException

checkAndPut

public boolean checkAndPut(byte[] row,
                           byte[] family,
                           byte[] qualifier,
                           byte[] expectedValue,
                           Put put,
                           Integer lockId,
                           boolean writeToWAL)
                    throws IOException
Parameters:
row -
family -
qualifier -
expectedValue -
put -
lockId -
writeToWAL -
Returns:
true if the new put was execute, false otherwise
Throws:
IOException

checkReadOnly

protected void checkReadOnly()
                      throws IOException
Throws:
IOException - Throws exception if region is in read-only mode.

doReconstructionLog

protected void doReconstructionLog(org.apache.hadoop.fs.Path oldLogFile,
                                   long minSeqId,
                                   long maxSeqId,
                                   org.apache.hadoop.util.Progressable reporter)
                            throws UnsupportedEncodingException,
                                   IOException
Throws:
UnsupportedEncodingException
IOException

instantiateHStore

protected Store instantiateHStore(org.apache.hadoop.fs.Path baseDir,
                                  HColumnDescriptor c,
                                  org.apache.hadoop.fs.Path oldLogFile,
                                  org.apache.hadoop.util.Progressable reporter)
                           throws IOException
Throws:
IOException

getStore

public Store getStore(byte[] column)
Return HStore instance. Use with caution. Exposed for use of fixup utilities.

Parameters:
column - Name of column family hosted by this region.
Returns:
Store that goes with the family on passed column. TODO: Make this lookup faster.

obtainRowLock

public Integer obtainRowLock(byte[] row)
                      throws IOException
Obtain a lock on the given row. Blocks until success. I know it's strange to have two mappings:
   ROWS  ==> LOCKS
 
as well as
   LOCKS ==> ROWS
 
But it acts as a guard on the client; a miswritten client just can't submit the name of a row and start writing to it; it must know the correct lockid, which matches the lock list in memory.

It would be more memory-efficient to assume a correctly-written client, which maybe we'll do in the future.

Parameters:
row - Name of row to lock.
Returns:
The id of the held lock.
Throws:
IOException

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getBaseDir

public org.apache.hadoop.fs.Path getBaseDir()
Returns:
Path of region base directory

newHRegion

public static HRegion newHRegion(org.apache.hadoop.fs.Path basedir,
                                 HLog log,
                                 org.apache.hadoop.fs.FileSystem fs,
                                 HBaseConfiguration conf,
                                 HRegionInfo regionInfo,
                                 FlushRequester flushListener)
A utility method to create new instances of HRegion based on the HConstants.REGION_IMPL configuration property.

Parameters:
basedir - qualified path of directory where region should be located, usually the table directory.
log - The HLog is the outbound log for any updates to the HRegion (There's a single HLog for all the HRegions on a single HRegionServer.) The log file is a logfile from the previous execution that's custom-computed for this HRegion. The HRegionServer computes and sorts the appropriate log info for this HRegion. If there is a previous log file (implying that the HRegion has been written-to before), then read it from the supplied path.
fs - is the filesystem.
conf - is global configuration settings.
regionInfo - - HRegionInfo that describes the region is new), then read them from the supplied path.
flushListener - an object that implements CacheFlushListener or null making progress to master -- otherwise master might think region deploy failed. Can be null.
Returns:
the new instance

createHRegion

public static HRegion createHRegion(HRegionInfo info,
                                    org.apache.hadoop.fs.Path rootDir,
                                    HBaseConfiguration conf)
                             throws IOException
Convenience method creating new HRegions. Used by createTable and by the bootstrap code in the HMaster constructor. Note, this method creates an HLog for the created region. It needs to be closed explicitly. Use getLog() to get access.

Parameters:
info - Info for region to create.
rootDir - Root directory for HBase instance
conf -
Returns:
new HRegion
Throws:
IOException

openHRegion

public static HRegion openHRegion(HRegionInfo info,
                                  org.apache.hadoop.fs.Path rootDir,
                                  HLog log,
                                  HBaseConfiguration conf)
                           throws IOException
Convenience method to open a HRegion outside of an HRegionServer context.

Parameters:
info - Info for region to be opened.
rootDir - Root directory for HBase instance
log - HLog for region to use. This method will call HLog#setSequenceNumber(long) passing the result of the call to HRegion#getMinSequenceId() to ensure the log id is properly kept up. HRegionStore does this every time it opens a new region.
conf -
Returns:
new HRegion
Throws:
IOException

addRegionToMETA

public static void addRegionToMETA(HRegion meta,
                                   HRegion r)
                            throws IOException
Inserts a new region's meta information into the passed meta region. Used by the HMaster bootstrap code adding new table to ROOT table.

Parameters:
meta - META HRegion to be updated
r - HRegion to add to meta
Throws:
IOException

removeRegionFromMETA

public static void removeRegionFromMETA(HRegionInterface srvr,
                                        byte[] metaRegionName,
                                        byte[] regionName)
                                 throws IOException
Delete a region's meta information from the passed meta region. Removes content in the 'info' column family. Does not remove region historian info.

Parameters:
srvr - META server to be updated
metaRegionName - Meta region name
regionName - HRegion to remove from meta
Throws:
IOException

offlineRegionInMETA

public static void offlineRegionInMETA(HRegionInterface srvr,
                                       byte[] metaRegionName,
                                       HRegionInfo info)
                                throws IOException
Utility method used by HMaster marking regions offlined.

Parameters:
srvr - META server to be updated
metaRegionName - Meta region name
info - HRegion to update in meta
Throws:
IOException

cleanRegionInMETA

public static void cleanRegionInMETA(HRegionInterface srvr,
                                     byte[] metaRegionName,
                                     HRegionInfo info)
                              throws IOException
Clean COL_SERVER and COL_STARTCODE for passed info in .META.

Parameters:
srvr -
metaRegionName -
info -
Throws:
IOException

deleteRegion

public static void deleteRegion(org.apache.hadoop.fs.FileSystem fs,
                                org.apache.hadoop.fs.Path rootdir,
                                HRegionInfo info)
                         throws IOException
Deletes all the files for a HRegion

Parameters:
fs - the file system object
rootdir - qualified path of HBase root directory
info - HRegionInfo for region to be deleted
Throws:
IOException

getRegionDir

public static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path tabledir,
                                                     int name)
Computes the Path of the HRegion

Parameters:
tabledir - qualified path for table
name - ENCODED region name
Returns:
Path of HRegion directory

getRegionDir

public static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path rootdir,
                                                     HRegionInfo info)
Computes the Path of the HRegion

Parameters:
rootdir - qualified path of HBase root directory
info - HRegionInfo for the region
Returns:
qualified path of region directory

rowIsInRange

public static boolean rowIsInRange(HRegionInfo info,
                                   byte[] row)
Determines if the specified row is within the row range specified by the specified HRegionInfo

Parameters:
info - HRegionInfo that specifies the row range
row - row to be checked
Returns:
true if the row is within the range specified by the HRegionInfo

makeColumnFamilyDirs

public static void makeColumnFamilyDirs(org.apache.hadoop.fs.FileSystem fs,
                                        org.apache.hadoop.fs.Path tabledir,
                                        HRegionInfo hri,
                                        byte[] colFamily)
                                 throws IOException
Make the directories for a specific column family

Parameters:
fs - the file system
tabledir - base directory where region will live (usually the table dir)
hri -
colFamily - the column family
Throws:
IOException

mergeAdjacent

public static HRegion mergeAdjacent(HRegion srcA,
                                    HRegion srcB)
                             throws IOException
Merge two HRegions. The regions must be adjacent and must not overlap.

Parameters:
srcA -
srcB -
Returns:
new merged HRegion
Throws:
IOException

merge

public static HRegion merge(HRegion a,
                            HRegion b)
                     throws IOException
Merge two regions whether they are adjacent or not.

Parameters:
a - region a
b - region b
Returns:
new merged region
Throws:
IOException

get

public Result get(Get get,
                  Integer ignoredLockId)
           throws IOException
Parameters:
get - get object
ignoredLockId - lock id that is ignored
Returns:
result
Throws:
IOException - read exceptions

incrementColumnValue

public long incrementColumnValue(byte[] row,
                                 byte[] family,
                                 byte[] qualifier,
                                 long amount,
                                 boolean writeToWAL)
                          throws IOException
Parameters:
row -
family -
qualifier -
amount -
writeToWAL -
Returns:
The new value.
Throws:
IOException

heapSize

public long heapSize()
Specified by:
heapSize in interface HeapSize
Returns:
Approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.

shouldSplit

public boolean shouldSplit(boolean b)
For internal use in forcing splits ahead of file size limit.

Parameters:
b -
Returns:
previous value

hasTooManyStoreFiles

public boolean hasTooManyStoreFiles()
Checks every store to see if one has too many store files

Returns:
true if any store has too many store files

main

public static void main(String[] args)
                 throws IOException
Facility for dumping and compacting catalog tables. Only does catalog tables since these are only tables we for sure know schema on. For usage run:
   ./bin/hbase org.apache.hadoop.hbase.regionserver.HRegion
 

Parameters:
args -
Throws:
IOException


Copyright © 2010 The Apache Software Foundation