org.apache.hadoop.oncrpc
Class RpcProgram

java.lang.Object
  extended by org.apache.hadoop.oncrpc.RpcProgram
Direct Known Subclasses:
RpcProgramPortmap

public abstract class RpcProgram
extends Object

Class for writing RPC server programs based on RFC 1050. Extend this class and implement handleInternal(org.apache.hadoop.oncrpc.RpcCall, org.apache.hadoop.oncrpc.XDR, org.apache.hadoop.oncrpc.XDR, java.net.InetAddress, org.jboss.netty.channel.Channel) to handle the requests received.


Field Summary
static int RPCB_PORT
           
 
Constructor Summary
protected RpcProgram(String program, String host, int port, int progNumber, int lowProgVersion, int highProgVersion, int cacheSize)
          Constructor
 
Method Summary
 int getPort()
           
 XDR handle(XDR xdr, InetAddress client, org.jboss.netty.channel.Channel channel)
           
protected abstract  XDR handleInternal(RpcCall rpcCall, XDR in, XDR out, InetAddress client, org.jboss.netty.channel.Channel channel)
          Handle an RPC request.
protected abstract  boolean isIdempotent(RpcCall call)
           
 void register(int transport)
          Register this program with the local portmapper.
protected  void register(PortmapMapping mapEntry)
          Register the program with Portmap or Rpcbind
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RPCB_PORT

public static final int RPCB_PORT
See Also:
Constant Field Values
Constructor Detail

RpcProgram

protected RpcProgram(String program,
                     String host,
                     int port,
                     int progNumber,
                     int lowProgVersion,
                     int highProgVersion,
                     int cacheSize)
Constructor

Parameters:
program - program name
host - host where the Rpc server program is started
port - port where the Rpc server program is listening to
progNumber - program number as defined in RFC 1050
lowProgVersion - lowest version of the specification supported
highProgVersion - highest version of the specification supported
cacheSize - size of cache to handle duplciate requests. Size <= 0 indicates no cache.
Method Detail

register

public void register(int transport)
Register this program with the local portmapper.


register

protected void register(PortmapMapping mapEntry)
Register the program with Portmap or Rpcbind


handleInternal

protected abstract XDR handleInternal(RpcCall rpcCall,
                                      XDR in,
                                      XDR out,
                                      InetAddress client,
                                      org.jboss.netty.channel.Channel channel)
Handle an RPC request.

Parameters:
rpcCall - RPC call that is received
in - xdr with cursor at reading the remaining bytes of a method call
out - xdr output corresponding to Rpc reply
client - making the Rpc request
channel - connection over which Rpc request is received
Returns:
response xdr response

handle

public XDR handle(XDR xdr,
                  InetAddress client,
                  org.jboss.netty.channel.Channel channel)

toString

public String toString()
Overrides:
toString in class Object

isIdempotent

protected abstract boolean isIdempotent(RpcCall call)

getPort

public int getPort()


Copyright © 2009 The Apache Software Foundation