Package org.apache.hadoop.oncrpc
Class RpcProgram
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.apache.hadoop.oncrpc.RpcProgram
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public abstract class RpcProgram
extends io.netty.channel.ChannelInboundHandlerAdapter
Class for writing RPC server programs based on RFC 1050. Extend this class
and implement
handleInternal(io.netty.channel.ChannelHandlerContext, org.apache.hadoop.oncrpc.RpcInfo) to handle the requests received.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanstatic final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRpcProgram(String program, String host, int port, int progNumber, int lowProgVersion, int highProgVersion, DatagramSocket registrationSocket, boolean allowInsecurePorts) protectedRpcProgram(String program, String host, int port, int progNumber, int lowProgVersion, int highProgVersion, DatagramSocket registrationSocket, boolean allowInsecurePorts, int portmapUdpTimeoutMillis) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) booleandoPortMonitoring(SocketAddress remoteAddress) intgetPort()intprotected abstract voidhandleInternal(io.netty.channel.ChannelHandlerContext ctx, RpcInfo info) protected abstract booleanisIdempotent(RpcCall call) voidregister(int transport, int boundPort) Register this program with the local portmapper.protected voidregister(PortmapMapping mapEntry, boolean set) Register the program with Portmap or Rpcbind.protected static voidsendRejectedReply(RpcCall call, SocketAddress remoteAddress, io.netty.channel.ChannelHandlerContext ctx) voidvoidtoString()voidunregister(int transport, int boundPort) Unregister this program with the local portmapper.Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
RPCB_PORT
public static final int RPCB_PORT- See Also:
-
allowInsecurePorts
protected final boolean allowInsecurePorts
-
-
Constructor Details
-
RpcProgram
protected RpcProgram(String program, String host, int port, int progNumber, int lowProgVersion, int highProgVersion, DatagramSocket registrationSocket, boolean allowInsecurePorts) -
RpcProgram
protected RpcProgram(String program, String host, int port, int progNumber, int lowProgVersion, int highProgVersion, DatagramSocket registrationSocket, boolean allowInsecurePorts, int portmapUdpTimeoutMillis) Constructor- Parameters:
program- program namehost- host where the Rpc server program is startedport- port where the Rpc server program is listening toprogNumber- program number as defined in RFC 1050lowProgVersion- lowest version of the specification supportedhighProgVersion- highest version of the specification supportedregistrationSocket- if not null, use this socket to register with portmap daemonallowInsecurePorts- true to allow client connections from unprivileged ports, false otherwiseportmapUdpTimeoutMillis- timeout in milliseconds for RPC connection
-
-
Method Details
-
register
public void register(int transport, int boundPort) Register this program with the local portmapper.- Parameters:
transport- transport layer for port mapboundPort- port number of bounded RPC program
-
unregister
public void unregister(int transport, int boundPort) Unregister this program with the local portmapper.- Parameters:
transport- transport layer for port mapboundPort- port number of bounded RPC program
-
register
Register the program with Portmap or Rpcbind.- Parameters:
mapEntry- port map entriesset- specifies registration or not
-
startDaemons
public void startDaemons() -
stopDaemons
public void stopDaemons() -
channelRead
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
doPortMonitoring
-
sendRejectedReply
protected static void sendRejectedReply(RpcCall call, SocketAddress remoteAddress, io.netty.channel.ChannelHandlerContext ctx) -
handleInternal
-
toString
-
isIdempotent
-
getPort
public int getPort() -
getPortmapUdpTimeoutMillis
@VisibleForTesting public int getPortmapUdpTimeoutMillis()
-