org.apache.hadoop.hbase.util.migration.v5
Class HRegionInfo

java.lang.Object
  extended by org.apache.hadoop.hbase.util.migration.v5.HRegionInfo
All Implemented Interfaces:
Comparable, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable

public class HRegionInfo
extends Object
implements org.apache.hadoop.io.WritableComparable

HRegion information. Contains HRegion id, start and end keys, a reference to this HRegions' table descriptor, etc.

This class has been modified so it instantiates using pre-v5 versions of the HTableDescriptor, etc: i.e. it will uses classes that in this migration v0_2 package.


Field Summary
static int DELIMITER
          delimiter used between portions of a region name
static HRegionInfo FIRST_META_REGIONINFO
          HRegionInfo for first meta region
static int NO_HASH
           
static HRegionInfo ROOT_REGIONINFO
          HRegionInfo for root region
protected  HTableDescriptor tableDesc
           
 
Constructor Summary
HRegionInfo()
          Default constructor - creates empty object
HRegionInfo(HRegionInfo other)
          Costruct a copy of another HRegionInfo
HRegionInfo(HTableDescriptor tableDesc, byte[] startKey, byte[] endKey)
          Construct HRegionInfo with explicit parameters
HRegionInfo(HTableDescriptor tableDesc, byte[] startKey, byte[] endKey, boolean split)
          Construct HRegionInfo with explicit parameters
HRegionInfo(HTableDescriptor tableDesc, byte[] startKey, byte[] endKey, boolean split, long regionid)
          Construct HRegionInfo with explicit parameters
 
Method Summary
 int compareTo(Object o)
          
static byte[] createRegionName(byte[] tableName, byte[] startKey, byte[] id)
          Make a region name of passed parameters.
static byte[] createRegionName(byte[] tableName, byte[] startKey, String id)
          Make a region name of passed parameters.
static int encodeRegionName(byte[] regionName)
           
 boolean equals(Object o)
          
 int getEncodedName()
           
 byte[] getEndKey()
           
 long getRegionId()
           
 byte[] getRegionName()
           
 String getRegionNameAsString()
           
 byte[] getStartKey()
           
 HTableDescriptor getTableDesc()
           
static byte[] getTableNameFromRegionName(byte[] regionName)
          Extracts table name prefix from a metaregion row name.
 int hashCode()
          
 boolean isMetaRegion()
           
 boolean isMetaTable()
           
 boolean isOffline()
           
 boolean isRootRegion()
           
 boolean isSplit()
           
static List<byte[]> parseMetaRegionRow(byte[] regionName)
          Parses passed metaregion row into its constituent parts.
 void readFields(DataInput in)
          
 void setOffline(boolean offLine)
           
 void setSplit(boolean split)
           
 String toString()
          
 void write(DataOutput out)
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DELIMITER

public static final int DELIMITER
delimiter used between portions of a region name

See Also:
Constant Field Values

ROOT_REGIONINFO

public static final HRegionInfo ROOT_REGIONINFO
HRegionInfo for root region


FIRST_META_REGIONINFO

public static final HRegionInfo FIRST_META_REGIONINFO
HRegionInfo for first meta region


tableDesc

protected HTableDescriptor tableDesc

NO_HASH

public static final int NO_HASH
See Also:
Constant Field Values
Constructor Detail

HRegionInfo

public HRegionInfo()
Default constructor - creates empty object


HRegionInfo

public HRegionInfo(HTableDescriptor tableDesc,
                   byte[] startKey,
                   byte[] endKey)
            throws IllegalArgumentException
Construct HRegionInfo with explicit parameters

Parameters:
tableDesc - the table descriptor
startKey - first key in region
endKey - end of key range
Throws:
IllegalArgumentException

HRegionInfo

public HRegionInfo(HTableDescriptor tableDesc,
                   byte[] startKey,
                   byte[] endKey,
                   boolean split)
            throws IllegalArgumentException
Construct HRegionInfo with explicit parameters

Parameters:
tableDesc - the table descriptor
startKey - first key in region
endKey - end of key range
split - true if this region has split and we have daughter regions regions that may or may not hold references to this region.
Throws:
IllegalArgumentException

HRegionInfo

public HRegionInfo(HTableDescriptor tableDesc,
                   byte[] startKey,
                   byte[] endKey,
                   boolean split,
                   long regionid)
            throws IllegalArgumentException
Construct HRegionInfo with explicit parameters

Parameters:
tableDesc - the table descriptor
startKey - first key in region
endKey - end of key range
split - true if this region has split and we have daughter regions regions that may or may not hold references to this region.
regionid - Region id to use.
Throws:
IllegalArgumentException

HRegionInfo

public HRegionInfo(HRegionInfo other)
Costruct a copy of another HRegionInfo

Parameters:
other -
Method Detail

encodeRegionName

public static int encodeRegionName(byte[] regionName)
Parameters:
regionName -
Returns:
the encodedName

getTableNameFromRegionName

public static byte[] getTableNameFromRegionName(byte[] regionName)
Extracts table name prefix from a metaregion row name.

Parameters:
regionName - A metaregion row name.
Returns:
The table prefix of a region name.

parseMetaRegionRow

public static List<byte[]> parseMetaRegionRow(byte[] regionName)
Parses passed metaregion row into its constituent parts. Presumes region names are ASCII characters only.

Parameters:
regionName - A metaregion row name.
Returns:
A list where first element is the tablename, second the row portion, and the third the id.

createRegionName

public static byte[] createRegionName(byte[] tableName,
                                      byte[] startKey,
                                      String id)
Make a region name of passed parameters.

Parameters:
tableName -
startKey - Can be null
id - Region id.
Returns:
Region name made of passed tableName, startKey and id

createRegionName

public static byte[] createRegionName(byte[] tableName,
                                      byte[] startKey,
                                      byte[] id)
Make a region name of passed parameters.

Parameters:
tableName -
startKey - Can be null
id - Region id
Returns:
Region name made of passed tableName, startKey and id

getEndKey

public byte[] getEndKey()
Returns:
the endKey

getRegionId

public long getRegionId()
Returns:
the regionId

getRegionName

public byte[] getRegionName()
Returns:
the regionName as an array of bytes.
See Also:
getRegionNameAsString()

getRegionNameAsString

public String getRegionNameAsString()
Returns:
Region name as a String for use in logging, etc.

getEncodedName

public int getEncodedName()
Returns:
the encoded region name

getStartKey

public byte[] getStartKey()
Returns:
the startKey

getTableDesc

public HTableDescriptor getTableDesc()
Returns:
the tableDesc

isRootRegion

public boolean isRootRegion()
Returns:
true if this is the root region

isMetaTable

public boolean isMetaTable()
Returns:
true if this is the meta table

isMetaRegion

public boolean isMetaRegion()
Returns:
true if this region is a meta region

isSplit

public boolean isSplit()
Returns:
True if has been split and has daughters.

setSplit

public void setSplit(boolean split)
Parameters:
split - set split status

isOffline

public boolean isOffline()
Returns:
True if this region is offline.

setOffline

public void setOffline(boolean offLine)
Parameters:
offLine - set online - offline status

toString

public String toString()

Overrides:
toString in class Object

equals

public boolean equals(Object o)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

write

public void write(DataOutput out)
           throws IOException

Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException

Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

compareTo

public int compareTo(Object o)

Specified by:
compareTo in interface Comparable


Copyright © 2008 The Apache Software Foundation