|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.util.migration.v5.HRegion
public class HRegion
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 HStore 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 HStore. The number of HStores should be configurable, so that data which is accessed together is stored in the same HStore. Right now, we approximate that by building a single HStore 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.
Field Summary |
---|
Constructor Summary | |
---|---|
HRegion(org.apache.hadoop.fs.Path basedir,
HLog log,
org.apache.hadoop.fs.FileSystem fs,
HBaseConfiguration conf,
HRegionInfo regionInfo,
org.apache.hadoop.fs.Path initialFiles,
FlushRequester flushListener)
HRegion constructor. |
|
HRegion(org.apache.hadoop.fs.Path basedir,
HLog log,
org.apache.hadoop.fs.FileSystem fs,
HBaseConfiguration conf,
HRegionInfo regionInfo,
org.apache.hadoop.fs.Path initialFiles,
FlushRequester flushListener,
org.apache.hadoop.util.Progressable reporter)
HRegion constructor. |
Method Summary | |
---|---|
static void |
addRegionToMETA(HRegion meta,
HRegion r)
Inserts a new region's meta information into the passed meta region. |
void |
batchUpdate(BatchUpdate b)
|
List<HStoreFile> |
close()
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 |
deleteAll(byte[] row,
byte[] column,
long ts)
Delete all cells of the same age as the passed timestamp or older. |
void |
deleteAll(byte[] row,
long ts)
Delete all cells of the same age as the passed timestamp or older. |
void |
deleteFamily(byte[] row,
byte[] family,
long timestamp)
Delete all cells for a row with matching column family with timestamps less than or equal to timestamp. |
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 maxSeqId,
org.apache.hadoop.util.Progressable reporter)
|
boolean |
equals(Object o)
|
boolean |
flushcache()
Flush the cache. |
Cell |
get(byte[] row,
byte[] column)
Fetch a single data item. |
Cell[] |
get(byte[] row,
byte[] column,
int numVersions)
Fetch multiple versions of a single data item |
Cell[] |
get(byte[] row,
byte[] column,
long timestamp,
int numVersions)
Fetch multiple versions of a single data item, with timestamp. |
org.apache.hadoop.fs.Path |
getBaseDir()
|
RowResult |
getClosestRowBefore(byte[] row)
Return all the data for the row that matches row exactly, or the one that immediately preceeds it, at or immediately before ts. |
HBaseConfiguration |
getConf()
|
byte[] |
getEndKey()
|
org.apache.hadoop.fs.FileSystem |
getFilesystem()
|
Map<byte[],Cell> |
getFull(byte[] row,
Set<byte[]> columns,
long ts)
Fetch all the columns for the indicated row at a specified timestamp. |
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()
|
InternalScanner |
getScanner(byte[][] cols,
byte[] firstRow,
long timestamp,
RowFilterInterface filter)
Return an iterator that scans over the HRegion, returning the indicated columns for only the rows that match the data filter. |
byte[] |
getStartKey()
|
protected HStore |
getStore(byte[] column)
|
HTableDescriptor |
getTableDesc()
|
int |
hashCode()
|
protected HStore |
instantiateHStore(org.apache.hadoop.fs.Path baseDir,
HColumnDescriptor c,
org.apache.hadoop.fs.Path oldLogFile,
org.apache.hadoop.util.Progressable reporter)
|
boolean |
isClosed()
|
static void |
makeColumnFamilyDirs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path basedir,
int encodedRegionName,
byte[] colFamily,
HTableDescriptor tabledesc)
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 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. |
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 |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HRegion(org.apache.hadoop.fs.Path basedir, HLog log, org.apache.hadoop.fs.FileSystem fs, HBaseConfiguration conf, HRegionInfo regionInfo, org.apache.hadoop.fs.Path initialFiles, FlushRequester flushListener) throws IOException
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 regioninitialFiles
- If there are initial files (implying that the HRegion
is new), then read them from the supplied path.flushListener
- an object that implements CacheFlushListener or null
or null
IOException
public HRegion(org.apache.hadoop.fs.Path basedir, HLog log, org.apache.hadoop.fs.FileSystem fs, HBaseConfiguration conf, HRegionInfo regionInfo, org.apache.hadoop.fs.Path initialFiles, FlushRequester flushListener, org.apache.hadoop.util.Progressable reporter) throws IOException
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.basedir
- qualified path of directory where region should be located,
usually the table directory.fs
- is the filesystem.conf
- is global configuration settings.regionInfo
- - HRegionInfo that describes the regioninitialFiles
- If there are initial files (implying that the HRegion
is new), then read them from the supplied path.flushListener
- an object that implements CacheFlushListener or nullreporter
- Call on a period so hosting server can report we're
making progress to master -- otherwise master might think region deploy
failed. Can be null.
IOException
Method Detail |
---|
public static HRegion mergeAdjacent(HRegion srcA, HRegion srcB) throws IOException
srcA
- srcB
-
IOException
public static HRegion merge(HRegion a, HRegion b) throws IOException
a
- region ab
- region b
IOException
public HRegionInfo getRegionInfo()
public boolean isClosed()
public List<HStoreFile> close() throws IOException
This method could take some time to execute, so don't call it from a time-sensitive thread.
IOException
public byte[] getStartKey()
public byte[] getEndKey()
public long getRegionId()
public byte[] getRegionName()
public HTableDescriptor getTableDesc()
public HLog getLog()
public HBaseConfiguration getConf()
public org.apache.hadoop.fs.Path getRegionDir()
public org.apache.hadoop.fs.FileSystem getFilesystem()
public long getLastFlushTime()
public long getLargestHStoreSize()
public byte[] compactStores() throws IOException
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.
IOException
public boolean flushcache() throws IOException
This method may block for some time, so it should not be called from a time-sensitive thread.
IOException
DroppedSnapshotException
- Thrown when replay of hlog is required
because a Snapshot was not properly persisted.public Cell get(byte[] row, byte[] column) throws IOException
row
- column
-
IOException
public Cell[] get(byte[] row, byte[] column, int numVersions) throws IOException
row
- column
- numVersions
-
IOException
public Cell[] get(byte[] row, byte[] column, long timestamp, int numVersions) throws IOException
row
- column
- timestamp
- numVersions
-
IOException
public Map<byte[],Cell> getFull(byte[] row, Set<byte[]> columns, long ts) throws IOException
row
- columns
- Array of columns you'd like to retrieve. When null, get all.ts
-
IOException
public RowResult getClosestRowBefore(byte[] row) throws IOException
row
- row key
IOException
public InternalScanner getScanner(byte[][] cols, byte[] firstRow, long timestamp, RowFilterInterface filter) throws IOException
cols
- columns to scan. If column name is a column family, all
columns of the specified column family are returned. Its also possible
to pass a regex in the column qualifier. A column qualifier is judged to
be a regex if it contains at least one of the following characters:
\+|^&*$[]]}{)(
.firstRow
- row which is the starting point of the scantimestamp
- only return rows whose timestamp is <= this valuefilter
- row filter
IOException
public void batchUpdate(BatchUpdate b) throws IOException
b
-
IOException
public void deleteAll(byte[] row, byte[] column, long ts) throws IOException
row
- column
- ts
- Delete all entries that have this timestamp or older
IOException
public void deleteAll(byte[] row, long ts) throws IOException
row
- ts
- Delete all entries that have this timestamp or older
IOException
public void deleteFamily(byte[] row, byte[] family, long timestamp) throws IOException
row
- The row to operate onfamily
- The column family to matchtimestamp
- Timestamp to match
IOException
protected void doReconstructionLog(org.apache.hadoop.fs.Path oldLogFile, long maxSeqId, org.apache.hadoop.util.Progressable reporter) throws UnsupportedEncodingException, IOException
UnsupportedEncodingException
IOException
protected HStore instantiateHStore(org.apache.hadoop.fs.Path baseDir, HColumnDescriptor c, org.apache.hadoop.fs.Path oldLogFile, org.apache.hadoop.util.Progressable reporter) throws IOException
IOException
protected HStore getStore(byte[] column)
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public org.apache.hadoop.fs.Path getBaseDir()
public static HRegion createHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, HBaseConfiguration conf) throws IOException
HLog
for the created region. It
needs to be closed explicitly. Use getLog()
to get
access.
info
- Info for region to create.rootDir
- Root directory for HBase instanceconf
-
IOException
public static HRegion openHRegion(HRegionInfo info, org.apache.hadoop.fs.Path rootDir, HLog log, HBaseConfiguration conf) throws IOException
info
- Info for region to be opened.rootDir
- Root directory for HBase instancelog
- 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
-
IOException
public static void addRegionToMETA(HRegion meta, HRegion r) throws IOException
meta
region. Used by the HMaster bootstrap code adding
new table to ROOT table.
meta
- META HRegion to be updatedr
- HRegion to add to meta
IOException
public static void removeRegionFromMETA(HRegionInterface srvr, byte[] metaRegionName, byte[] regionName) throws IOException
meta
region.
srvr
- META server to be updatedmetaRegionName
- Meta region nameregionName
- HRegion to remove from meta
IOException
public static void offlineRegionInMETA(HRegionInterface srvr, byte[] metaRegionName, HRegionInfo info) throws IOException
srvr
- META server to be updatedmetaRegionName
- Meta region nameinfo
- HRegion to update in meta
IOException
public static void deleteRegion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, HRegionInfo info) throws IOException
fs
- the file system objectrootdir
- qualified path of HBase root directoryinfo
- HRegionInfo for region to be deleted
IOException
public static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path tabledir, int name)
tabledir
- qualified path for tablename
- ENCODED region name
public static org.apache.hadoop.fs.Path getRegionDir(org.apache.hadoop.fs.Path rootdir, HRegionInfo info)
rootdir
- qualified path of HBase root directoryinfo
- HRegionInfo for the region
public static boolean rowIsInRange(HRegionInfo info, byte[] row)
info
- HRegionInfo that specifies the row rangerow
- row to be checked
public static void makeColumnFamilyDirs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path basedir, int encodedRegionName, byte[] colFamily, HTableDescriptor tabledesc) throws IOException
fs
- the file systembasedir
- base directory where region will live (usually the table dir)encodedRegionName
- encoded region namecolFamily
- the column familytabledesc
- table descriptor of table
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |