RpcProgramNfs3 extends RpcProgram implements Nfs3Interface { @Override public COMMIT3Response commit(XDR xdr, RpcInfo info) { SecurityHandler securityHandler = getSecurityHandler(info); RpcCall rpcCall = (RpcCall) info.header(); int xid = rpcCall.getXid(); SocketAddress remoteAddress = info.remoteAddress(); return commit(xdr, info.channel(), xid, securityHandler, remoteAddress); } RpcProgramNfs3(NfsConfiguration config, DatagramSocket registrationSocket,
      boolean allowInsecurePorts); static RpcProgramNfs3 createRpcProgramNfs3(NfsConfiguration config,
      DatagramSocket registrationSocket, boolean allowInsecurePorts); @Override void startDaemons(); @Override void stopDaemons(); @Override NFS3Response nullProcedure(); @Override GETATTR3Response getattr(XDR xdr, RpcInfo info); @Override SETATTR3Response setattr(XDR xdr, RpcInfo info); @Override LOOKUP3Response lookup(XDR xdr, RpcInfo info); @Override ACCESS3Response access(XDR xdr, RpcInfo info); @Override READLINK3Response readlink(XDR xdr, RpcInfo info); @Override READ3Response read(XDR xdr, RpcInfo info); @Override WRITE3Response write(XDR xdr, RpcInfo info); @Override CREATE3Response create(XDR xdr, RpcInfo info); @Override MKDIR3Response mkdir(XDR xdr, RpcInfo info); @Override READDIR3Response mknod(XDR xdr, RpcInfo info); @Override REMOVE3Response remove(XDR xdr, RpcInfo info); @Override RMDIR3Response rmdir(XDR xdr, RpcInfo info); @Override RENAME3Response rename(XDR xdr, RpcInfo info); @Override SYMLINK3Response symlink(XDR xdr, RpcInfo info); @Override READDIR3Response link(XDR xdr, RpcInfo info); @Override READDIR3Response readdir(XDR xdr, RpcInfo info); READDIR3Response readdir(XDR xdr, SecurityHandler securityHandler,
      SocketAddress remoteAddress); @Override READDIRPLUS3Response readdirplus(XDR xdr, RpcInfo info); @Override FSSTAT3Response fsstat(XDR xdr, RpcInfo info); @Override FSINFO3Response fsinfo(XDR xdr, RpcInfo info); @Override PATHCONF3Response pathconf(XDR xdr, RpcInfo info); @Override COMMIT3Response commit(XDR xdr, RpcInfo info); @Override void handleInternal(ChannelHandlerContext ctx, RpcInfo info); static final int DEFAULT_UMASK; static final FsPermission umask; }
@Test(timeout = 120000) public void testEncryptedReadWrite() throws Exception { final int len = 8192; final Path zone = new Path("/zone"); hdfs.mkdirs(zone); dfsAdmin.createEncryptionZone(zone, TEST_KEY, NO_TRASH); final byte[] buffer = new byte[len]; for (int i = 0; i < len; i++) { buffer[i] = (byte) i; } final String encFile1 = "/zone/myfile"; createFileUsingNfs(encFile1, buffer); commit(encFile1, len); assertArrayEquals("encFile1 not equal", getFileContentsUsingNfs(encFile1, len), getFileContentsUsingDfs(encFile1, len)); final String encFile2 = "/zone/myfile2"; final Path encFile2Path = new Path(encFile2); DFSTestUtil.createFile(hdfs, encFile2Path, len, (short) 1, 0xFEED); assertArrayEquals("encFile2 not equal", getFileContentsUsingNfs(encFile2, len), getFileContentsUsingDfs(encFile2, len)); }
@Test(timeout = 60000) public void testCommit() throws Exception { HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar"); long dirId = status.getFileId(); int namenodeId = Nfs3Utils.getNamenodeId(config); FileHandle handle = new FileHandle(dirId, namenodeId); XDR xdr_req = new XDR(); COMMIT3Request req = new COMMIT3Request(handle, 0, 5); req.serialize(xdr_req); Channel ch = Mockito.mock(Channel.class); COMMIT3Response response1 = nfsd.commit(xdr_req.asReadOnlyWrap(), ch, 1, securityHandlerUnpriviledged, new InetSocketAddress("localhost", 1234)); assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES, response1.getStatus()); COMMIT3Response response2 = nfsd.commit(xdr_req.asReadOnlyWrap(), ch, 1, securityHandler, new InetSocketAddress("localhost", 1234)); assertEquals("Incorrect COMMIT3Response:", null, response2); }