|
||||||||||
| 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| Field Summary | |
|---|---|
protected java.lang.String |
bindAddress
|
protected java.util.concurrent.BlockingQueue<org.apache.hadoop.hbase.ipc.HBaseServer.Call> |
callQueue
|
protected org.apache.hadoop.conf.Configuration |
conf
|
protected java.util.List<org.apache.hadoop.hbase.ipc.HBaseServer.Connection> |
connectionList
|
protected static java.lang.ThreadLocal<org.apache.hadoop.hbase.ipc.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 java.nio.ByteBuffer |
HEADER
The first four bytes of Hadoop RPC connections |
static org.apache.commons.logging.Log |
LOG
|
protected int |
maxIdleTime
|
protected int |
numConnections
|
protected java.lang.Class<? extends org.apache.hadoop.io.Writable> |
paramClass
|
protected int |
port
|
protected java.util.concurrent.BlockingQueue<org.apache.hadoop.hbase.ipc.HBaseServer.Call> |
priorityCallQueue
|
protected org.apache.hadoop.hbase.ipc.HBaseServer.Responder |
responder
|
protected HBaseRpcMetrics |
rpcMetrics
|
protected boolean |
running
|
protected static java.lang.ThreadLocal<HBaseServer> |
SERVER
|
protected int |
socketSendBufferSize
|
protected boolean |
tcpKeepAlive
|
protected boolean |
tcpNoDelay
|
protected int |
thresholdIdleConnections
|
| Constructor Summary | |
|---|---|
protected |
HBaseServer(java.lang.String bindAddress,
int port,
java.lang.Class<? extends org.apache.hadoop.io.Writable> paramClass,
int handlerCount,
int priorityHandlerCount,
org.apache.hadoop.conf.Configuration conf,
java.lang.String serverName,
int highPriorityLevel)
|
| Method Summary | |
|---|---|
static void |
bind(java.net.ServerSocket socket,
java.net.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. |
abstract org.apache.hadoop.io.Writable |
call(org.apache.hadoop.io.Writable param,
long receiveTime)
Called for each call. |
protected static int |
channelRead(java.nio.channels.ReadableByteChannel channel,
java.nio.ByteBuffer buffer)
This is a wrapper around ReadableByteChannel.read(ByteBuffer). |
protected static int |
channelWrite(java.nio.channels.WritableByteChannel channel,
java.nio.ByteBuffer buffer)
This is a wrapper around WritableByteChannel.write(ByteBuffer). |
protected void |
closeConnection(org.apache.hadoop.hbase.ipc.HBaseServer.Connection connection)
|
static HBaseServer |
get()
Returns the server instance called under or null. |
int |
getCallQueueLen()
The number of rpc calls in the queue. |
java.net.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 java.lang.String |
getRemoteAddress()
Returns remote address as a string when invoked inside an RPC. |
static java.net.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,java.lang.Integer> newFunc)
|
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 |
| Field Detail |
|---|
public static final java.nio.ByteBuffer HEADER
public static final byte CURRENT_VERSION
public static final org.apache.commons.logging.Log LOG
protected static final java.lang.ThreadLocal<HBaseServer> SERVER
protected static final java.lang.ThreadLocal<org.apache.hadoop.hbase.ipc.HBaseServer.Call> CurCall
protected java.lang.String bindAddress
protected int port
protected java.lang.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 java.util.concurrent.BlockingQueue<org.apache.hadoop.hbase.ipc.HBaseServer.Call> callQueue
protected java.util.concurrent.BlockingQueue<org.apache.hadoop.hbase.ipc.HBaseServer.Call> priorityCallQueue
protected final java.util.List<org.apache.hadoop.hbase.ipc.HBaseServer.Connection> connectionList
protected org.apache.hadoop.hbase.ipc.HBaseServer.Responder responder
protected int numConnections
protected HBaseRPCErrorHandler errorHandler
| Constructor Detail |
|---|
protected HBaseServer(java.lang.String bindAddress,
int port,
java.lang.Class<? extends org.apache.hadoop.io.Writable> paramClass,
int handlerCount,
int priorityHandlerCount,
org.apache.hadoop.conf.Configuration conf,
java.lang.String serverName,
int highPriorityLevel)
throws java.io.IOException
java.io.IOException| Method Detail |
|---|
public static HBaseServer get()
call(Writable, long) implementations, and under Writable
methods of paramters and return values. Permits applications to access
the server context.
public static java.net.InetAddress getRemoteIp()
public static java.lang.String getRemoteAddress()
public static void bind(java.net.ServerSocket socket,
java.net.InetSocketAddress address,
int backlog)
throws java.io.IOException
socket - the socket to bindaddress - the address to bind tobacklog - the number of connections allowed in the queue
java.net.BindException - if the address can't be bound
java.net.UnknownHostException - if the address isn't a valid host name
java.io.IOException - other random errors from bindpublic void setQosFunction(com.google.common.base.Function<org.apache.hadoop.io.Writable,java.lang.Integer> newFunc)
protected int getQosLevel(org.apache.hadoop.io.Writable param)
protected void closeConnection(org.apache.hadoop.hbase.ipc.HBaseServer.Connection connection)
public void setSocketSendBufSize(int size)
size - send sizepublic void start()
public void openServer()
public void startThreads()
ServerNotRunningException instead.
public void stop()
public void join()
throws java.lang.InterruptedException
stop().
java.lang.InterruptedException - epublic java.net.InetSocketAddress getListenerAddress()
public abstract org.apache.hadoop.io.Writable call(org.apache.hadoop.io.Writable param,
long receiveTime)
throws java.io.IOException
param - writable parameterreceiveTime - time
java.io.IOException - epublic int getNumOpenConnections()
public int getCallQueueLen()
public void setErrorHandler(HBaseRPCErrorHandler handler)
handler - the handler implementationpublic HBaseRpcMetrics getRpcMetrics()
protected static int channelWrite(java.nio.channels.WritableByteChannel channel,
java.nio.ByteBuffer buffer)
throws java.io.IOException
WritableByteChannel.write(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
java.io.IOException - eWritableByteChannel.write(ByteBuffer)
protected static int channelRead(java.nio.channels.ReadableByteChannel channel,
java.nio.ByteBuffer buffer)
throws java.io.IOException
ReadableByteChannel.read(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
java.io.IOException - eReadableByteChannel.read(ByteBuffer)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||