RPC.Server@Public
@Evolving
public abstract class Server
extends java.lang.Object
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.Client| Modifier and Type | Class | Description |
|---|---|---|
static class |
Server.AuthProtocol |
|
static class |
Server.Call |
A generic call queued for handling.
|
class |
Server.Connection |
Reads calls from a connection and queues them for handling.
|
| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
AUDITLOG |
|
static org.slf4j.Logger |
LOG |
|
protected RpcDetailedMetrics |
rpcDetailedMetrics |
|
protected RpcMetrics |
rpcMetrics |
| Modifier | Constructor | Description |
|---|---|---|
protected |
Server(java.lang.String bindAddress,
int port,
java.lang.Class<? extends Writable> rpcRequestClass,
int handlerCount,
int numReaders,
int queueSizePerHandler,
Configuration conf,
java.lang.String serverName,
SecretManager<? extends TokenIdentifier> secretManager) |
|
protected |
Server(java.lang.String bindAddress,
int port,
java.lang.Class<? extends Writable> rpcRequestClass,
int handlerCount,
int numReaders,
int queueSizePerHandler,
Configuration conf,
java.lang.String serverName,
SecretManager<? extends TokenIdentifier> secretManager,
java.lang.String portRangeConfig) |
Constructs a server listening on the named port and address.
|
protected |
Server(java.lang.String bindAddress,
int port,
java.lang.Class<? extends Writable> paramClass,
int handlerCount,
Configuration conf) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
addAuxiliaryListener(int auxiliaryPort) |
|
void |
addSuppressedLoggingExceptions(java.lang.Class<?>... exceptionClass) |
Add exception classes which server won't log at all.
|
void |
addTerseExceptions(java.lang.Class<?>... exceptionClass) |
Add exception classes for which server won't log stack traces.
|
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.
|
static void |
bind(java.net.ServerSocket socket,
java.net.InetSocketAddress address,
int backlog,
Configuration conf,
java.lang.String rangeConf) |
|
Writable |
call(Writable param,
long receiveTime) |
Deprecated.
Use
call(RPC.RpcKind, String,
Writable, long) instead |
abstract Writable |
call(RPC.RpcKind rpcKind,
java.lang.String protocol,
Writable param,
long receiveTime) |
Called for each call.
|
static Server |
get() |
|
java.util.Set<java.net.InetSocketAddress> |
getAuxiliaryListenerAddresses() |
Return the set of all the configured auxiliary socket addresses NameNode
RPC is listening on.
|
static java.lang.String |
getAuxiliaryPortEstablishedQOP() |
Returns the SASL qop for the current call, if the current call is
set, and the SASL negotiation is done.
|
static int |
getCallId() |
Returns the currently active RPC call's sequential ID number.
|
int |
getCallQueueLen() |
The number of rpc calls in the queue.
|
static int |
getCallRetryCount() |
|
static byte[] |
getClientId() |
|
static java.lang.ThreadLocal<Server.Call> |
getCurCall() |
|
java.net.InetSocketAddress |
getListenerAddress() |
Return the socket (ip+port) on which the RPC server is listening to.
|
long |
getLogSlowRPCThresholdTime() |
|
protected int |
getMaxIdleTime() |
|
int |
getMaxQueueSize() |
The maximum size of the rpc call queue of this server.
|
long |
getNumDroppedConnections() |
The number of RPC connections dropped due to
too many connections.
|
int |
getNumInProcessHandler() |
|
int |
getNumOpenConnections() |
The number of open RPC conections
|
java.lang.String |
getNumOpenConnectionsPerUser() |
|
int |
getNumReaders() |
The number of reader threads for this server.
|
int |
getPort() |
Get the port on which the IPC Server is listening for incoming connections.
|
static int |
getPriorityLevel() |
|
static java.lang.String |
getProtocol() |
|
long |
getPurgeIntervalNanos() |
|
static java.lang.String |
getRemoteAddress() |
|
static java.net.InetAddress |
getRemoteIp() |
|
static int |
getRemotePort() |
|
static UserGroupInformation |
getRemoteUser() |
Returns the RPC remote user when invoked inside an RPC.
|
RpcDetailedMetrics |
getRpcDetailedMetrics() |
|
static org.apache.hadoop.ipc.RPC.RpcInvoker |
getRpcInvoker(RPC.RpcKind rpcKind) |
|
RpcMetrics |
getRpcMetrics() |
Returns a handle to the rpcMetrics (required in tests)
|
java.lang.Class<? extends Writable> |
getRpcRequestWrapper(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcKindProto rpcKind) |
|
java.lang.String |
getServerName() |
|
protected org.apache.hadoop.ipc.RPC.RpcInvoker |
getServerRpcInvoker(RPC.RpcKind rpcKind) |
|
ServiceAuthorizationManager |
getServiceAuthorizationManager() |
Returns a handle to the serviceAuthorizationManager (required in tests)
|
long |
getTotalRequests() |
|
long |
getTotalRequestsPerSecond() |
|
boolean |
isClientBackoffEnabled() |
|
boolean |
isLogSlowRPC() |
Checks if LogSlowRPC is set true.
|
static boolean |
isRpcInvocation() |
|
boolean |
isServerFailOverEnabled() |
|
boolean |
isServerFailOverEnabledByQueue() |
|
void |
join() |
Wait for the server to be stopped.
|
void |
queueCall(Server.Call call) |
|
void |
refreshCallQueue(Configuration conf) |
|
void |
refreshServiceAcl(Configuration conf,
PolicyProvider provider) |
Refresh the service authorization ACL for the service handled by this server.
|
void |
refreshServiceAclWithLoadedConfiguration(Configuration conf,
PolicyProvider provider) |
Refresh the service authorization ACL for the service handled by this server
using the specified Configuration.
|
static void |
registerProtocolEngine(RPC.RpcKind rpcKind,
java.lang.Class<? extends Writable> rpcRequestWrapperClass,
org.apache.hadoop.ipc.RPC.RpcInvoker rpcInvoker) |
Register a RPC kind and the class to deserialize the rpc request.
|
void |
setAlignmentContext(AlignmentContext alignmentContext) |
Set alignment context to pass state info thru RPC.
|
void |
setClientBackoffEnabled(boolean value) |
|
void |
setLogSlowRPC(boolean logSlowRPCFlag) |
Sets slow RPC flag.
|
void |
setLogSlowRPCThresholdTime(long logSlowRPCThresholdMs) |
|
void |
setSocketSendBufSize(int size) |
Sets the socket buffer size used for responding to RPCs.
|
void |
setTracer(org.apache.hadoop.tracing.Tracer t) |
|
void |
start() |
Starts the service.
|
void |
stop() |
Stops the service.
|
public static final org.slf4j.Logger LOG
public static final org.slf4j.Logger AUDITLOG
protected final RpcMetrics rpcMetrics
protected final RpcDetailedMetrics rpcDetailedMetrics
protected Server(java.lang.String bindAddress,
int port,
java.lang.Class<? extends Writable> paramClass,
int handlerCount,
Configuration conf)
throws java.io.IOException
java.io.IOExceptionprotected Server(java.lang.String bindAddress,
int port,
java.lang.Class<? extends Writable> rpcRequestClass,
int handlerCount,
int numReaders,
int queueSizePerHandler,
Configuration conf,
java.lang.String serverName,
SecretManager<? extends TokenIdentifier> secretManager)
throws java.io.IOException
java.io.IOExceptionprotected Server(java.lang.String bindAddress,
int port,
java.lang.Class<? extends Writable> rpcRequestClass,
int handlerCount,
int numReaders,
int queueSizePerHandler,
Configuration conf,
java.lang.String serverName,
SecretManager<? extends TokenIdentifier> secretManager,
java.lang.String portRangeConfig)
throws java.io.IOException
handlerCount determines
the number of handler threads that will be used to process calls.
If queueSizePerHandler or numReaders are not -1 they will be used instead of parameters
from configuration. Otherwise the configuration will be picked up.
If rpcRequestClass is null then the rpcRequestClass must have been
registered via registerProtocolEngine(RPC.RpcKind,
Class, RPC.RpcInvoker)
This parameter has been retained for compatibility with existing tests
and usage.bindAddress - input bindAddress.port - input port.rpcRequestClass - input rpcRequestClass.handlerCount - input handlerCount.numReaders - input numReaders.queueSizePerHandler - input queueSizePerHandler.conf - input Configuration.serverName - input serverName.secretManager - input secretManager.portRangeConfig - input portRangeConfig.java.io.IOException - raised on errors performing I/O.public void addTerseExceptions(java.lang.Class<?>... exceptionClass)
exceptionClass - exception classespublic void addSuppressedLoggingExceptions(java.lang.Class<?>... exceptionClass)
exceptionClass - exception classespublic void setAlignmentContext(AlignmentContext alignmentContext)
alignmentContext - alignment state contextpublic static void registerProtocolEngine(RPC.RpcKind rpcKind, java.lang.Class<? extends Writable> rpcRequestWrapperClass, org.apache.hadoop.ipc.RPC.RpcInvoker rpcInvoker)
rpcKind - - input rpcKind.rpcRequestWrapperClass - - this class is used to deserialze the
the rpc request.rpcInvoker - - use to process the calls on SS.public java.lang.Class<? extends Writable> getRpcRequestWrapper(org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcKindProto rpcKind)
protected org.apache.hadoop.ipc.RPC.RpcInvoker getServerRpcInvoker(RPC.RpcKind rpcKind)
public static org.apache.hadoop.ipc.RPC.RpcInvoker getRpcInvoker(RPC.RpcKind rpcKind)
public static Server get()
call(Writable, long) implementations, and under Writable
methods of paramters and return values. Permits applications to access
the server context.@VisibleForTesting public static java.lang.ThreadLocal<Server.Call> getCurCall()
public static int getCallId()
public static int getCallRetryCount()
public static java.net.InetAddress getRemoteIp()
public static int getRemotePort()
public static java.lang.String getAuxiliaryPortEstablishedQOP()
public static byte[] getClientId()
public static java.lang.String getRemoteAddress()
public static UserGroupInformation getRemoteUser()
public static java.lang.String getProtocol()
public static boolean isRpcInvocation()
public static int getPriorityLevel()
public boolean isLogSlowRPC()
public long getLogSlowRPCThresholdTime()
public int getNumInProcessHandler()
public long getTotalRequests()
public long getTotalRequestsPerSecond()
@VisibleForTesting public void setLogSlowRPC(boolean logSlowRPCFlag)
logSlowRPCFlag - input logSlowRPCFlag.@VisibleForTesting public void setLogSlowRPCThresholdTime(long logSlowRPCThresholdMs)
@VisibleForTesting public long getPurgeIntervalNanos()
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 queuejava.net.BindException - if the address can't be boundjava.net.UnknownHostException - if the address isn't a valid host namejava.io.IOException - other random errors from bindpublic static void bind(java.net.ServerSocket socket,
java.net.InetSocketAddress address,
int backlog,
Configuration conf,
java.lang.String rangeConf)
throws java.io.IOException
java.io.IOException@VisibleForTesting public RpcMetrics getRpcMetrics()
@VisibleForTesting public RpcDetailedMetrics getRpcDetailedMetrics()
public void refreshServiceAcl(Configuration conf, PolicyProvider provider)
conf - input Configuration.provider - input PolicyProvider.@Private public void refreshServiceAclWithLoadedConfiguration(Configuration conf, PolicyProvider provider)
conf - input Configuration.provider - input provider.@LimitedPrivate({"HDFS","MapReduce"})
public ServiceAuthorizationManager getServiceAuthorizationManager()
public void refreshCallQueue(Configuration conf)
public void queueCall(Server.Call call) throws java.io.IOException, java.lang.InterruptedException
java.io.IOExceptionjava.lang.InterruptedExceptionpublic void addAuxiliaryListener(int auxiliaryPort)
throws java.io.IOException
java.io.IOExceptionpublic void setSocketSendBufSize(int size)
size - input size.public void setTracer(org.apache.hadoop.tracing.Tracer t)
public void start()
public void stop()
public void join()
throws java.lang.InterruptedException
stop().java.lang.InterruptedException - if the thread is interrupted.public java.net.InetSocketAddress getListenerAddress()
public java.util.Set<java.net.InetSocketAddress> getAuxiliaryListenerAddresses()
@Deprecated public Writable call(Writable param, long receiveTime) throws java.lang.Exception
call(RPC.RpcKind, String,
Writable, long) insteadparam - input param.receiveTime - input receiveTime.java.lang.Exception - if any error occurs.public abstract Writable call(RPC.RpcKind rpcKind, java.lang.String protocol, Writable param, long receiveTime) throws java.lang.Exception
rpcKind - input rpcKind.protocol - input protocol.param - input param.receiveTime - input receiveTime.java.lang.Exception - raised on errors performing I/O.public int getPort()
public int getNumOpenConnections()
public java.lang.String getNumOpenConnectionsPerUser()
public long getNumDroppedConnections()
public int getCallQueueLen()
public boolean isClientBackoffEnabled()
public void setClientBackoffEnabled(boolean value)
@VisibleForTesting public boolean isServerFailOverEnabled()
@VisibleForTesting public boolean isServerFailOverEnabledByQueue()
public int getMaxQueueSize()
public int getNumReaders()
protected int getMaxIdleTime()
public java.lang.String getServerName()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.