org.apache.hadoop.hbase.regionserver
Class HRegionServer

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.HRegionServer
All Implemented Interfaces:
Runnable, AdminProtocol, ClientProtocol, HBaseRPCErrorHandler, IpcProtocol, AdminProtos.AdminService.BlockingInterface, ClientProtos.ClientService.BlockingInterface, LastSequenceId, RegionServerServices

@InterfaceAudience.Private
public class HRegionServer
extends Object
implements ClientProtocol, AdminProtocol, Runnable, RegionServerServices, HBaseRPCErrorHandler, LastSequenceId

HRegionServer makes a set of HRegions available to clients. It checks in with the HMaster. There are many HRegionServers in a single HBase deployment.


Nested Class Summary
protected static class HRegionServer.MovedRegionsCleaner
          Creates a Chore thread to clean the moved region cache.
protected static interface HRegionServer.QosPriority
           
 
Field Summary
protected  boolean abortRequested
           
protected  org.apache.hadoop.hbase.regionserver.MemStoreFlusher cacheFlusher
           
protected  CatalogTracker catalogTracker
           
protected static String CLOSE
           
 CompactSplitThread compactSplitThread
           
protected  org.apache.hadoop.conf.Configuration conf
           
protected  HFileSystem fs
           
protected  boolean fsOk
           
protected  HLog hlog
           
protected  HLog hlogForMeta
           
protected  boolean isOnline
           
protected  Leases leases
           
protected  ReentrantReadWriteLock lock
           
static org.apache.commons.logging.Log LOG
           
protected  long maxScannerResultSize
           
protected  Map<String,org.apache.hadoop.hbase.regionserver.HRegionServer.MovedRegionInfo> movedRegions
           
protected  int numRegionsToReport
           
protected  Map<String,HRegion> onlineRegions
          Map of regions currently being served by this region server.
protected static String OPEN
           
static String REGIONSERVER
          region server process name
static String REGIONSERVER_CONF
          region server configuration name
protected  ConcurrentMap<byte[],Boolean> regionsInTransitionInRS
           
protected  ReplicationSinkService replicationSinkHandler
           
protected  ReplicationSourceService replicationSourceHandler
           
protected  ExecutorService service
           
protected  boolean stopped
           
protected  TableDescriptors tableDescriptors
          Go here to get table descriptors.
protected  int threadWakeFrequency
           
protected  int webuiport
           
 
Constructor Summary
HRegionServer(org.apache.hadoop.conf.Configuration conf)
          Starts a HRegionServer at the default location
 
