org.apache.hadoop.ipc
Class Server

java.lang.Object
  extended by org.apache.hadoop.ipc.Server
Direct Known Subclasses:
RPC.Server

public abstract class Server
extends Object

An abstract IPC service. IPC calls take a single 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.

Author:
Doug Cutting
See Also:
Client

Field Summary
static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
protected Server(int port, Class paramClass, int handlerCount, Configuration conf)
          Deprecated. the bind address should always be specified
protected Server(String bindAddress, int port, Class paramClass, int handlerCount, Configuration conf)
          Constructs a server listening on the named port and address.
 
Method Summary
abstract  Writable call(Writable param)
          Called for each call.
static Server get()
          Returns the server instance called under or null.
 void join()
          Wait for the server to be stopped.
 void setTimeout(int timeout)
          Sets the timeout used for network i/o.
 void start()
          Starts the service.
 void stop()
          Stops the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
Constructor Detail

Server

protected Server(String bindAddress,
                 int port,
                 Class paramClass,
                 int handlerCount,
                 Configuration conf)
Constructs a server listening on the named port and address. Parameters passed must be of the named class. The handlerCount determines the number of handler threads that will be used to process calls.


Server

protected Server(int port,
                 Class paramClass,
                 int handlerCount,
                 Configuration conf)
Deprecated. the bind address should always be specified

Constructs a server listening on the named port. Parameters passed must be of the named class. The handlerCount determines the number of handler threads that will be used to process calls.

Method Detail

get

public static Server get()
Returns the server instance called under or null. May be called under call(Writable) implementations, and under Writable methods of paramters and return values. Permits applications to access the server context.


setTimeout

public void setTimeout(int timeout)
Sets the timeout used for network i/o.


start

public void start()
           throws IOException
Starts the service. Must be called before any calls will be handled.

Throws:
IOException

stop

public void stop()
Stops the service. No new calls will be handled after this is called.


join

public void join()
          throws InterruptedException
Wait for the server to be stopped. Does not wait for all subthreads to finish. See stop().

Throws:
InterruptedException

call

public abstract Writable call(Writable param)
                       throws IOException
Called for each call.

Throws:
IOException


Copyright © 2006 The Apache Software Foundation