|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hbase.regionserver.HRegionServer
public class HRegionServer
HRegionServer makes a set of HRegions available to clients. It checks in with the HMaster. There are many HRegionServers in a single HBase deployment.
| Field Summary | |
|---|---|
protected boolean |
abortRequested
|
protected org.apache.hadoop.conf.Configuration |
conf
|
protected boolean |
fsOk
|
protected java.util.concurrent.atomic.AtomicBoolean |
haveRootRegion
|
protected HLog |
hlog
|
protected boolean |
isOnline
|
protected java.util.concurrent.locks.ReentrantReadWriteLock |
lock
|
static org.apache.commons.logging.Log |
LOG
|
protected int |
numRegionsToReport
|
protected java.util.Map<java.lang.String,HRegion> |
onlineRegions
Map of regions currently being served by this region server. |
static java.lang.String |
REGIONSERVER
region server process name |
protected HServerInfo |
serverInfo
|
protected boolean |
stopped
|
protected int |
threadWakeFrequency
|
| Fields inherited from interface org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion |
|---|
versionID |
| Constructor Summary | |
|---|---|
HRegionServer(org.apache.hadoop.conf.Configuration conf)
Starts a HRegionServer at the default location |
|
| Method Summary | |
|---|---|
void |
abort(java.lang.String reason)
|
void |
abort(java.lang.String reason,
java.lang.Throwable cause)
Cause the server to exit without closing the regions it is serving, the log it is using and without notifying the master. |
protected long |
addRowLock(java.lang.Integer r,
HRegion region)
|
protected long |
addScanner(InternalScanner s)
|
void |
addToOnlineRegions(HRegion region)
Add to online regions. |
void |
bulkLoadHFile(java.lang.String hfilePath,
byte[] regionName,
byte[] familyName)
Bulk load an HFile into an open region |
boolean |
checkAndDelete(byte[] regionName,
byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Delete delete)
Atomically checks if a row/family/qualifier value match the expectedValue. |
boolean |
checkAndPut(byte[] regionName,
byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Put put)
Atomically checks if a row/family/qualifier value match the expectedValue. |
protected boolean |
checkFileSystem()
Checks to see if the file system is still accessible. |
boolean |
checkOOME(java.lang.Throwable e)
Take actions on the event of an OutOfMemoryError. |
protected void |
checkOpen()
Called to verify that this server is up and running. |
void |
close(long scannerId)
Close a scanner |
protected void |
closeAllRegions(boolean abort)
Closes all regions. |
boolean |
closeRegion(HRegionInfo region)
Closes the specified region. |
boolean |
closeRegion(HRegionInfo region,
boolean zk)
Closes the specified region and will use or not use ZK during the close according to the specified flag. |
protected boolean |
closeRegion(HRegionInfo region,
boolean abort,
boolean zk)
|
void |
compactRegion(HRegionInfo regionInfo,
boolean major)
Compacts the specified region. |
static HRegionServer |
constructRegionServer(java.lang.Class<? extends HRegionServer> regionServerClass,
org.apache.hadoop.conf.Configuration conf2)
Utility for constructing an instance of the passed HRegionServer class. |
HServerLoad.RegionLoad |
createRegionLoad(java.lang.String encodedRegionName)
|
void |
delete(byte[] regionName,
Delete delete)
Deletes all the KeyValues that match those found in the Delete object, if their ts <= to the Delete. |
int |
delete(byte[] regionName,
java.util.List<Delete> deletes)
Put an array of deletes into the specified region |
protected void |
doMetrics()
|
boolean |
exists(byte[] regionName,
Get get)
Perform exists operation. |
void |
flushRegion(HRegionInfo regionInfo)
Flushes the MemStore of the specified region. |
Result |
get(byte[] regionName,
Get get)
Perform Get operation. |
CatalogTracker |
getCatalogTracker()
|
Result |
getClosestRowBefore(byte[] regionName,
byte[] row,
byte[] family)
Return all the data for the row that matches row exactly, or the one that immediately preceeds it. |
CompactionRequestor |
getCompactionRequester()
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
Gets the configuration object for this server. |
java.util.SortedMap<java.lang.Long,HRegion> |
getCopyOfOnlineRegionsSortedBySize()
|
protected org.apache.hadoop.fs.FileSystem |
getFileSystem()
|
FlushRequester |
getFlushRequester()
|
HRegion |
getFromOnlineRegions(java.lang.String encodedRegionName)
Return HRegion instance. |
long |
getGlobalMemStoreSize()
Return the total size of all memstores in every region. |
HServerInfo |
getHServerInfo()
Method used when a master is taking the place of another failed one. |
InfoServer |
getInfoServer()
|
protected Leases |
getLeases()
|
protected org.apache.hadoop.hbase.regionserver.LogRoller |
getLogRoller()
|
RegionServerMetrics |
getMetrics()
|
protected HRegionInfo[] |
getMostLoadedRegions()
Get the top N most loaded regions this server is serving so we can tell the master which regions it can reallocate if we're overloaded. |
int |
getNumberOfOnlineRegions()
|
HRegion |
getOnlineRegion(byte[] regionName)
|
java.util.List<HRegionInfo> |
getOnlineRegions()
|
java.util.Collection<HRegion> |
getOnlineRegionsLocalContext()
For tests and web ui. |
protected java.util.concurrent.LinkedBlockingQueue<HMsg> |
getOutboundMsgs()
|
long |
getProtocolVersion(java.lang.String protocol,
long clientVersion)
|
protected HRegion |
getRegion(byte[] regionName)
Protected utility method for safely obtaining an HRegion handle. |
HRegionInfo |
getRegionInfo(byte[] regionName)
Get metainfo about an HRegion |
HRegionInfo[] |
getRegionsAssignment()
|
protected java.util.Set<HRegion> |
getRegionsToCheck()
|
java.util.concurrent.atomic.AtomicInteger |
getRequestCount()
|
protected org.apache.hadoop.fs.Path |
getRootDir()
|
HBaseRpcMetrics |
getRpcMetrics()
Return a reference to the metrics instance used for counting RPC calls. |
HServerInfo |
getServerInfo()
Return data structure that has Server address and startcode. |
java.lang.String |
getServerName()
Gets the unique server name for this server. |
int |
getThreadWakeFrequency()
Interval at which threads should run |
HLog |
getWAL()
|
protected java.util.List<WALObserver> |
getWALActionListeners()
Called by instantiateHLog(Path, Path) setting up WAL instance. |
ZooKeeperWatcher |
getZooKeeper()
Gets the ZooKeeper instance for this server. |
protected void |
handleReportForDutyResponse(org.apache.hadoop.io.MapWritable c)
|
Result |
increment(byte[] regionName,
Increment increment)
Increments one or more columns values in a row. |
long |
incrementColumnValue(byte[] regionName,
byte[] row,
byte[] family,
byte[] qualifier,
long amount,
boolean writeToWAL)
Atomically increments a column value. |
protected HLog |
instantiateHLog(org.apache.hadoop.fs.Path logdir,
org.apache.hadoop.fs.Path oldLogDir)
Called by setupWALAndReplication() creating WAL instance. |
boolean |
isOnline()
Report the status of the server. |
boolean |
isStopped()
|
boolean |
isStopping()
|
protected void |
join()
Wait on all threads to finish. |
protected void |
kill()
|
long |
lockRow(byte[] regionName,
byte[] row)
Opens a remote row lock. |
static void |
main(java.lang.String[] args)
|
protected void |
metrics()
|
MultiResponse |
multi(MultiAction multi)
Method used for doing multiple actions(Deletes, Gets and Puts) in one call |
MultiPutResponse |
multiPut(MultiPut puts)
Deprecated. Use HRegionServer.multi( MultiAction action) instead |
Result |
next(long scannerId)
Get the next set of values |
Result[] |
next(long scannerId,
int nbRows)
Get the next set of values |
void |
openRegion(HRegionInfo region)
Opens the specified region. |
void |
openRegions(java.util.List<HRegionInfo> regions)
Opens the specified regions. |
long |
openScanner(byte[] regionName,
Scan scan)
Opens a remote scanner with a RowFilter. |
void |
postOpenDeployTasks(HRegion r,
CatalogTracker ct,
boolean daughter)
Tasks to perform after region open to complete deploy of region on regionserver |
int |
put(byte[] regionName,
java.util.List<Put> puts)
Put an array of puts into the specified region |
void |
put(byte[] regionName,
Put put)
Put data into the specified region |
boolean |
removeFromOnlineRegions(java.lang.String encodedName)
This method removes HRegion corresponding to hri from the Map of onlineRegions. |
void |
replicateLogEntries(HLog.Entry[] entries)
Replicates the given entries. |
void |
run()
The HRegionServer sticks in this loop until closed. |
void |
splitRegion(HRegionInfo regionInfo)
Splits the specified region. |
static java.lang.Thread |
startRegionServer(HRegionServer hrs)
|
static java.lang.Thread |
startRegionServer(HRegionServer hrs,
java.lang.String name)
|
void |
stop(java.lang.String msg)
Stop this service. |
java.lang.String |
toString()
|
void |
unlockRow(byte[] regionName,
long lockId)
Releases a remote row lock. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final org.apache.commons.logging.Log LOG
protected volatile boolean stopped
protected volatile boolean abortRequested
protected volatile boolean fsOk
protected HServerInfo serverInfo
protected final org.apache.hadoop.conf.Configuration conf
protected final java.util.concurrent.atomic.AtomicBoolean haveRootRegion
protected final java.util.Map<java.lang.String,HRegion> onlineRegions
protected final java.util.concurrent.locks.ReentrantReadWriteLock lock
protected final int threadWakeFrequency
protected final int numRegionsToReport
public static final java.lang.String REGIONSERVER
protected volatile HLog hlog
protected volatile boolean isOnline
| Constructor Detail |
|---|
public HRegionServer(org.apache.hadoop.conf.Configuration conf)
throws java.io.IOException,
java.lang.InterruptedException
conf -
java.io.IOException
java.lang.InterruptedException| Method Detail |
|---|
public void run()
run in interface java.lang.Runnable
protected void handleReportForDutyResponse(org.apache.hadoop.io.MapWritable c)
throws java.io.IOException
java.io.IOExceptionpublic HServerLoad.RegionLoad createRegionLoad(java.lang.String encodedRegionName)
encodedRegionName -
java.io.IOExceptionpublic boolean checkOOME(java.lang.Throwable e)
HBaseRPCErrorHandler
checkOOME in interface HBaseRPCErrorHandlere - the throwable
protected boolean checkFileSystem()
public boolean isOnline()
protected HLog instantiateHLog(org.apache.hadoop.fs.Path logdir,
org.apache.hadoop.fs.Path oldLogDir)
throws java.io.IOException
setupWALAndReplication() creating WAL instance.
logdir - oldLogDir -
java.io.IOExceptionprotected java.util.List<WALObserver> getWALActionListeners()
instantiateHLog(Path, Path) setting up WAL instance.
Add any WALObservers you want inserted before WAL startup.
HLog on construction.protected org.apache.hadoop.hbase.regionserver.LogRoller getLogRoller()
protected void doMetrics()
protected void metrics()
public RegionServerMetrics getMetrics()
public HLog getWAL()
getWAL in interface RegionServerServicespublic CatalogTracker getCatalogTracker()
getCatalogTracker in interface ServerCatalogTrackerpublic void stop(java.lang.String msg)
Stoppable
stop in interface Stoppablemsg - Why we're stopping.
public void postOpenDeployTasks(HRegion r,
CatalogTracker ct,
boolean daughter)
throws org.apache.zookeeper.KeeperException,
java.io.IOException
RegionServerServices
postOpenDeployTasks in interface RegionServerServicesr - Region to open.ct - Instance of CatalogTrackerdaughter - True if this is daughter of a split
org.apache.zookeeper.KeeperException
java.io.IOExceptionpublic HBaseRpcMetrics getRpcMetrics()
getRpcMetrics in interface RegionServerServices
public void abort(java.lang.String reason,
java.lang.Throwable cause)
abort in interface Abortablereason - the reason we are abortingcause - the exception that caused the abort, or nullpublic void abort(java.lang.String reason)
abort(String, Throwable)protected void kill()
protected void join()
protected void closeAllRegions(boolean abort)
public HRegionInfo getRegionInfo(byte[] regionName)
throws NotServingRegionException
HRegionInterface
getRegionInfo in interface HRegionInterfaceregionName - name of the region
NotServingRegionException
public Result getClosestRowBefore(byte[] regionName,
byte[] row,
byte[] family)
throws java.io.IOException
HRegionInterface
getClosestRowBefore in interface HRegionInterfaceregionName - region namerow - row keyfamily - Column family to look for row in.
java.io.IOException - e
public Result get(byte[] regionName,
Get get)
throws java.io.IOException
get in interface HRegionInterfaceregionName - name of region to get fromget - Get operation
java.io.IOException - e
public boolean exists(byte[] regionName,
Get get)
throws java.io.IOException
HRegionInterface
exists in interface HRegionInterfaceregionName - name of region to get fromget - Get operation describing cell to test
java.io.IOException - e
public void put(byte[] regionName,
Put put)
throws java.io.IOException
HRegionInterface
put in interface HRegionInterfaceregionName - region nameput - the data to be put
java.io.IOException - e
public int put(byte[] regionName,
java.util.List<Put> puts)
throws java.io.IOException
HRegionInterface
put in interface HRegionInterfaceregionName - region nameputs - List of puts to execute
java.io.IOException - e
public boolean checkAndPut(byte[] regionName,
byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Put put)
throws java.io.IOException
HRegionInterface
checkAndPut in interface HRegionInterfaceregionName - row - family - qualifier - value - the expected valueput -
java.io.IOException
public boolean checkAndDelete(byte[] regionName,
byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Delete delete)
throws java.io.IOException
HRegionInterface
checkAndDelete in interface HRegionInterfaceregionName - row - family - qualifier - value - the expected valuedelete -
java.io.IOException
public long openScanner(byte[] regionName,
Scan scan)
throws java.io.IOException
HRegionInterface
openScanner in interface HRegionInterfaceregionName - name of region to scanscan - configured scan object
java.io.IOException - e
protected long addScanner(InternalScanner s)
throws Leases.LeaseStillHeldException
Leases.LeaseStillHeldException
public Result next(long scannerId)
throws java.io.IOException
HRegionInterface
next in interface HRegionInterfacescannerId - clientId passed to openScanner
java.io.IOException - e
public Result[] next(long scannerId,
int nbRows)
throws java.io.IOException
HRegionInterface
next in interface HRegionInterfacescannerId - clientId passed to openScannernbRows - the number of rows to fetch
java.io.IOException - e
public void close(long scannerId)
throws java.io.IOException
HRegionInterface
close in interface HRegionInterfacescannerId - the scanner id returned by openScanner
java.io.IOException - e
public void delete(byte[] regionName,
Delete delete)
throws java.io.IOException
HRegionInterface
delete in interface HRegionInterfaceregionName - region namedelete - delete object
java.io.IOException - e
public int delete(byte[] regionName,
java.util.List<Delete> deletes)
throws java.io.IOException
HRegionInterface
delete in interface HRegionInterfaceregionName - region namedeletes - delete List to execute
java.io.IOException - e
public long lockRow(byte[] regionName,
byte[] row)
throws java.io.IOException
HRegionInterface
lockRow in interface HRegionInterfaceregionName - name of regionrow - row to lock
java.io.IOException - e
protected long addRowLock(java.lang.Integer r,
HRegion region)
throws Leases.LeaseStillHeldException
Leases.LeaseStillHeldException
public void unlockRow(byte[] regionName,
long lockId)
throws java.io.IOException
HRegionInterface
unlockRow in interface HRegionInterfaceregionName - region namelockId - the lock id returned by lockRow
java.io.IOException - e
public void bulkLoadHFile(java.lang.String hfilePath,
byte[] regionName,
byte[] familyName)
throws java.io.IOException
HRegionInterface
bulkLoadHFile in interface HRegionInterfacejava.io.IOException
public void openRegion(HRegionInfo region)
throws RegionServerStoppedException
HRegionInterface
openRegion in interface HRegionInterfaceregion - region to open
RegionServerStoppedException
public void openRegions(java.util.List<HRegionInfo> regions)
throws RegionServerStoppedException
HRegionInterface
openRegions in interface HRegionInterfaceregions - regions to open
RegionServerStoppedException
public boolean closeRegion(HRegionInfo region)
throws NotServingRegionException
HRegionInterface
closeRegion in interface HRegionInterfaceregion - region to close
NotServingRegionException
public boolean closeRegion(HRegionInfo region,
boolean zk)
throws NotServingRegionException
HRegionInterface
closeRegion in interface HRegionInterfaceregion - region to closezk - true if transitions should be done in ZK, false if not
NotServingRegionException
protected boolean closeRegion(HRegionInfo region,
boolean abort,
boolean zk)
region - Region to closeabort - True if we are abortingzk - True if we are to update zk about the region close; if the close
was orchestrated by master, then update zk. If the close is being run by
the regionserver because its going down, don't update zk.
public void flushRegion(HRegionInfo regionInfo)
throws NotServingRegionException,
java.io.IOException
HRegionInterfaceThis method is synchronous.
flushRegion in interface HRegionInterfaceregionInfo - region to flush
NotServingRegionException
java.io.IOException
public void splitRegion(HRegionInfo regionInfo)
throws NotServingRegionException,
java.io.IOException
HRegionInterfaceThis method currently flushes the region and then forces a compaction which will then trigger a split. The flush is done synchronously but the compaction is asynchronous.
splitRegion in interface HRegionInterfaceregionInfo - region to split
NotServingRegionException
java.io.IOException
public void compactRegion(HRegionInfo regionInfo,
boolean major)
throws NotServingRegionException,
java.io.IOException
HRegionInterfaceThis method is asynchronous.
compactRegion in interface HRegionInterfaceregionInfo - region to compactmajor - true to force major compaction
NotServingRegionException
java.io.IOExceptionpublic InfoServer getInfoServer()
public boolean isStopped()
isStopped in interface Stoppablepublic boolean isStopping()
isStopping in interface RegionServerServicespublic org.apache.hadoop.conf.Configuration getConfiguration()
Server
getConfiguration in interface Serverpublic java.util.List<HRegionInfo> getOnlineRegions()
getOnlineRegions in interface HRegionInterfacepublic int getNumberOfOnlineRegions()
public java.util.Collection<HRegion> getOnlineRegionsLocalContext()
getOnlineRegions()public void addToOnlineRegions(HRegion region)
public boolean removeFromOnlineRegions(java.lang.String encodedName)
public java.util.SortedMap<java.lang.Long,HRegion> getCopyOfOnlineRegionsSortedBySize()
public HRegion getFromOnlineRegions(java.lang.String encodedRegionName)
HRegion instance.
Only works if caller is in same context, in same JVM. HRegion is not
serializable.
encodedRegionName or
null if named region is not member of the online regions.public HRegion getOnlineRegion(byte[] regionName)
regionName -
regionName or null if
named region is not member of the online regions.public java.util.concurrent.atomic.AtomicInteger getRequestCount()
public FlushRequester getFlushRequester()
getFlushRequester in interface RegionServerServices
protected HRegion getRegion(byte[] regionName)
throws NotServingRegionException
regionName - Name of online HRegion to return
HRegion for regionName
NotServingRegionExceptionprotected HRegionInfo[] getMostLoadedRegions()
protected void checkOpen()
throws java.io.IOException
java.io.IOExceptionprotected java.util.Set<HRegion> getRegionsToCheck()
public long getProtocolVersion(java.lang.String protocol,
long clientVersion)
throws java.io.IOException
getProtocolVersion in interface org.apache.hadoop.ipc.VersionedProtocoljava.io.IOExceptionprotected java.util.concurrent.LinkedBlockingQueue<HMsg> getOutboundMsgs()
public long getGlobalMemStoreSize()
protected Leases getLeases()
protected org.apache.hadoop.fs.Path getRootDir()
protected org.apache.hadoop.fs.FileSystem getFileSystem()
public HServerInfo getServerInfo()
RegionServerServices
getServerInfo in interface RegionServerServices
public Result increment(byte[] regionName,
Increment increment)
throws java.io.IOException
HRegionInterfaceThis operation does not appear atomic to readers. Increments are done under a row lock but readers do not take row locks.
increment in interface HRegionInterfaceregionName - region nameincrement - increment operation
java.io.IOException
public long incrementColumnValue(byte[] regionName,
byte[] row,
byte[] family,
byte[] qualifier,
long amount,
boolean writeToWAL)
throws java.io.IOException
incrementColumnValue in interface HRegionInterfaceregionName - region namerow - row to checkfamily - column familyqualifier - column qualifieramount - long amount to incrementwriteToWAL - whether to write the increment to the WAL
java.io.IOException - e
public HRegionInfo[] getRegionsAssignment()
throws java.io.IOException
java.io.IOException
public HServerInfo getHServerInfo()
throws java.io.IOException
getHServerInfo in interface HRegionInterfacejava.io.IOException - e
public MultiResponse multi(MultiAction multi)
throws java.io.IOException
HRegionInterface
multi in interface HRegionInterfacejava.io.IOException
public MultiPutResponse multiPut(MultiPut puts)
throws java.io.IOException
HRegionInterface
multiPut in interface HRegionInterfaceputs - the request
java.io.IOException - epublic java.lang.String toString()
toString in class java.lang.Objectpublic int getThreadWakeFrequency()
public ZooKeeperWatcher getZooKeeper()
Server
getZooKeeper in interface Serverpublic java.lang.String getServerName()
Server<hostname> ',' <port> ',' <startcode>.
If the master, it returns <hostname> ':' <port>'.
- Specified by:
getServerName in interface Server
- Returns:
- unique server name
public CompactionRequestor getCompactionRequester()
getCompactionRequester in interface RegionServerServicesCompactionRequestor or null.
public static java.lang.Thread startRegionServer(HRegionServer hrs)
throws java.io.IOException
hrs -
java.io.IOException
public static java.lang.Thread startRegionServer(HRegionServer hrs,
java.lang.String name)
throws java.io.IOException
hrs - name -
java.io.IOException
public static HRegionServer constructRegionServer(java.lang.Class<? extends HRegionServer> regionServerClass,
org.apache.hadoop.conf.Configuration conf2)
regionServerClass - conf2 -
public void replicateLogEntries(HLog.Entry[] entries)
throws java.io.IOException
HRegionInterface
replicateLogEntries in interface HRegionInterfaceentries - entries to replicate
java.io.IOException
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.ExceptionHRegionServerCommandLine
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||