Method Summary
 void abort(String reason)
           
 void abort(String reason, 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 addScanner(RegionScanner s)
           
protected  void addToMovedRegions(String encodedName, ServerName destination, long closeSeqNum)
           
 void addToOnlineRegions(HRegion region)
          Add to online regions.
protected  Result append(HRegion region, ClientProtos.MutationProto m, CellScanner cellScanner)
          Execute an append mutation.
 ClientProtos.BulkLoadHFileResponse bulkLoadHFile(com.google.protobuf.RpcController controller, ClientProtos.BulkLoadHFileRequest request)
          Atomically bulk load several HFiles into an open region
 boolean checkFileSystem()
          Checks to see if the file system is still accessible.
 boolean checkOOME(Throwable e)
          Take actions on the event of an OutOfMemoryError.
protected  void checkOpen()
          Called to verify that this server is up and running.
protected  void cleanMovedRegions()
          Remove the expired entries from the moved regions list.
protected  Throwable cleanup(Throwable t)
           
protected  Throwable cleanup(Throwable t, String msg)
           
protected  void closeAllRegions(boolean abort)
          Closes all regions.
 AdminProtos.CloseRegionResponse closeRegion(com.google.protobuf.RpcController controller, AdminProtos.CloseRegionRequest request)
          Close a region on the region server.
protected  boolean closeRegion(String encodedName, boolean abort, boolean zk, int versionOfClosingNode, ServerName sn)
          Close asynchronously a region, can be called from the master or internally by the regionserver when stopping.
 AdminProtos.CompactRegionResponse compactRegion(com.google.protobuf.RpcController controller, AdminProtos.CompactRegionRequest request)
          Compact a region on the region server.
static HRegionServer constructRegionServer(Class<? extends HRegionServer> regionServerClass, org.apache.hadoop.conf.Configuration conf2)
          Utility for constructing an instance of the passed HRegionServer class.
protected  IOException convertThrowableToIOE(Throwable t)
           
protected  IOException convertThrowableToIOE(Throwable t, String msg)
           
 HBaseProtos.RegionLoad createRegionLoad(String encodedRegionName)
           
protected  void doBatchOp(ClientProtos.MultiResponse.Builder builder, HRegion region, List<ClientProtos.MutationProto> mutations, CellScanner cells)
          Execute a list of Put/Delete mutations.
 ClientProtos.CoprocessorServiceResponse execService(com.google.protobuf.RpcController controller, ClientProtos.CoprocessorServiceRequest request)
           
 AdminProtos.FlushRegionResponse flushRegion(com.google.protobuf.RpcController controller, AdminProtos.FlushRegionRequest request)
          Flush a region on the region server.
 ClientProtos.GetResponse get(com.google.protobuf.RpcController controller, ClientProtos.GetRequest request)
          Get data from a table.
 CatalogTracker getCatalogTracker()
           
 CompactionRequestor getCompactionRequester()
           
 CompactSplitThread getCompactSplitThread()
           
 org.apache.hadoop.conf.Configuration getConfiguration()
          Gets the configuration object for this server.
 RegionServerCoprocessorHost getCoprocessorHost()
           
 String[] getCoprocessors()
           
 SortedMap<Long,HRegion> getCopyOfOnlineRegionsSortedBySize()
           
 ExecutorService getExecutorService()
           
 org.apache.hadoop.fs.FileSystem getFileSystem()
           
 FlushRequester getFlushRequester()
           
 HRegion getFromOnlineRegions(String encodedRegionName)
          Return HRegion instance.
 InfoServer getInfoServer()
           
 long getLastSequenceId(byte[] region)
           
 Leases getLeases()
           
protected  org.apache.hadoop.hbase.regionserver.LogRoller getLogRoller()
           
 MasterAddressTracker getMasterAddressManager()
           
protected  List<WALActionsListener> getMetaWALActionListeners()
           
 MetricsRegionServer 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)
           
 AdminProtos.GetOnlineRegionResponse getOnlineRegion(com.google.protobuf.RpcController controller, AdminProtos.GetOnlineRegionRequest request)
           
 List<HRegion> getOnlineRegions(byte[] tableName)
          Gets the online regions of the specified table.
 Collection<HRegion> getOnlineRegionsLocalContext()
          For tests, web ui and metrics.
protected  HRegion getRegion(byte[] regionName)
          Protected utility method for safely obtaining an HRegion handle.
protected  HRegion getRegion(HBaseProtos.RegionSpecifier regionSpecifier)
          Find the HRegion based on a region specifier
protected  HRegion getRegionByEncodedName(String encodedRegionName)
           
 AdminProtos.GetRegionInfoResponse getRegionInfo(com.google.protobuf.RpcController controller, AdminProtos.GetRegionInfoRequest request)
           
 RegionServerAccounting getRegionServerAccounting()
           
 ConcurrentMap<byte[],Boolean> getRegionsInTransitionInRS()
          Get the regions that are currently being opened or closed in the RS
protected  org.apache.hadoop.fs.Path getRootDir()
           
 RpcServer getRpcServer()
          Returns a reference to the region server's RPC server
 AdminProtos.GetServerInfoResponse getServerInfo(com.google.protobuf.RpcController controller, AdminProtos.GetServerInfoRequest request)
          Get some information of the region server.
 ServerName getServerName()
           
 long getStartcode()
           
 AdminProtos.GetStoreFileResponse getStoreFile(com.google.protobuf.RpcController controller, AdminProtos.GetStoreFileRequest request)
           
 TableLockManager getTableLockManager()
           
 int getThreadWakeFrequency()
          Interval at which threads should run
 HLog getWAL()
           
 HLog getWAL(HRegionInfo regionInfo)
           
protected  List<WALActionsListener> getWALActionListeners()
          Called by instantiateHLog(Path, String) setting up WAL instance.
 ZooKeeperWatcher getZooKeeper()
          Gets the ZooKeeper instance for this server.
 ZooKeeperWatcher getZooKeeperWatcher()
           
protected  void handleReportForDutyResponse(RegionServerStatusProtos.RegionServerStartupResponse c)
           
protected  Result increment(HRegion region, ClientProtos.MutationProto mutation, CellScanner cells)
          Execute an increment mutation.
