public abstract class Server extends 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 and Description |
---|---|
static class |
Server.AuthProtocol |
static class |
Server.Call
A call queued for handling.
|
class |
Server.Connection
Reads calls from a connection and queues them for handling.
|
Modifier and Type | Field and Description |
---|---|
static org.apache.commons.logging.Log |
AUDITLOG |
static org.apache.commons.logging.Log |
LOG |
protected RpcDetailedMetrics |
rpcDetailedMetrics |
protected RpcMetrics |
rpcMetrics |
Modifier | Constructor and Description |
---|---|
protected |
Server(String bindAddress,
int port,
Class<? extends Writable> paramClass,
int handlerCount,
Configuration conf) |
protected |
Server(String bindAddress,
int port,
Class<? extends Writable> rpcRequestClass,
int handlerCount,
int numReaders,
int queueSizePerHandler,
Configuration conf,
String serverName,
SecretManager<? extends TokenIdentifier> secretManager) |
protected |
Server(String bindAddress,
int port,
Class<? extends Writable> rpcRequestClass,
int handlerCount,
int numReaders,
int queueSizePerHandler,
Configuration conf,
String serverName,
SecretManager<? extends TokenIdentifier> secretManager,
String portRangeConfig)
Constructs a server listening on the named port and address.
|
Modifier and Type | Method and Description |
---|---|
void |
addTerseExceptions(Class<?>... exceptionClass) |
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.
|
static void |
bind(ServerSocket socket,
InetSocketAddress address,
int backlog,
Configuration conf,
String rangeConf) |
abstract Writable |
call(RPC.RpcKind rpcKind,
String protocol,
Writable param,
long receiveTime)
Called for each call.
|
Writable |
call(Writable param,
long receiveTime)
Deprecated.
Use
#call(RpcPayloadHeader.RpcKind, String,
Writable, long) instead |
static Server |
get()
Returns the server instance called under or null.
|
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()
Returns the clientId from the current RPC request
|
static ThreadLocal<Server.Call> |
getCurCall()
Get the current call
|
InetSocketAddress |
getListenerAddress()
Return the socket (ip+port) on which the RPC server is listening to.
|
int |
getMaxQueueSize()
The maximum size of the rpc call queue of this server.
|
int |
getNumOpenConnections()
The number of open RPC conections
|
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 String |
getRemoteAddress()
Returns remote address as a string when invoked inside an RPC.
|
static InetAddress |
getRemoteIp()
Returns the remote side ip address when invoked inside an RPC
Returns null incase of an error.
|
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)
|
Class<? extends Writable> |
getRpcRequestWrapper(RpcHeaderProtos.RpcKindProto rpcKind) |
ServiceAuthorizationManager |
getServiceAuthorizationManager()
Returns a handle to the serviceAuthorizationManager (required in tests)
|
static boolean |
isRpcInvocation()
Return true if the invocation was through an RPC.
|
void |
join()
Wait for the server to be stopped.
|
void |
refreshServiceAcl(Configuration conf,
PolicyProvider provider)
Refresh the service authorization ACL for the service handled by this server.
|
static void |
registerProtocolEngine(RPC.RpcKind rpcKind,
Class<? extends Writable> rpcRequestWrapperClass,
org.apache.hadoop.ipc.RPC.RpcInvoker rpcInvoker)
Register a RPC kind and the class to deserialize the rpc request.
|
void |
setSocketSendBufSize(int size)
Sets the socket buffer size used for responding to RPCs
|
void |
start()
Starts the service.
|
void |
stop()
Stops the service.
|
public static final org.apache.commons.logging.Log LOG
public static final org.apache.commons.logging.Log AUDITLOG
protected RpcMetrics rpcMetrics
protected RpcDetailedMetrics rpcDetailedMetrics
protected Server(String bindAddress, int port, Class<? extends Writable> paramClass, int handlerCount, Configuration conf) throws IOException
IOException
protected Server(String bindAddress, int port, Class<? extends Writable> rpcRequestClass, int handlerCount, int numReaders, int queueSizePerHandler, Configuration conf, String serverName, SecretManager<? extends TokenIdentifier> secretManager) throws IOException
IOException
protected Server(String bindAddress, int port, Class<? extends Writable> rpcRequestClass, int handlerCount, int numReaders, int queueSizePerHandler, Configuration conf, String serverName, SecretManager<? extends TokenIdentifier> secretManager, String portRangeConfig) throws 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(RpcPayloadHeader.RpcKind,
Class, RPC.RpcInvoker)
This parameter has been retained for compatibility with existing tests
and usage.
IOException
public void addTerseExceptions(Class<?>... exceptionClass)
public static void registerProtocolEngine(RPC.RpcKind rpcKind, Class<? extends Writable> rpcRequestWrapperClass, org.apache.hadoop.ipc.RPC.RpcInvoker rpcInvoker)
rpcKind
- rpcRequestWrapperClass
- - this class is used to deserialze the
the rpc request.rpcInvoker
- - use to process the calls on SS.public Class<? extends Writable> getRpcRequestWrapper(RpcHeaderProtos.RpcKindProto 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.public static ThreadLocal<Server.Call> getCurCall()
public static int getCallId()
public static int getCallRetryCount()
public static InetAddress getRemoteIp()
public static byte[] getClientId()
public static String getRemoteAddress()
public static UserGroupInformation getRemoteUser()
public static boolean isRpcInvocation()
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 static void bind(ServerSocket socket, InetSocketAddress address, int backlog, Configuration conf, String rangeConf) throws IOException
IOException
public RpcMetrics getRpcMetrics()
public RpcDetailedMetrics getRpcDetailedMetrics()
public void refreshServiceAcl(Configuration conf, PolicyProvider provider)
@InterfaceAudience.LimitedPrivate(value={"HDFS","MapReduce"}) public ServiceAuthorizationManager getServiceAuthorizationManager()
public void setSocketSendBufSize(int size)
public void start()
public void stop()
public void join() throws InterruptedException
stop()
.InterruptedException
public InetSocketAddress getListenerAddress()
@Deprecated public Writable call(Writable param, long receiveTime) throws Exception
#call(RpcPayloadHeader.RpcKind, String,
Writable, long)
insteadException
public abstract Writable call(RPC.RpcKind rpcKind, String protocol, Writable param, long receiveTime) throws Exception
Exception
public int getPort()
public int getNumOpenConnections()
public int getCallQueueLen()
public int getMaxQueueSize()
public int getNumReaders()
Copyright © 2013 Apache Software Foundation. All rights reserved.