@InterfaceAudience.Private public abstract class RpcServer extends Object implements RpcServerInterface, ConfigurationObserver
Modifier and Type | Class and Description |
---|---|
static class |
RpcServer.BlockingServiceAndInterface
Datastructure for passing a
BlockingService and its associated class of
protobuf service interface. |
protected static interface |
RpcServer.CallCleanup |
Modifier and Type | Field and Description |
---|---|
protected boolean |
allowFallbackToSimpleAuth |
protected static org.slf4j.Logger |
AUDITLOG |
protected static String |
AUTH_FAILED_FOR |
protected static String |
AUTH_SUCCESSFUL_FOR |
protected org.apache.hadoop.security.authorize.ServiceAuthorizationManager |
authManager |
protected AuthenticationTokenSecretManager |
authTokenSecretMgr |
protected InetSocketAddress |
bindAddress |
protected static CallQueueTooBigException |
CALL_QUEUE_TOO_BIG_EXCEPTION |
protected LongAdder |
callQueueSizeInBytes
This is a running count of the size in bytes of all outstanding calls whether currently
executing or queued waiting to be run.
|
protected org.apache.hadoop.hbase.ipc.CellBlockBuilder |
cellBlockBuilder |
protected org.apache.hadoop.conf.Configuration |
conf |
protected static ThreadLocal<RpcCall> |
CurCall
This is set to Call object before Handler invokes an RPC and ybdie
after the call returns.
|
static byte |
CURRENT_VERSION |
protected static int |
DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER
How many calls/handler are allowed in the queue.
|
protected static int |
DEFAULT_MAX_CALLQUEUE_SIZE |
static int |
DEFAULT_MAX_REQUEST_SIZE
Default value for above params
|
protected static int |
DEFAULT_MIN_CLIENT_REQUEST_TIMEOUT |
protected static int |
DEFAULT_TRACE_LOG_MAX_LENGTH |
protected static int |
DEFAULT_WARN_RESPONSE_SIZE |
protected static int |
DEFAULT_WARN_RESPONSE_TIME |
protected HBaseRPCErrorHandler |
errorHandler |
static String |
FALLBACK_TO_INSECURE_CLIENT_AUTH
Whether we allow a fallback to SIMPLE auth for insecure clients when security is enabled.
|
protected boolean |
isSecurityEnabled |
protected static String |
KEY_WORD_TRUNCATED |
static org.slf4j.Logger |
LOG |
protected static com.fasterxml.jackson.databind.ObjectMapper |
MAPPER |
static String |
MAX_REQUEST_SIZE |
protected long |
maxQueueSizeInBytes
Maximum size in bytes of the currently queued and running Calls.
|
protected int |
maxRequestSize |
protected MetricsHBaseServer |
metrics |
protected static String |
MIN_CLIENT_REQUEST_TIMEOUT
Minimum allowable timeout (in milliseconds) in rpc request's header.
|
protected int |
minClientRequestTimeout |
protected int |
minSizeForReservoirUse |
protected static ThreadLocal<MonitoredRPCHandler> |
MONITORED_RPC
Keeps MonitoredRPCHandler per handler thread.
|
protected static int |
NIO_BUFFER_LIMIT
When the read or write buffer size is larger than this limit, i/o will be
done in chunks of this size.
|
protected static RequestTooBigException |
REQUEST_TOO_BIG_EXCEPTION |
protected ByteBufferPool |
reservoir |
protected Map<String,String> |
saslProps |
protected RpcScheduler |
scheduler |
protected org.apache.hadoop.security.token.SecretManager<org.apache.hadoop.security.token.TokenIdentifier> |
secretManager |
protected Server |
server |
protected List<RpcServer.BlockingServiceAndInterface> |
services |
protected boolean |
tcpKeepAlive |
protected boolean |
tcpNoDelay |
protected static String |
TRACE_LOG_MAX_LENGTH |
protected UserProvider |
userProvider |
protected static String |
WARN_RESPONSE_SIZE |
protected static String |
WARN_RESPONSE_TIME |
protected int |
warnResponseSize |
protected int |
warnResponseTime |
Constructor and Description |
---|
RpcServer(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 |
---|---|
void |
addCallSize(long diff)
Add/subtract from the current size of all outstanding calls.
|
void |
authorize(org.apache.hadoop.security.UserGroupInformation user,
RPCProtos.ConnectionHeader connection,
InetAddress addr)
Authorize the incoming client connection.
|
Pair<org.apache.hbase.thirdparty.com.google.protobuf.Message,CellScanner> |
call(RpcCall call,
MonitoredRPCHandler status)
This is a server side method, which is invoked over RPC.
|
protected int |
channelRead(ReadableByteChannel channel,
ByteBuffer buffer)
This is a wrapper around
ReadableByteChannel.read(java.nio.ByteBuffer) . |
protected AuthenticationTokenSecretManager |
createSecretManager() |
static Optional<RpcCall> |
getCurrentCall()
Needed for features such as delayed calls.
|
HBaseRPCErrorHandler |
getErrorHandler() |
MetricsHBaseServer |
getMetrics()
Returns the metrics instance for reporting RPC call statistics
|
abstract int |
getNumOpenConnections()
The number of open RPC conections
|
static Optional<InetAddress> |
getRemoteAddress() |
static InetAddress |
getRemoteIp()
Returns the remote side ip address when invoked inside an RPC
Returns null incase of an error.
|
static Optional<User> |
getRequestUser()
Returns the user credentials associated with the current RPC request or not present if no
credentials were provided.
|
static Optional<String> |
getRequestUserName()
Returns the username for any user associated with the current RPC
request or not present if no user is set.
|
RpcScheduler |
getScheduler() |
org.apache.hadoop.security.token.SecretManager<? extends org.apache.hadoop.security.token.TokenIdentifier> |
getSecretManager() |
protected static org.apache.hbase.thirdparty.com.google.protobuf.BlockingService |
getService(List<RpcServer.BlockingServiceAndInterface> services,
String serviceName) |
protected static RpcServer.BlockingServiceAndInterface |
getServiceAndInterface(List<RpcServer.BlockingServiceAndInterface> services,
String serviceName) |
protected static Class<?> |
getServiceInterface(List<RpcServer.BlockingServiceAndInterface> services,
String serviceName) |
protected static MonitoredRPCHandler |
getStatus() |
protected void |
initReconfigurable(org.apache.hadoop.conf.Configuration confToLoad) |
static boolean |
isInRpcCallContext() |
boolean |
isStarted() |
void |
onConfigurationChange(org.apache.hadoop.conf.Configuration newConf)
This method would be called by the
ConfigurationManager
object when the Configuration object is reloaded from disk. |
void |
refreshAuthManager(org.apache.hadoop.security.authorize.PolicyProvider pp)
Refresh authentication manager policy.
|
void |
setErrorHandler(HBaseRPCErrorHandler handler)
Set the handler for calling out of RPC for error conditions.
|
void |
setRsRpcServices(RSRpcServices rsRpcServices) |
void |
setSecretManager(org.apache.hadoop.security.token.SecretManager<? extends org.apache.hadoop.security.token.TokenIdentifier> secretManager) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
call, call, getListenerAddress, join, setSocketSendBufSize, start, stop
public static final org.slf4j.Logger LOG
protected static final CallQueueTooBigException CALL_QUEUE_TOO_BIG_EXCEPTION
protected boolean isSecurityEnabled
public static final byte CURRENT_VERSION
public static final String FALLBACK_TO_INSECURE_CLIENT_AUTH
protected static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER
protected final org.apache.hadoop.hbase.ipc.CellBlockBuilder cellBlockBuilder
protected static final String AUTH_FAILED_FOR
protected static final String AUTH_SUCCESSFUL_FOR
protected static final org.slf4j.Logger AUDITLOG
protected org.apache.hadoop.security.token.SecretManager<org.apache.hadoop.security.token.TokenIdentifier> secretManager
protected org.apache.hadoop.security.authorize.ServiceAuthorizationManager authManager
protected static final ThreadLocal<RpcCall> CurCall
protected static final ThreadLocal<MonitoredRPCHandler> MONITORED_RPC
protected final InetSocketAddress bindAddress
protected MetricsHBaseServer metrics
protected final org.apache.hadoop.conf.Configuration conf
protected final long maxQueueSizeInBytes
callQueueSizeInBytes
.callQueueSizeInBytes
,
DEFAULT_MAX_CALLQUEUE_SIZE
protected static final int DEFAULT_MAX_CALLQUEUE_SIZE
protected final LongAdder callQueueSizeInBytes
protected final boolean tcpNoDelay
protected final boolean tcpKeepAlive
protected AuthenticationTokenSecretManager authTokenSecretMgr
protected HBaseRPCErrorHandler errorHandler
public static final String MAX_REQUEST_SIZE
protected static final RequestTooBigException REQUEST_TOO_BIG_EXCEPTION
protected static final String WARN_RESPONSE_TIME
protected static final String WARN_RESPONSE_SIZE
protected static final String MIN_CLIENT_REQUEST_TIMEOUT
protected static final int DEFAULT_MIN_CLIENT_REQUEST_TIMEOUT
public static final int DEFAULT_MAX_REQUEST_SIZE
protected static final int DEFAULT_WARN_RESPONSE_TIME
protected static final int DEFAULT_WARN_RESPONSE_SIZE
protected static final int DEFAULT_TRACE_LOG_MAX_LENGTH
protected static final String TRACE_LOG_MAX_LENGTH
protected static final String KEY_WORD_TRUNCATED
protected static final com.fasterxml.jackson.databind.ObjectMapper MAPPER
protected final int maxRequestSize
protected final int warnResponseTime
protected final int warnResponseSize
protected final int minClientRequestTimeout
protected final Server server
protected final List<RpcServer.BlockingServiceAndInterface> services
protected final RpcScheduler scheduler
protected UserProvider userProvider
protected final ByteBufferPool reservoir
protected final int minSizeForReservoirUse
protected volatile boolean allowFallbackToSimpleAuth
protected static final int NIO_BUFFER_LIMIT
public RpcServer(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
public void onConfigurationChange(org.apache.hadoop.conf.Configuration newConf)
ConfigurationObserver
ConfigurationManager
object when the Configuration
object is reloaded from disk.onConfigurationChange
in interface ConfigurationObserver
protected void initReconfigurable(org.apache.hadoop.conf.Configuration confToLoad)
public boolean isStarted()
isStarted
in interface RpcServerInterface
public void refreshAuthManager(org.apache.hadoop.security.authorize.PolicyProvider pp)
RpcServerInterface
refreshAuthManager
in interface RpcServerInterface
protected AuthenticationTokenSecretManager createSecretManager()
public org.apache.hadoop.security.token.SecretManager<? extends org.apache.hadoop.security.token.TokenIdentifier> getSecretManager()
public void setSecretManager(org.apache.hadoop.security.token.SecretManager<? extends org.apache.hadoop.security.token.TokenIdentifier> secretManager)
public Pair<org.apache.hbase.thirdparty.com.google.protobuf.Message,CellScanner> call(RpcCall call, MonitoredRPCHandler status) throws IOException
call
in interface RpcServerInterface
IOException
public void setErrorHandler(HBaseRPCErrorHandler handler)
setErrorHandler
in interface RpcServerInterface
handler
- the handler implementationpublic HBaseRPCErrorHandler getErrorHandler()
getErrorHandler
in interface RpcServerInterface
public MetricsHBaseServer getMetrics()
getMetrics
in interface RpcServerInterface
public void addCallSize(long diff)
RpcServerInterface
addCallSize
in interface RpcServerInterface
diff
- Change (plus or minus)public void authorize(org.apache.hadoop.security.UserGroupInformation user, RPCProtos.ConnectionHeader connection, InetAddress addr) throws org.apache.hadoop.security.authorize.AuthorizationException
user
- client userconnection
- incoming connectionaddr
- InetAddress of incoming connectionorg.apache.hadoop.security.authorize.AuthorizationException
- when the client isn't authorized to talk the protocolprotected 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 writeIOException
- eReadableByteChannel.read(java.nio.ByteBuffer)
public static Optional<RpcCall> getCurrentCall()
public static boolean isInRpcCallContext()
public static Optional<User> getRequestUser()
public abstract int getNumOpenConnections()
public static Optional<String> getRequestUserName()
public static Optional<InetAddress> getRemoteAddress()
protected static RpcServer.BlockingServiceAndInterface getServiceAndInterface(List<RpcServer.BlockingServiceAndInterface> services, String serviceName)
serviceName
- Some arbitrary string that represents a 'service'.services
- Available service instancesprotected static Class<?> getServiceInterface(List<RpcServer.BlockingServiceAndInterface> services, String serviceName)
serviceName
- Some arbitrary string that represents a 'service'.services
- Available services and their service interfaces.serviceName
protected static org.apache.hbase.thirdparty.com.google.protobuf.BlockingService getService(List<RpcServer.BlockingServiceAndInterface> services, String serviceName)
serviceName
- Some arbitrary string that represents a 'service'.services
- Available services and their service interfaces.serviceName
protected static MonitoredRPCHandler getStatus()
public static InetAddress getRemoteIp()
public RpcScheduler getScheduler()
getScheduler
in interface RpcServerInterface
public void setRsRpcServices(RSRpcServices rsRpcServices)
setRsRpcServices
in interface RpcServerInterface
Copyright © 2007–2019 Cloudera. All rights reserved.