@InterfaceAudience.LimitedPrivate(value="Configuration") public class SimpleRpcServer extends RpcServer
Scheduler can be variously implemented but default simple scheduler has handlers to which it has given the queues into which calls (i.e. CallRunner instances) are inserted. Handlers run taking from the queue. They run the CallRunner#run method on each item gotten from queue and keep taking while the server is up. CallRunner#run executes the call. When done, asks the included Call to put itself on new queue for Responder to pull from and return result to client.
BlockingRpcClient
Modifier and Type | Class and Description |
---|---|
private class |
SimpleRpcServer.ConnectionManager |
private class |
SimpleRpcServer.Listener
Listens on the socket.
|
RpcServer.BlockingServiceAndInterface, RpcServer.CallCleanup
Modifier and Type | Field and Description |
---|---|
protected InetSocketAddress |
address |
private SimpleRpcServer.ConnectionManager |
connectionManager |
private SimpleRpcServer.Listener |
listener |
protected int |
port |
protected long |
purgeTimeout |
private int |
readThreads |
protected SimpleRpcServerResponder |
responder |
protected int |
socketSendBufferSize |
allowFallbackToSimpleAuth, AUDITLOG, AUTH_FAILED_FOR, AUTH_SUCCESSFUL_FOR, authManager, authTokenSecretMgr, bbAllocator, bindAddress, CALL_QUEUE_TOO_BIG_EXCEPTION, callQueueSizeInBytes, cellBlockBuilder, conf, CurCall, CURRENT_VERSION, DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER, DEFAULT_MAX_CALLQUEUE_SIZE, DEFAULT_MAX_REQUEST_SIZE, DEFAULT_MIN_CLIENT_REQUEST_TIMEOUT, DEFAULT_TRACE_LOG_MAX_LENGTH, DEFAULT_WARN_RESPONSE_SIZE, DEFAULT_WARN_RESPONSE_TIME, errorHandler, FALLBACK_TO_INSECURE_CLIENT_AUTH, GSON, isSecurityEnabled, KEY_WORD_TRUNCATED, LOG, MAX_REQUEST_SIZE, maxQueueSizeInBytes, maxRequestSize, metrics, MIN_CLIENT_REQUEST_TIMEOUT, minClientRequestTimeout, MONITORED_RPC, NIO_BUFFER_LIMIT, REQUEST_TOO_BIG_EXCEPTION, running, saslProps, scheduler, secretManager, server, services, started, tcpKeepAlive, tcpNoDelay, TRACE_LOG_MAX_LENGTH, userProvider, WARN_RESPONSE_SIZE, WARN_RESPONSE_TIME, warnResponseSize, warnResponseTime
Constructor and Description |
---|
SimpleRpcServer(Server server,
String name,
List<RpcServer.BlockingServiceAndInterface> services,
InetSocketAddress bindAddress,
org.apache.hadoop.conf.Configuration conf,
RpcScheduler scheduler,
boolean reservoirEnabled)
Constructs a server listening on the named port and address.
|
Modifier and Type | Method and Description |
---|---|
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.
|
Pair<org.apache.hbase.thirdparty.com.google.protobuf.Message,CellScanner> |
call(org.apache.hbase.thirdparty.com.google.protobuf.BlockingService service,
org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor md,
org.apache.hbase.thirdparty.com.google.protobuf.Message param,
CellScanner cellScanner,
long receiveTime,
MonitoredRPCHandler status) |
Pair<org.apache.hbase.thirdparty.com.google.protobuf.Message,CellScanner> |
call(org.apache.hbase.thirdparty.com.google.protobuf.BlockingService service,
org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor md,
org.apache.hbase.thirdparty.com.google.protobuf.Message param,
CellScanner cellScanner,
long receiveTime,
MonitoredRPCHandler status,
long startTime,
int timeout) |
protected long |
channelWrite(GatheringByteChannel channel,
BufferChain bufferChain)
This is a wrapper around
WritableByteChannel.write(java.nio.ByteBuffer) . |
protected void |
closeConnection(SimpleServerRpcConnection connection) |
protected SimpleServerRpcConnection |
getConnection(SocketChannel channel,
long time)
Subclasses of HBaseServer can override this to provide their own
Connection implementations.
|
InetSocketAddress |
getListenerAddress()
Return the socket (ip+port) on which the RPC server is listening to.
|
int |
getNumOpenConnections()
The number of open RPC conections
|
void |
join()
Wait for the server to be stopped.
|
void |
setSocketSendBufSize(int size)
Sets the socket buffer size used for responding to RPCs.
|
void |
start()
Starts the service.
|
void |
stop()
Stops the service.
|
addCallSize, authorize, call, channelRead, createSecretManager, getByteBuffAllocator, getConf, getCurrentCall, getErrorHandler, getMetrics, getRemoteAddress, getRemoteIp, getRequestUser, getRequestUserName, getScheduler, getSecretManager, getService, getServiceAndInterface, getServiceInterface, getSlowLogRecorder, getStatus, initReconfigurable, isInRpcCallContext, isStarted, logResponse, onConfigurationChange, refreshAuthManager, setCurrentCall, setErrorHandler, setRsRpcServices, setSecretManager, setSlowLogRecorder, truncateTraceLog, unsetCurrentCall
protected int port
protected InetSocketAddress address
private int readThreads
protected int socketSendBufferSize
protected final long purgeTimeout
private SimpleRpcServer.ConnectionManager connectionManager
private SimpleRpcServer.Listener listener
protected SimpleRpcServerResponder responder
public SimpleRpcServer(Server server, String name, List<RpcServer.BlockingServiceAndInterface> services, InetSocketAddress bindAddress, org.apache.hadoop.conf.Configuration conf, RpcScheduler scheduler, boolean reservoirEnabled) throws IOException
server
- hosting instance of Server
. We will do authentications if an
instance else pass null for no authentication check.name
- Used keying this rpc servers' metrics and for naming the Listener thread.services
- A list of services.bindAddress
- Where to listenconf
- scheduler
- reservoirEnabled
- Enable ByteBufferPool or not.IOException
protected SimpleServerRpcConnection getConnection(SocketChannel channel, long time)
protected void closeConnection(SimpleServerRpcConnection connection)
public void setSocketSendBufSize(int size)
size
- send sizepublic void start()
public void stop()
public void join() throws InterruptedException
stop()
.InterruptedException
- epublic InetSocketAddress getListenerAddress()
public Pair<org.apache.hbase.thirdparty.com.google.protobuf.Message,CellScanner> call(org.apache.hbase.thirdparty.com.google.protobuf.BlockingService service, org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor md, org.apache.hbase.thirdparty.com.google.protobuf.Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status) throws IOException
IOException
public Pair<org.apache.hbase.thirdparty.com.google.protobuf.Message,CellScanner> call(org.apache.hbase.thirdparty.com.google.protobuf.BlockingService service, org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor md, org.apache.hbase.thirdparty.com.google.protobuf.Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status, long startTime, int timeout) throws IOException
IOException
protected long channelWrite(GatheringByteChannel channel, BufferChain bufferChain) 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 tobufferChain
- Chain of buffers to writeIOException
- eWritableByteChannel.write(java.nio.ByteBuffer)
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 queueBindException
- if the address can't be boundUnknownHostException
- if the address isn't a valid host nameIOException
- other random errors from bindpublic int getNumOpenConnections()
getNumOpenConnections
in class RpcServer
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.