protected  HLog instantiateHLog(org.apache.hadoop.fs.Path rootdir, String logName)
          Called by setupWALAndReplication() creating WAL instance.
 boolean isAborted()
          Check if the server or client was aborted.
 boolean isOnline()
          Report the status of the server.
 boolean isStopped()
           
 boolean isStopping()
           
protected  void join()
          Wait on all threads to finish.
protected  void kill()
           
static void main(String[] args)
           
 AdminProtos.MergeRegionsResponse mergeRegions(com.google.protobuf.RpcController controller, AdminProtos.MergeRegionsRequest request)
          Merge regions on the region server.
 ClientProtos.MultiResponse multi(com.google.protobuf.RpcController rpcc, ClientProtos.MultiRequest request)
          Execute multiple actions on a table: get, mutate, and/or execCoprocessor
 ClientProtos.MultiGetResponse multiGet(com.google.protobuf.RpcController controller, ClientProtos.MultiGetRequest request)
          Get multi data from a table.
 ClientProtos.MutateResponse mutate(com.google.protobuf.RpcController rpcc, ClientProtos.MutateRequest request)
          Mutate data in a table.
protected  void mutateRows(HRegion region, List<ClientProtos.MutationProto> mutations, CellScanner cellScanner)
          Mutate a list of rows atomically.
protected  long nextLong()
          Generate a random positive long number
 AdminProtos.OpenRegionResponse openRegion(com.google.protobuf.RpcController controller, AdminProtos.OpenRegionRequest request)
          Open asynchronously a region or a set of regions on the region server.
 void postOpenDeployTasks(HRegion r, CatalogTracker ct)
          Tasks to perform after region open to complete deploy of region on regionserver
 boolean removeFromOnlineRegions(HRegion r, ServerName destination)
          This method removes HRegion corresponding to hri from the Map of onlineRegions.
 AdminProtos.ReplicateWALEntryResponse replicateWALEntry(com.google.protobuf.RpcController controller, AdminProtos.ReplicateWALEntryRequest request)
          Replicate WAL entries on the region server.
 AdminProtos.RollWALWriterResponse rollWALWriter(com.google.protobuf.RpcController controller, AdminProtos.RollWALWriterRequest request)
          Roll the WAL writer of the region server.
 void run()
          The HRegionServer sticks in this loop until closed.
 ClientProtos.ScanResponse scan(com.google.protobuf.RpcController controller, ClientProtos.ScanRequest request)
          Scan data in a table.
 AdminProtos.SplitRegionResponse splitRegion(com.google.protobuf.RpcController controller, AdminProtos.SplitRegionRequest request)
          Split a region on the region server.
static Thread startRegionServer(HRegionServer hrs)
           
static Thread startRegionServer(HRegionServer hrs, String name)
           
 void stop(String msg)
          Stop this service.
 AdminProtos.StopServerResponse stopServer(com.google.protobuf.RpcController controller, AdminProtos.StopServerRequest request)
          Stop the region server.
 String toString()
           
 void waitForServerOnline()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

OPEN

protected static final String OPEN
See Also:
Constant Field Values

CLOSE

protected static final String CLOSE
See Also:
Constant Field Values

regionsInTransitionInRS

protected final ConcurrentMap<byte[],Boolean> regionsInTransitionInRS

maxScannerResultSize

protected long maxScannerResultSize

cacheFlusher

protected org.apache.hadoop.hbase.regionserver.MemStoreFlusher cacheFlusher

catalogTracker

protected CatalogTracker catalogTracker

tableDescriptors

protected TableDescriptors tableDescriptors
Go here to get table descriptors.


replicationSourceHandler

protected ReplicationSourceService replicationSourceHandler

replicationSinkHandler

protected ReplicationSinkService replicationSinkHandler

compactSplitThread

public CompactSplitThread compactSplitThread

onlineRegions

protected final Map<String,HRegion> onlineRegions
Map of regions currently being served by this region server. Key is the encoded region name. All access should be synchronized.


leases

protected Leases leases

service

protected ExecutorService service

fsOk

protected volatile boolean fsOk

fs

protected HFileSystem fs

stopped

protected volatile boolean stopped

abortRequested

protected volatile boolean abortRequested

webuiport

protected int webuiport

conf

protected final org.apache.hadoop.conf.Configuration conf

lock

protected final ReentrantReadWriteLock lock

threadWakeFrequency

protected final int threadWakeFrequency

numRegionsToReport

