import org.apache.hadoop.oncrpc.RpcReply; //导入依赖的package包/类
@Override
public XDR handleInternal(RpcCall rpcCall, final XDR xdr, XDR out,
InetAddress client, Channel channel) {
int procedure = rpcCall.getProcedure();
int xid = rpcCall.getXid();
RpcAuthSys authSys = null;
// Ignore auth only for NFSPROC3_NULL, especially for Linux clients.
if (procedure != Nfs3Constant.NFSPROC3_NULL) {
if (rpcCall.getCredential().getFlavor() != AuthFlavor.AUTH_SYS) {
LOG.info("Wrong RPC AUTH flavor, "
+ rpcCall.getCredential().getFlavor() + " is not AUTH_SYS.");
XDR reply = new XDR();
reply = RpcDeniedReply.voidReply(reply, xid,
RpcReply.ReplyState.MSG_ACCEPTED,
RpcDeniedReply.RejectState.AUTH_ERROR);
return reply;
}
authSys = RpcAuthSys.from(rpcCall.getCredential().getBody());
}
NFS3Response response = null;
if (procedure == Nfs3Constant.NFSPROC3_NULL) {
response = nullProcedure();
} else if (procedure == Nfs3Constant.NFSPROC3_GETATTR) {
response = getattr(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_SETATTR) {
response = setattr(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_LOOKUP) {
response = lookup(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_ACCESS) {
response = access(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_READLINK) {
response = readlink(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_READ) {
response = read(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_WRITE) {
response = write(xdr, channel, xid, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_CREATE) {
response = create(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_MKDIR) {
response = mkdir(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_SYMLINK) {
response = symlink(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_MKNOD) {
response = mknod(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_REMOVE) {
response = remove(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_RMDIR) {
response = rmdir(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_RENAME) {
response = rename(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_LINK) {
response = link(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_READDIR) {
response = readdir(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_READDIRPLUS) {
response = readdirplus(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_FSSTAT) {
response = fsstat(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_FSINFO) {
response = fsinfo(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_PATHCONF) {
response = pathconf(xdr, authSys);
} else if (procedure == Nfs3Constant.NFSPROC3_COMMIT) {
response = commit(xdr, authSys);
} else {
// Invalid procedure
RpcAcceptedReply.voidReply(out, xid,
RpcAcceptedReply.AcceptState.PROC_UNAVAIL);
}
if (response != null) {
out = response.send(out, xid);
}
return out;
}
请发表评论