@InterfaceAudience.Private public abstract class RpcServer extends Object implements RpcServerInterface, ConfigurationObserver
| Modifier and Type | Class and Description | 
|---|---|
| static class  | RpcServer.BlockingServiceAndInterfaceDatastructure for passing a  BlockingServiceand 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 | 
| private boolean | authorize | 
| protected AuthenticationTokenSecretManager | authTokenSecretMgr | 
| protected ByteBuffAllocator | bbAllocator | 
| protected InetSocketAddress | bindAddress | 
| protected static CallQueueTooBigException | CALL_QUEUE_TOO_BIG_EXCEPTION | 
| protected LongAdder | callQueueSizeInBytesThis is a running count of the size in bytes of all outstanding calls whether currently
 executing or queued waiting to be run. | 
| protected CellBlockBuilder | cellBlockBuilder | 
| protected org.apache.hadoop.conf.Configuration | conf | 
| protected static ThreadLocal<RpcCall> | CurCallThis 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_HANDLERHow many calls/handler are allowed in the queue. | 
| protected static int | DEFAULT_MAX_CALLQUEUE_SIZE | 
| static int | DEFAULT_MAX_REQUEST_SIZEDefault 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_AUTHWhether we allow a fallback to SIMPLE auth for insecure clients when security is enabled. | 
| protected static org.apache.hbase.thirdparty.com.google.gson.Gson | GSON | 
| private boolean | isOnlineLogProviderEnabled | 
| protected boolean | isSecurityEnabled | 
| protected static String | KEY_WORD_TRUNCATED | 
| static org.slf4j.Logger | LOG | 
| static String | MAX_REQUEST_SIZE | 
| protected long | maxQueueSizeInBytesMaximum size in bytes of the currently queued and running Calls. | 
| protected int | maxRequestSize | 
| protected MetricsHBaseServer | metrics | 
| protected static String | MIN_CLIENT_REQUEST_TIMEOUTMinimum allowable timeout (in milliseconds) in rpc request's header. | 
| protected int | minClientRequestTimeout | 
| protected static ThreadLocal<MonitoredRPCHandler> | MONITORED_RPCKeeps MonitoredRPCHandler per handler thread. | 
| private static String | MULTI_GETS | 
| private static String | MULTI_MUTATIONS | 
| private static String | MULTI_SERVICE_CALLS | 
| private NamedQueueRecorder | namedQueueRecorderUse to add online slowlog responses | 
| protected static int | NIO_BUFFER_LIMITWhen 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 | 
| private RSRpcServices | rsRpcServicesUsed to get details for scan with a scanner_id TODO try to figure out a better way and remove reference from regionserver package later. | 
| (package private) boolean | runningThis flag is used to indicate to sub threads when they should go down. | 
| 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 | 
| (package private) boolean | startedThis flag is set to true after all threads are up and 'running' and the server is then opened
 for business by the call to  RpcServerInterface.start(). | 
| 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,
         org.apache.hadoop.hbase.shaded.protobuf.generated.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. | 
| private static int | channelIO(ReadableByteChannel readCh,
         WritableByteChannel writeCh,
         ByteBuffer buf) | 
| protected int | channelRead(ReadableByteChannel channel,
           ByteBuffer buffer)This is a wrapper around  ReadableByteChannel.read(java.nio.ByteBuffer). | 
| protected AuthenticationTokenSecretManager | createSecretManager() | 
| ByteBuffAllocator | getByteBuffAllocator()Allocator to allocate/free the ByteBuffers, those ByteBuffers can be on-heap or off-heap. | 
| (package private) org.apache.hadoop.conf.Configuration | getConf() | 
| 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() | 
| (package private) void | logResponse(org.apache.hbase.thirdparty.com.google.protobuf.Message param,
           String methodName,
           String call,
           boolean tooLarge,
           boolean tooSlow,
           String clientAddress,
           long startTime,
           int processingTime,
           int qTime,
           long responseSize,
           String userName)Logs an RPC response to the LOG file, producing valid JSON objects for
 client Operations. | 
| void | onConfigurationChange(org.apache.hadoop.conf.Configuration newConf)This method would be called by the  ConfigurationManagerobject when theConfigurationobject is reloaded from disk. | 
| void | refreshAuthManager(org.apache.hadoop.conf.Configuration conf,
                  org.apache.hadoop.security.authorize.PolicyProvider pp)Refresh authentication manager policy. | 
| static void | setCurrentCall(RpcCall rpcCall)Used by  RegionProcedureStore. | 
| void | setErrorHandler(HBaseRPCErrorHandler handler)Set the handler for calling out of RPC for error conditions. | 
| void | setNamedQueueRecorder(NamedQueueRecorder namedQueueRecorder)Set Online SlowLog Provider | 
| void | setRsRpcServices(RSRpcServices rsRpcServices) | 
| void | setSecretManager(org.apache.hadoop.security.token.SecretManager<? extends org.apache.hadoop.security.token.TokenIdentifier> secretManager) | 
| (package private) String | truncateTraceLog(String strParam)Truncate to number of chars decided by conf hbase.ipc.trace.log.max.length
 if TRACE is on else to 150 chars Refer to Jira HBASE-20826 and HBASE-20942 | 