protected final int numRegionsToReport

REGIONSERVER

public static final String REGIONSERVER
region server process name

See Also:
Constant Field Values

REGIONSERVER_CONF

public static final String REGIONSERVER_CONF
region server configuration name

See Also:
Constant Field Values

hlog

protected volatile HLog hlog

hlogForMeta

protected volatile HLog hlogForMeta

isOnline

protected volatile boolean isOnline

movedRegions

protected Map<String,org.apache.hadoop.hbase.regionserver.HRegionServer.MovedRegionInfo> movedRegions
Constructor Detail

HRegionServer

public HRegionServer(org.apache.hadoop.conf.Configuration conf)
              throws IOException,
                     InterruptedException
Starts a HRegionServer at the default location

Parameters:
conf -
Throws:
IOException
InterruptedException
Method Detail

run

public void run()
The HRegionServer sticks in this loop until closed.

Specified by:
run in interface Runnable

handleReportForDutyResponse

protected void handleReportForDutyResponse(RegionServerStatusProtos.RegionServerStartupResponse c)
                                    throws IOException
Throws:
IOException

getRegionServerAccounting

public RegionServerAccounting getRegionServerAccounting()
Specified by:
getRegionServerAccounting in interface RegionServerServices
Returns:
the RegionServerAccounting for this Region Server

getTableLockManager

public TableLockManager getTableLockManager()
Specified by:
getTableLockManager in interface RegionServerServices
Returns:
RegionServer's instance of TableLockManager

createRegionLoad

public HBaseProtos.RegionLoad createRegionLoad(String encodedRegionName)
Parameters:
encodedRegionName -
Returns:
An instance of RegionLoad.

isOnline

public boolean isOnline()
Report the status of the server. A server is online once all the startup is completed (setting up filesystem, starting service threads, etc.). This method is designed mostly to be useful in tests.

Returns:
true if online, false if not.

instantiateHLog

protected HLog instantiateHLog(org.apache.hadoop.fs.Path rootdir,
                               String logName)
                        throws IOException
Called by setupWALAndReplication() creating WAL instance.

Parameters:
rootdir -
logName -
Returns:
WAL instance.
Throws:
IOException

getWALActionListeners

protected List<WALActionsListener> getWALActionListeners()
Called by instantiateHLog(Path, String) setting up WAL instance. Add any WALActionsListeners you want inserted before WAL startup.

Returns:
List of WALActionsListener that will be passed in to FSHLog on construction.

getMetaWALActionListeners

protected List<WALActionsListener> getMetaWALActionListeners()

getLogRoller

protected org.apache.hadoop.hbase.regionserver.LogRoller getLogRoller()

getMetrics

public MetricsRegionServer getMetrics()

getMasterAddressManager

public MasterAddressTracker getMasterAddressManager()
Returns:
Master address tracker instance.

getWAL

public HLog getWAL()

getWAL

public HLog getWAL(HRegionInfo regionInfo)
            throws IOException
Specified by:
getWAL in interface RegionServerServices
Returns:
the HLog for a particular region. Pass null for getting the default (common) WAL
Throws:
IOException

getCatalogTracker

public CatalogTracker getCatalogTracker()
Specified by:
getCatalogTracker in interface RegionServerServices
Returns:
The RegionServer's CatalogTracker

stop

public void stop(String msg)
Description copied from interface: Stoppable
Stop this service.

Parameters:
msg - Why we're stopping.

waitForServerOnline

public void waitForServerOnline()

postOpenDeployTasks

public void postOpenDeployTasks(HRegion r,
                                CatalogTracker ct)
                         throws org.apache.zookeeper.KeeperException,
                                IOException
Description copied from interface: RegionServerServices
Tasks to perform after region open to complete deploy of region on regionserver

Specified by:
postOpenDeployTasks in interface RegionServerServices
Parameters:
r - Region to open.
ct - Instance of CatalogTracker
Throws:
org.apache.zookeeper.KeeperException
IOException

getRpcServer

public RpcServer getRpcServer()
Description copied from interface: RegionServerServices
Returns a reference to the region server's RPC server

Specified by:
getRpcServer in interface RegionServerServices

abort

public void abort(String reason,
                  Throwable cause)
Cause the server to exit without closing the regions it is serving, the log it is using and without notifying the master. Used unit testing and on catastrophic events such as HDFS is yanked out from under hbase or we OOME.

