com.nhncorp.neptune.common.ipc
Class NServer

java.lang.Object
  extended by com.nhncorp.neptune.common.ipc.NServer
Direct Known Subclasses:
NRPC.Server

public abstract class NServer
extends java.lang.Object

An abstract IPC service. IPC calls take a single NWritable as a parameter, and return a NWritable 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:
NClient

Field Summary
static java.nio.ByteBuffer HEADER
          The first four bytes of Hadoop RPC connections
static org.apache.commons.logging.Log LOG
           
 
Method Summary
abstract  NWritable call(NWritable param)
          Called for each call.
static NServer get()
          Returns the server instance called under or null.
 java.net.InetSocketAddress getListenerAddress()
          Return the socket (ip+port) on which the RPC server is listening to.
static java.lang.String getRemoteAddress()
          Returns remote address as a string when invoked inside an RPC.
static java.net.InetAddress getRemoteIp()
          Returns the remote side ip address when invoked inside an RPC Returns null incase of an error.
 void join()
          Wait for the server to be stopped.
 void start()
          Starts the service.
 void stop()
          Stops the service.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER

public static final java.nio.ByteBuffer HEADER
The first four bytes of Hadoop RPC connections


LOG

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

get

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


getRemoteIp

public static java.net.InetAddress getRemoteIp()
Returns the remote side ip address when invoked inside an RPC Returns null incase of an error.


getRemoteAddress

public static java.lang.String getRemoteAddress()
Returns remote address as a string when invoked inside an RPC. Returns null in case of an error.


start

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

Throws:
java.io.IOException

stop

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


join

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

Throws:
java.lang.InterruptedException

getListenerAddress

public java.net.InetSocketAddress getListenerAddress()
Return the socket (ip+port) on which the RPC server is listening to.

Returns:
the socket (ip+port) on which the RPC server is listening to.

call

public abstract NWritable call(NWritable param)
                        throws java.io.IOException
Called for each call.

Throws:
java.io.IOException