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
限定符和类型 | 类和说明 |
---|---|
class |
Server.Connection
Reads calls from a connection and queues them for handling.
|
限定符和类型 | 字段和说明 |
---|---|
static byte |
CURRENT_VERSION |
static ByteBuffer |
HEADER
The first four bytes of Hadoop RPC connections
|
static org.apache.commons.logging.Log |
LOG |
protected RpcInstrumentation |
rpcMetrics |
限定符 | 构造器和说明 |
---|---|
protected |
Server(String bindAddress,
int port,
Class<? extends Writable> paramClass,
int handlerCount,
Configuration conf) |
protected |
Server(String bindAddress,
int port,
Class<? extends Writable> paramClass,
int handlerCount,
Configuration conf,
String serverName) |
protected |
Server(String bindAddress,
int port,
Class<? extends Writable> paramClass,
int handlerCount,
Configuration conf,
String serverName,
SecretManager<? extends TokenIdentifier> secretManager)
Constructs a server listening on the named port and address.
|
限定符和类型 | 方法和说明 |
---|---|
void |
addTerseExceptions(Class<?>... exceptionClass) |
void |
authorize(UserGroupInformation user,
org.apache.hadoop.ipc.ConnectionHeader connection,
InetAddress addr)
Authorize the incoming client connection.
|
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.
|
abstract Writable |
call(Class<?> protocol,
Writable param,
long receiveTime)
Called for each call.
|
Writable |
call(Writable param,
long receiveTime)
已过时。
Use
call(Class, Writable, long) instead |
static Server |
get()
Returns the server instance called under or null.
|
int |
getCallQueueLen()
The number of rpc calls in the queue.
|
InetSocketAddress |
getListenerAddress()
Return the socket (ip+port) on which the RPC server is listening to.
|
int |
getNumOpenConnections()
The number of open RPC conections
|
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.
|
RpcInstrumentation |
getRpcMetrics()
Returns a handle to the rpcMetrics (required in tests)
|
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.
|
public static final ByteBuffer HEADER
public static final byte CURRENT_VERSION
public static final org.apache.commons.logging.Log LOG
protected RpcInstrumentation rpcMetrics
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> paramClass, int handlerCount, Configuration conf, String serverName) throws IOException
IOException
protected Server(String bindAddress, int port, Class<? extends Writable> paramClass, int handlerCount, Configuration conf, String serverName, SecretManager<? extends TokenIdentifier> secretManager) throws IOException
handlerCount determines
the number of handler threads that will be used to process calls.
IOException
public void addTerseExceptions(Class<?>... exceptionClass)
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 InetAddress getRemoteIp()
public static String getRemoteAddress()
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 RpcInstrumentation getRpcMetrics()
public void setSocketSendBufSize(int size)
public void start()
public void stop()
public void join() throws InterruptedException
stop()
.public InetSocketAddress getListenerAddress()
@Deprecated public Writable call(Writable param, long receiveTime) throws IOException
call(Class, Writable, long)
insteadIOException
public abstract Writable call(Class<?> protocol, Writable param, long receiveTime) throws IOException
IOException
public void authorize(UserGroupInformation user, org.apache.hadoop.ipc.ConnectionHeader connection, InetAddress addr) throws AuthorizationException
user
- client userconnection
- incoming connectionaddr
- InetAddress of incoming connectionAuthorizationException
- when the client isn't authorized to talk the protocolpublic int getNumOpenConnections()
public int getCallQueueLen()
Copyright © 2009 The Apache Software Foundation