Parameters:
reason - the reason we are aborting
cause - the exception that caused the abort, or null

abort

public void abort(String reason)
See Also:
abort(String, Throwable)

isAborted

public boolean isAborted()
Description copied from interface: Abortable
Check if the server or client was aborted.

Returns:
true if the server or client was aborted, false otherwise

kill

protected void kill()

join

protected void join()
Wait on all threads to finish. Presumption is that all closes and stops have already been called.


getLastSequenceId

public long getLastSequenceId(byte[] region)
Specified by:
getLastSequenceId in interface LastSequenceId
Returns:
Last flushed sequence Id for regionname

closeAllRegions

protected void closeAllRegions(boolean abort)
Closes all regions. Called on our way out. Assumes that its not possible for new regions to be added to onlineRegions while this method runs.


getInfoServer

public InfoServer getInfoServer()
Returns:
the info server

isStopped

public boolean isStopped()
Returns:
true if a stop has been requested.

isStopping

public boolean isStopping()
Specified by:
isStopping in interface RegionServerServices
Returns:
True if this regionserver is stopping.

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Description copied from interface: Server
Gets the configuration object for this server.

Returns:
the configuration

getNumberOfOnlineRegions

public int getNumberOfOnlineRegions()

getOnlineRegionsLocalContext

public Collection<HRegion> getOnlineRegionsLocalContext()
For tests, web ui and metrics. This method will only work if HRegionServer is in the same JVM as client; HRegion cannot be serialized to cross an rpc.


addToOnlineRegions

public void addToOnlineRegions(HRegion region)
Add to online regions.


getCopyOfOnlineRegionsSortedBySize

public SortedMap<Long,HRegion> getCopyOfOnlineRegionsSortedBySize()
Returns:
A new Map of online regions sorted by region size with the first entry being the biggest.

getStartcode

public long getStartcode()
Returns:
time stamp in millis of when this region server was started

getFlushRequester

public FlushRequester getFlushRequester()
Specified by:
getFlushRequester in interface RegionServerServices
Returns:
reference to FlushRequester

