Search in sources :

Example 1 with RpcInfo

use of org.apache.hadoop.oncrpc.RpcInfo in project hadoop by apache.

the class RpcProgramPortmap method messageReceived.

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    RpcInfo info = (RpcInfo) e.getMessage();
    RpcCall rpcCall = (RpcCall) info.header();
    final int portmapProc = rpcCall.getProcedure();
    int xid = rpcCall.getXid();
    XDR in = new XDR(info.data().toByteBuffer().asReadOnlyBuffer(), XDR.State.READING);
    XDR out = new XDR();
    if (portmapProc == PMAPPROC_NULL) {
        out = nullOp(xid, in, out);
    } else if (portmapProc == PMAPPROC_SET) {
        out = set(xid, in, out);
    } else if (portmapProc == PMAPPROC_UNSET) {
        out = unset(xid, in, out);
    } else if (portmapProc == PMAPPROC_DUMP) {
        out = dump(xid, in, out);
    } else if (portmapProc == PMAPPROC_GETPORT) {
        out = getport(xid, in, out);
    } else if (portmapProc == PMAPPROC_GETVERSADDR) {
        out = getport(xid, in, out);
    } else {
        LOG.info("PortmapHandler unknown rpc procedure=" + portmapProc);
        RpcAcceptedReply reply = RpcAcceptedReply.getInstance(xid, RpcAcceptedReply.AcceptState.PROC_UNAVAIL, new VerifierNone());
        reply.write(out);
    }
    ChannelBuffer buf = ChannelBuffers.wrappedBuffer(out.asReadOnlyWrap().buffer());
    RpcResponse rsp = new RpcResponse(buf, info.remoteAddress());
    RpcUtil.sendRpcResponse(ctx, rsp);
}
Also used : RpcInfo(org.apache.hadoop.oncrpc.RpcInfo) RpcCall(org.apache.hadoop.oncrpc.RpcCall) XDR(org.apache.hadoop.oncrpc.XDR) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) RpcAcceptedReply(org.apache.hadoop.oncrpc.RpcAcceptedReply) RpcResponse(org.apache.hadoop.oncrpc.RpcResponse) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Aggregations

RpcAcceptedReply (org.apache.hadoop.oncrpc.RpcAcceptedReply)1 RpcCall (org.apache.hadoop.oncrpc.RpcCall)1 RpcInfo (org.apache.hadoop.oncrpc.RpcInfo)1 RpcResponse (org.apache.hadoop.oncrpc.RpcResponse)1 XDR (org.apache.hadoop.oncrpc.XDR)1 VerifierNone (org.apache.hadoop.oncrpc.security.VerifierNone)1 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)1