| static Optional<RpcCall> | unsetCurrentCall()Used by  RegionProcedureStore. | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcall, call, getListenerAddress, join, setSocketSendBufSize, start, stoppublic static final org.slf4j.Logger LOG
protected static final CallQueueTooBigException CALL_QUEUE_TOO_BIG_EXCEPTION
private static final String MULTI_GETS
private static final String MULTI_MUTATIONS
private static final String MULTI_SERVICE_CALLS
private final boolean authorize
private final boolean isOnlineLogProviderEnabled
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 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_SIZEprotected static final int DEFAULT_MAX_CALLQUEUE_SIZE
protected final LongAdder callQueueSizeInBytes
protected final boolean tcpNoDelay
protected final boolean tcpKeepAlive
volatile boolean running
RpcServerInterface.start(), all threads started will consult this flag on whether they should
 keep going.  It is set to false when RpcServerInterface.stop() is called.volatile boolean started
RpcServerInterface.start().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 org.apache.hbase.thirdparty.com.google.gson.Gson GSON
protected final int maxRequestSize
protected final int warnResponseTime
protected final int warnResponseSize
protected final int minClientRequestTimeout
protected final List<RpcServer.BlockingServiceAndInterface> services
protected final RpcScheduler scheduler
protected UserProvider userProvider
protected final ByteBuffAllocator bbAllocator
protected volatile boolean allowFallbackToSimpleAuth
private RSRpcServices rsRpcServices
private NamedQueueRecorder namedQueueRecorder
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.IOExceptionpublic void onConfigurationChange(org.apache.hadoop.conf.Configuration newConf)
ConfigurationObserverConfigurationManager
 object when the Configuration object is reloaded from disk.onConfigurationChange in interface ConfigurationObserverprotected void initReconfigurable(org.apache.hadoop.conf.Configuration confToLoad)
org.apache.hadoop.conf.Configuration getConf()
public boolean isStarted()
isStarted in interface RpcServerInterfacepublic void refreshAuthManager(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.security.authorize.PolicyProvider pp)
RpcServerInterfacerefreshAuthManager in interface RpcServerInterfaceprotected 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 RpcServerInterfaceIOExceptionvoid logResponse(org.apache.hbase.thirdparty.com.google.protobuf.Message param, String methodName, String call, boolean tooLarge, boolean tooSlow, String clientAddress, long startTime, int processingTime, int qTime, long responseSize, String userName)
param - The parameters received in the call.methodName - The name of the method invokedcall - The string representation of the calltooLarge - To indicate if the event is tooLargetooSlow - To indicate if the event is tooSlowclientAddress - The address of the client who made this call.startTime - The time that the call was initiated, in ms.processingTime - The duration that the call took to run, in ms.qTime - The duration that the call spent on the queue
   prior to being initiated, in ms.responseSize - The size in bytes of the response buffer.userName - UserName of the current RPC CallString truncateTraceLog(String strParam)
strParam - stringifiedParam to be truncatedpublic void setErrorHandler(HBaseRPCErrorHandler handler)
setErrorHandler in interface RpcServerInterfacehandler - the handler implementationpublic HBaseRPCErrorHandler getErrorHandler()
getErrorHandler in interface RpcServerInterfacepublic MetricsHBaseServer getMetrics()
getMetrics in interface RpcServerInterfacepublic void addCallSize(long diff)
RpcServerInterfaceaddCallSize in interface RpcServerInterfacediff - Change (plus or minus)public void authorize(org.apache.hadoop.security.UserGroupInformation user, org.apache.hadoop.hbase.shaded.protobuf.generated.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)private static int channelIO(ReadableByteChannel readCh, WritableByteChannel writeCh, ByteBuffer buf) throws IOException
channelRead(java.nio.channels.ReadableByteChannel, java.nio.ByteBuffer).
 Only one of readCh or writeCh should be non-null.readCh - read channelwriteCh - write channelbuf - buffer to read or write into/out ofIOException - echannelRead(java.nio.channels.ReadableByteChannel, java.nio.ByteBuffer)public static Optional<RpcCall> getCurrentCall()
public static boolean isInRpcCallContext()
public static Optional<RpcCall> unsetCurrentCall()
RegionProcedureStore. For
 master's rpc call, it may generate new procedure and mutate the region which store procedure.
 There are some check about rpc when mutate region, such as rpc timeout check. So unset the rpc
 call to avoid the rpc check.public static void setCurrentCall(RpcCall rpcCall)
RegionProcedureStore. Set the
 rpc call back after mutate region.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.serviceNameprotected 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.serviceNameprotected static MonitoredRPCHandler getStatus()
public static InetAddress getRemoteIp()
public RpcScheduler getScheduler()
getScheduler in interface RpcServerInterfacepublic ByteBuffAllocator getByteBuffAllocator()
RpcServerInterfacegetByteBuffAllocator in interface RpcServerInterfacepublic void setRsRpcServices(RSRpcServices rsRpcServices)
setRsRpcServices in interface RpcServerInterfacepublic void setNamedQueueRecorder(NamedQueueRecorder namedQueueRecorder)
RpcServerInterfacesetNamedQueueRecorder in interface RpcServerInterfacenamedQueueRecorder - instance of NamedQueueRecorderCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.