getMostLoadedRegions

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. TODO: actually calculate which regions are most loaded. (Right now, we're just grabbing the first N regions being served regardless of load.)


getLeases

public Leases getLeases()
Specified by:
getLeases in interface RegionServerServices
Returns:
The RegionServer's "Leases" service

getRootDir

protected org.apache.hadoop.fs.Path getRootDir()
Returns:
Return the rootDir.

getFileSystem

public org.apache.hadoop.fs.FileSystem getFileSystem()
Specified by:
getFileSystem in interface RegionServerServices
Returns:
Return the fs.

toString

public String toString()
Overrides:
toString in class Object

getThreadWakeFrequency

public int getThreadWakeFrequency()
Interval at which threads should run

Returns:
the interval

getZooKeeper

public ZooKeeperWatcher getZooKeeper()
Description copied from interface: Server
Gets the ZooKeeper instance for this server.


getServerName

public ServerName getServerName()
Returns:
The unique server name for this server.

getCompactionRequester

public CompactionRequestor getCompactionRequester()
Specified by:
getCompactionRequester in interface RegionServerServices
Returns:
Implementation of CompactionRequestor or null.

getZooKeeperWatcher

public ZooKeeperWatcher getZooKeeperWatcher()

getCoprocessorHost

public RegionServerCoprocessorHost getCoprocessorHost()

getRegionsInTransitionInRS

public ConcurrentMap<byte[],Boolean> getRegionsInTransitionInRS()
Description copied from interface: RegionServerServices
Get the regions that are currently being opened or closed in the RS

Specified by:
getRegionsInTransitionInRS in interface RegionServerServices
Returns:
map of regions in transition in this RS

getExecutorService

public ExecutorService getExecutorService()
Specified by:
getExecutorService in interface RegionServerServices
Returns:
hbase executor service

startRegionServer

public static Thread startRegionServer(HRegionServer hrs)
                                throws IOException
Parameters:
hrs -
Returns:
Thread the RegionServer is running in correctly named.
Throws:
IOException

startRegionServer

public static Thread startRegionServer(HRegionServer hrs,
                                       String name)
                                throws IOException
Parameters:
hrs -
name -
Returns:
Thread the RegionServer is running in correctly named.
Throws:
IOException

constructRegionServer

public static HRegionServer constructRegionServer(Class<? extends HRegionServer> regionServerClass,
                                                  org.apache.hadoop.conf.Configuration conf2)
Utility for constructing an instance of the passed HRegionServer class.

Parameters:
regionServerClass -
conf2 -
Returns:
HRegionServer instance.

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception
See Also:
HRegionServerCommandLine

getOnlineRegions

public List<HRegion> getOnlineRegions(byte[] tableName)
Gets the online regions of the specified table. This method looks at the in-memory onlineRegions. It does not go to .META.. Only returns online regions. If a region on this table has been closed during a disable, etc., it will not be included in the returned list. So, the returned list may not necessarily be ALL regions in this table, its all the ONLINE regions in the table.

Parameters:
tableName -
Returns:
Online regions from tableName

getCoprocessors

public String[] getCoprocessors()

checkOpen

protected void checkOpen()
                  throws IOException
Called to verify that this server is up and running.

Throws:
IOException

closeRegion

protected boolean closeRegion(String encodedName,
                              boolean abort,
                              boolean zk,
                              int versionOfClosingNode,
                              ServerName sn)
                       throws NotServingRegionException
Close asynchronously a region, can be called from the master or internally by the regionserver when stopping. If called from the master, the region will update the znode status.

If an opening was in progress, this method will cancel it, but will not start a new close. The coprocessors are not called in this case. A NotServingRegionException exception is thrown.

If a close was in progress, this new request will be ignored, and an exception thrown.

Parameters:
encodedName - Region to close
abort - True if we are aborting
zk - 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.
versionOfClosingNode - the version of znode to compare when RS transitions the znode from CLOSING state.
Returns:
True if closed a region.
Throws:
NotServingRegionException - if the region is not online or if a close request in in progress.

getOnlineRegion

public HRegion getOnlineRegion(byte[] regionName)
Parameters:
regionName -
Returns:
HRegion for the passed binary regionName or null if named region is not member of the online regions.

getFromOnlineRegions

public HRegion getFromOnlineRegions(String encodedRegionName)
Return HRegion instance. Only works if caller is in same context, in same JVM. HRegion is not serializable.

Returns:
HRegion for the passed encoded encodedRegionName or null if named region is not member of the online regions.

removeFromOnlineRegions

public boolean removeFromOnlineRegions(HRegion r,
                                       ServerName destination)
This method removes HRegion corresponding to hri from the Map of onlineRegions.

Parameters:
r - Region to remove.
destination - Destination, if any, null otherwise.
Returns:
True if we removed a region from online list.

getRegion

protected HRegion getRegion(byte[] regionName)
                     throws NotServingRegionException
Protected utility method for safely obtaining an HRegion handle.

Parameters:
regionName - Name of online HRegion to return
Returns:
HRegion for regionName
Throws:
NotServingRegionException

getRegionByEncodedName

protected HRegion getRegionByEncodedName(String encodedRegionName)
                                  throws NotServingRegionException
Throws:
NotServingRegionException

cleanup

protected Throwable cleanup(Throwable t)

cleanup

protected Throwable cleanup(Throwable t,
                            String msg)

convertThrowableToIOE

protected IOException convertThrowableToIOE(Throwable t)

convertThrowableToIOE

protected IOException convertThrowableToIOE(Throwable t,
                                            String msg)

checkOOME

public boolean checkOOME(Throwable e)
Description copied from interface: HBaseRPCErrorHandler
Take actions on the event of an OutOfMemoryError.

Specified by:
checkOOME in interface HBaseRPCErrorHandler
Parameters:
e - the throwable
Returns:
if the server should be shut down

checkFileSystem

public boolean checkFileSystem()
Checks to see if the file system is still accessible. If not, sets abortRequested and stopRequested

Returns:
false if file system is not available

addScanner

protected long addScanner(RegionScanner s)
                   throws Leases.LeaseStillHeldException
Throws:
Leases.LeaseStillHeldException

nextLong

protected long nextLong()
Generate a random positive long number

Returns:
a random positive long number

get

public ClientProtos.GetResponse get(com.google.protobuf.RpcController controller,
                                    ClientProtos.GetRequest request)
                             throws com.google.protobuf.ServiceException
Get data from a table.

Specified by:
get in interface ClientProtos.ClientService.BlockingInterface
Parameters:
controller - the RPC controller
request - the get request
Throws:
com.google.protobuf.ServiceException

multiGet

public ClientProtos.MultiGetResponse multiGet(com.google.protobuf.RpcController controller,
                                              ClientProtos.MultiGetRequest request)
                                       throws com.google.protobuf.ServiceException
Get multi data from a table.

Specified by:
multiGet in interface ClientProtos.ClientService.BlockingInterface
Parameters:
controller - the RPC controller
request - multi-the get request
Throws:
com.google.protobuf.ServiceException

mutate

public ClientProtos.MutateResponse mutate(com.google.protobuf.RpcController rpcc,
                                          ClientProtos.MutateRequest request)
                                   throws com.google.protobuf.ServiceException
Mutate data in a table.

Specified by:
mutate in interface ClientProtos.ClientService.BlockingInterface
Parameters:
rpcc - the RPC controller
request - the mutate request
Throws:
com.google.protobuf.ServiceException

scan

public ClientProtos.ScanResponse scan(com.google.protobuf.RpcController controller,
                                      ClientProtos.ScanRequest request)
                               throws com.google.protobuf.ServiceException
Scan data in a table.

Specified by:
scan in interface ClientProtos.ClientService.BlockingInterface
Parameters:
controller - the RPC controller
request - the scan request
Throws:
com.google.protobuf.ServiceException

bulkLoadHFile

public ClientProtos.BulkLoadHFileResponse bulkLoadHFile(com.google.protobuf.RpcController controller,
                                                        ClientProtos.BulkLoadHFileRequest request)
                                                 throws com.google.protobuf.ServiceException
Atomically bulk load several HFiles into an open region

Specified by:
bulkLoadHFile in interface ClientProtos.ClientService.BlockingInterface
Returns:
true if successful, false is failed but recoverably (no action)
Throws:
IOException - if failed unrecoverably
com.google.protobuf.ServiceException

execService

public ClientProtos.CoprocessorServiceResponse execService(com.google.protobuf.RpcController controller,
                                                           ClientProtos.CoprocessorServiceRequest request)
                                                    throws com.google.protobuf.ServiceException
Specified by:
execService in interface ClientProtos.ClientService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

multi

public ClientProtos.MultiResponse multi(com.google.protobuf.RpcController rpcc,
                                        ClientProtos.MultiRequest request)
                                 throws com.google.protobuf.ServiceException
Execute multiple actions on a table: get, mutate, and/or execCoprocessor

Specified by:
multi in interface ClientProtos.ClientService.BlockingInterface
Parameters:
rpcc - the RPC controller
request - the multi request
Throws:
com.google.protobuf.ServiceException

getRegionInfo

public AdminProtos.GetRegionInfoResponse getRegionInfo(com.google.protobuf.RpcController controller,
                                                       AdminProtos.GetRegionInfoRequest request)
                                                throws com.google.protobuf.ServiceException
Specified by:
getRegionInfo in interface AdminProtos.AdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

getStoreFile

public AdminProtos.GetStoreFileResponse getStoreFile(com.google.protobuf.RpcController controller,
                                                     AdminProtos.GetStoreFileRequest request)
                                              throws com.google.protobuf.ServiceException
Specified by:
getStoreFile in interface AdminProtos.AdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

getOnlineRegion

public AdminProtos.GetOnlineRegionResponse getOnlineRegion(com.google.protobuf.RpcController controller,
                                                           AdminProtos.GetOnlineRegionRequest request)
                                                    throws com.google.protobuf.ServiceException
Specified by:
getOnlineRegion in interface AdminProtos.AdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

openRegion

public AdminProtos.OpenRegionResponse openRegion(com.google.protobuf.RpcController controller,
                                                 AdminProtos.OpenRegionRequest request)
                                          throws com.google.protobuf.ServiceException
Open asynchronously a region or a set of regions on the region server. The opening is coordinated by ZooKeeper, and this method requires the znode to be created before being called. As a consequence, this method should be called only from the master.

Different manages states for the region are:

Bulk assign: If there are more than 1 region to open, it will be considered as a bulk assign. For a single region opening, errors are sent through a ServiceException. For bulk assign, errors are put in the response as FAILED_OPENING.

Specified by:
openRegion in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

closeRegion

public AdminProtos.CloseRegionResponse closeRegion(com.google.protobuf.RpcController controller,
                                                   AdminProtos.CloseRegionRequest request)
                                            throws com.google.protobuf.ServiceException
Close a region on the region server.

Specified by:
closeRegion in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

flushRegion

public AdminProtos.FlushRegionResponse flushRegion(com.google.protobuf.RpcController controller,
                                                   AdminProtos.FlushRegionRequest request)
                                            throws com.google.protobuf.ServiceException
Flush a region on the region server.

Specified by:
flushRegion in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

splitRegion

public AdminProtos.SplitRegionResponse splitRegion(com.google.protobuf.RpcController controller,
                                                   AdminProtos.SplitRegionRequest request)
                                            throws com.google.protobuf.ServiceException
Split a region on the region server.

Specified by:
splitRegion in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

mergeRegions

public AdminProtos.MergeRegionsResponse mergeRegions(com.google.protobuf.RpcController controller,
                                                     AdminProtos.MergeRegionsRequest request)
                                              throws com.google.protobuf.ServiceException
Merge regions on the region server.

Specified by:
mergeRegions in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Returns:
merge regions response
Throws:
com.google.protobuf.ServiceException

compactRegion

public AdminProtos.CompactRegionResponse compactRegion(com.google.protobuf.RpcController controller,
                                                       AdminProtos.CompactRegionRequest request)
                                                throws com.google.protobuf.ServiceException
Compact a region on the region server.

Specified by:
compactRegion in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

replicateWALEntry

public AdminProtos.ReplicateWALEntryResponse replicateWALEntry(com.google.protobuf.RpcController controller,
                                                               AdminProtos.ReplicateWALEntryRequest request)
                                                        throws com.google.protobuf.ServiceException
Replicate WAL entries on the region server.

Specified by:
replicateWALEntry in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

rollWALWriter

public AdminProtos.RollWALWriterResponse rollWALWriter(com.google.protobuf.RpcController controller,
                                                       AdminProtos.RollWALWriterRequest request)
                                                throws com.google.protobuf.ServiceException
Roll the WAL writer of the region server.

Specified by:
rollWALWriter in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

stopServer

public AdminProtos.StopServerResponse stopServer(com.google.protobuf.RpcController controller,
                                                 AdminProtos.StopServerRequest request)
                                          throws com.google.protobuf.ServiceException
Stop the region server.

Specified by:
stopServer in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

getServerInfo

public AdminProtos.GetServerInfoResponse getServerInfo(com.google.protobuf.RpcController controller,
                                                       AdminProtos.GetServerInfoRequest request)
                                                throws com.google.protobuf.ServiceException
Get some information of the region server.

Specified by:
getServerInfo in interface AdminProtos.AdminService.BlockingInterface
Parameters:
controller - the RPC controller
request - the request
Throws:
com.google.protobuf.ServiceException

getRegion

protected HRegion getRegion(HBaseProtos.RegionSpecifier regionSpecifier)
                     throws IOException
Find the HRegion based on a region specifier

Parameters:
regionSpecifier - the region specifier
Returns:
the corresponding region
Throws:
IOException - if the specifier is not null, but failed to find the region

append

protected Result append(HRegion region,
                        ClientProtos.MutationProto m,
                        CellScanner cellScanner)
                 throws IOException
Execute an append mutation.

Parameters:
region -
m -
cellScanner -
Returns:
result to return to client if default operation should be bypassed as indicated by RegionObserver, null otherwise
Throws:
IOException

increment

protected Result increment(HRegion region,
                           ClientProtos.MutationProto mutation,
                           CellScanner cells)
                    throws IOException
Execute an increment mutation.

Parameters:
region -
mutation -
Returns:
the Result
Throws:
IOException

doBatchOp

protected void doBatchOp(ClientProtos.MultiResponse.Builder builder,
                         HRegion region,
                         List<ClientProtos.MutationProto> mutations,
                         CellScanner cells)
Execute a list of Put/Delete mutations.

Parameters:
builder -
region -
mutations -

mutateRows

protected void mutateRows(HRegion region,
                          List<ClientProtos.MutationProto> mutations,
                          CellScanner cellScanner)
                   throws IOException
Mutate a list of rows atomically.

Parameters:
region -
mutations -
cellScanner - if non-null, the mutation data -- the Cell content.
Throws:
IOException

addToMovedRegions

protected void addToMovedRegions(String encodedName,
                                 ServerName destination,
                                 long closeSeqNum)

cleanMovedRegions

protected void cleanMovedRegions()
Remove the expired entries from the moved regions list.


getCompactSplitThread

public CompactSplitThread getCompactSplitThread()
Returns:
the underlying CompactSplitThread for the servers


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