|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hbase.ipc.HBaseServer
public abstract class HBaseServer
An abstract IPC service. IPC calls take a single Writable as a
parameter, and return a Writable as their value. A service runs on
a port and is defined by a parameter class and a value class.
Copied local so can fix HBASE-900.
HBaseClient| Nested Class Summary | |
|---|---|
protected class |
HBaseServer.Call
A call queued for handling. |
protected class |
HBaseServer.Connection
Reads calls from a connection and queues them for handling. |
protected class |
HBaseServer.Responder
|
| Field Summary | |
|---|---|
protected String |
bindAddress
|
protected BlockingQueue<HBaseServer.Call> |
callQueue
|
protected org.apache.hadoop.conf.Configuration |
conf
|
protected List<HBaseServer.Connection> |
connectionList
|
protected static ThreadLocal<HBaseServer.Call> |
CurCall
This is set to Call object before Handler invokes an RPC and reset after the call returns. |
static byte |
CURRENT_VERSION
|
protected HBaseRPCErrorHandler |
errorHandler
|
static ByteBuffer |
HEADER
The first four bytes of Hadoop RPC connections |
protected int |
highPriorityLevel
|
static org.apache.commons.logging.Log |
LOG
|
protected int |
maxIdleTime
|
protected int |
numConnections
|
protected Class<? extends org.apache.hadoop.io.Writable> |
paramClass
|
protected int |
port
|
protected BlockingQueue<HBaseServer.Call> |
priorityCallQueue
|
protected HBaseServer.Responder |
responder
|
protected HBaseRpcMetrics |
rpcMetrics
|
protected boolean |
running
|
protected static ThreadLocal<RpcServer> |
SERVER
|
protected int |
socketSendBufferSize
|
protected boolean |
tcpKeepAlive
|
protected boolean |
tcpNoDelay
|
protected int |
thresholdIdleConnections
|
protected static org.apache.commons.logging.Log |
TRACELOG
|
| Constructor Summary | |
|---|---|
protected |
HBaseServer(String bindAddress,
int port,
Class<? extends org.apache.hadoop.io.Writable> paramClass,
int handlerCount,
int priorityHandlerCount,
org.apache.hadoop.conf.Configuration conf,
String serverName,
int highPriorityLevel)
|
| Method Summary | |
|---|---|
static void |
bind(ServerSocket socket,
InetSocketAddress address,
int backlog)
A convenience method to bind to a given address and report better exceptions if the address is not a valid host. |
protected int |
channelRead(ReadableByteChannel channel,
ByteBuffer buffer)
This is a wrapper around ReadableByteChannel.read(java.nio.ByteBuffer). |
protected int |
channelWrite(WritableByteChannel channel,
ByteBuffer buffer)
This is a wrapper around WritableByteChannel.write(java.nio.ByteBuffer). |
protected void |
closeConnection(HBaseServer.Connection connection)
|
static RpcServer |
get()
Returns the server instance called under or null. |
int |
getCallQueueLen()
The number of rpc calls in the queue. |
protected HBaseServer.Connection |
getConnection(SocketChannel channel,
long time)
Subclasses of HBaseServer can override this to provide their own Connection implementations. |
Delayable |
getCurrentCall()
Needed for delayed calls. |
InetSocketAddress |
getListenerAddress()
Return the socket (ip+port) on which the RPC server is listening to. |
int |
getNumOpenConnections()
The number of open RPC conections |
protected int |
getQosLevel(org.apache.hadoop.io.Writable param)
|
static String |
getRemoteAddress()
Returns remote address as a string when invoked inside an RPC. |
static InetAddress |
getRemoteIp()
Returns the remote side ip address when invoked inside an RPC Returns null incase of an error. |
HBaseRpcMetrics |
getRpcMetrics()
Returns the metrics instance for reporting RPC call statistics |
void |
join()
Wait for the server to be stopped. |
void |
openServer()
Open a previously started server. |
void |
setErrorHandler(HBaseRPCErrorHandler handler)
Set the handler for calling out of RPC for error conditions. |
void |
setQosFunction(com.google.common.base.Function<org.apache.hadoop.io.Writable,Integer> newFunc)
Gets the QOS level for this call. |
void |
setSocketSendBufSize(int size)
Sets the socket buffer size used for responding to RPCs. |
void |
start()
Starts the service. |
void |
startThreads()
Starts the service threads but does not allow requests to be responded yet. |
void |
stop()
Stops the service. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.hadoop.hbase.ipc.RpcServer |
|---|
call |
| Field Detail |
|---|
public static final ByteBuffer HEADER
public static final byte CURRENT_VERSION
public static final org.apache.commons.logging.Log LOG
protected static final org.apache.commons.logging.Log TRACELOG
protected static final ThreadLocal<RpcServer> SERVER
protected static final ThreadLocal<HBaseServer.Call> CurCall
protected String bindAddress
protected int port
protected Class<? extends org.apache.hadoop.io.Writable> paramClass
protected int maxIdleTime
protected int thresholdIdleConnections
protected HBaseRpcMetrics rpcMetrics
protected org.apache.hadoop.conf.Configuration conf
protected int socketSendBufferSize
protected final boolean tcpNoDelay
protected final boolean tcpKeepAlive
protected volatile boolean running
protected BlockingQueue<HBaseServer.Call> callQueue
protected BlockingQueue<HBaseServer.Call> priorityCallQueue
protected int highPriorityLevel
protected final List<HBaseServer.Connection> connectionList
protected HBaseServer.Responder responder
protected int numConnections
protected HBaseRPCErrorHandler errorHandler
| Constructor Detail |
|---|
protected HBaseServer(String bindAddress,
int port,
Class<? extends org.apache.hadoop.io.Writable> paramClass,
int handlerCount,
int priorityHandlerCount,
org.apache.hadoop.conf.Configuration conf,
String serverName,
int highPriorityLevel)
throws IOException
IOException| Method Detail |
|---|
public static RpcServer get()
RpcServer.call(Class, Writable, long, MonitoredRPCHandler) implementations,
and under Writable methods of paramters and return values.
Permits applications to access the server context.
public static InetAddress getRemoteIp()
public static String getRemoteAddress()
public static void bind(ServerSocket socket,
InetSocketAddress address,
int backlog)
throws IOException
socket - the socket to bindaddress - the address to bind tobacklog - the number of connections allowed in the queue
BindException - if the address can't be bound
UnknownHostException - if the address isn't a valid host name
IOException - other random errors from bindpublic void setQosFunction(com.google.common.base.Function<org.apache.hadoop.io.Writable,Integer> newFunc)
setQosFunction in interface RpcServernewFunc - protected int getQosLevel(org.apache.hadoop.io.Writable param)
protected HBaseServer.Connection getConnection(SocketChannel channel,
long time)
protected void closeConnection(HBaseServer.Connection connection)
public void setSocketSendBufSize(int size)
setSocketSendBufSize in interface RpcServersize - send sizepublic void start()
start in interface RpcServerpublic void openServer()
openServer in interface RpcServerpublic void startThreads()
ServerNotRunningYetException instead.
startThreads in interface RpcServerpublic void stop()
stop in interface RpcServer
public void join()
throws InterruptedException
stop().
join in interface RpcServerInterruptedException - epublic InetSocketAddress getListenerAddress()
getListenerAddress in interface RpcServerpublic int getNumOpenConnections()
getNumOpenConnections in interface RpcServerpublic int getCallQueueLen()
getCallQueueLen in interface RpcServerpublic void setErrorHandler(HBaseRPCErrorHandler handler)
setErrorHandler in interface RpcServerhandler - the handler implementationpublic HBaseRpcMetrics getRpcMetrics()
getRpcMetrics in interface RpcServer
protected int channelWrite(WritableByteChannel channel,
ByteBuffer buffer)
throws IOException
WritableByteChannel.write(java.nio.ByteBuffer).
If the amount of data is large, it writes to channel in smaller chunks.
This is to avoid jdk from creating many direct buffers as the size of
buffer increases. This also minimizes extra copies in NIO layer
as a result of multiple write operations required to write a large
buffer.
channel - writable byte channel to write tobuffer - buffer to write
IOException - eWritableByteChannel.write(java.nio.ByteBuffer)
protected int channelRead(ReadableByteChannel channel,
ByteBuffer buffer)
throws IOException
ReadableByteChannel.read(java.nio.ByteBuffer).
If the amount of data is large, it writes to channel in smaller chunks.
This is to avoid jdk from creating many direct buffers as the size of
ByteBuffer increases. There should not be any performance degredation.
channel - writable byte channel to write onbuffer - buffer to write
IOException - eReadableByteChannel.read(java.nio.ByteBuffer)public Delayable getCurrentCall()
RpcServer
getCurrentCall in interface RpcServer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||