org.apache.hadoop.oncrpc
Class RpcProgram

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by org.apache.hadoop.oncrpc.RpcProgram
All Implemented Interfaces:
org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public abstract class RpcProgram
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler

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


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Field Summary
protected  boolean allowInsecurePorts
           
static int RPCB_PORT
           
 
Constructor Summary
protected RpcProgram(String program, String host, int port, int progNumber, int lowProgVersion, int highProgVersion, DatagramSocket registrationSocket, boolean allowInsecurePorts)
          Constructor
 
Method Summary
 boolean doPortMonitoring(SocketAddress remoteAddress)
           
 int getPort()
           
protected abstract  void handleInternal(org.jboss.netty.channel.ChannelHandlerContext ctx, RpcInfo info)
           
protected abstract  boolean isIdempotent(RpcCall call)
           
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent e)
           
 void register(int transport, int boundPort)
          Register this program with the local portmapper.
protected  void register(PortmapMapping mapEntry, boolean set)
          Register the program with Portmap or Rpcbind
protected static void sendRejectedReply(RpcCall call, SocketAddress remoteAddress, org.jboss.netty.channel.ChannelHandlerContext ctx)
           
 void startDaemons()
           
 void stopDaemons()
           
 String toString()
           
 void unregister(int transport, int boundPort)
          Unregister this program with the local portmapper.
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, exceptionCaught, handleUpstream, writeComplete
 
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

allowInsecurePorts

protected final boolean allowInsecurePorts
Constructor Detail

RpcProgram

protected RpcProgram(String program,
                     String host,
                     int port,
                     int progNumber,
                     int lowProgVersion,
                     int highProgVersion,
                     DatagramSocket registrationSocket,
                     boolean allowInsecurePorts)
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
DatagramSocket - registrationSocket if not null, use this socket to register with portmap daemon
allowInsecurePorts - true to allow client connections from unprivileged ports, false otherwise
Method Detail

register

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


unregister

public void unregister(int transport,
                       int boundPort)
Unregister this program with the local portmapper.


register

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


startDaemons

public void startDaemons()

stopDaemons

public void stopDaemons()

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.MessageEvent e)
                     throws Exception
Overrides:
messageReceived in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception

doPortMonitoring

public boolean doPortMonitoring(SocketAddress remoteAddress)

sendRejectedReply

protected static void sendRejectedReply(RpcCall call,
                                        SocketAddress remoteAddress,
                                        org.jboss.netty.channel.ChannelHandlerContext ctx)

handleInternal

protected abstract void handleInternal(org.jboss.netty.channel.ChannelHandlerContext ctx,
                                       RpcInfo info)

toString

public String toString()
Overrides:
toString in class Object

isIdempotent

protected abstract boolean isIdempotent(RpcCall call)

getPort

public int getPort()


Copyright © 2014 Apache Software Foundation. All Rights Reserved.