use of org.apache.hadoop.nfs.nfs3.response.READDIRPLUS3Response.EntryPlus3 in project hadoop by apache.
the class READDIRPLUS3Response method serialize.
@Override
public XDR serialize(XDR out, int xid, Verifier verifier) {
super.serialize(out, xid, verifier);
// attributes follow
out.writeBoolean(true);
if (postOpDirAttr == null) {
postOpDirAttr = new Nfs3FileAttributes();
}
postOpDirAttr.serialize(out);
if (getStatus() == Nfs3Status.NFS3_OK) {
out.writeLongAsHyper(cookieVerf);
for (EntryPlus3 f : dirListPlus.getEntries()) {
// next
out.writeBoolean(true);
f.seralize(out);
}
out.writeBoolean(false);
out.writeBoolean(dirListPlus.getEof());
}
return out;
}
use of org.apache.hadoop.nfs.nfs3.response.READDIRPLUS3Response.EntryPlus3 in project hadoop by apache.
the class READDIRPLUS3Response method deserialize.
public static READDIRPLUS3Response deserialize(XDR xdr) {
int status = xdr.readInt();
xdr.readBoolean();
Nfs3FileAttributes postOpDirAttr = Nfs3FileAttributes.deserialize(xdr);
long cookieVerf = 0;
ArrayList<EntryPlus3> entries = new ArrayList<EntryPlus3>();
DirListPlus3 dirList = null;
if (status == Nfs3Status.NFS3_OK) {
cookieVerf = xdr.readHyper();
while (xdr.readBoolean()) {
EntryPlus3 e = EntryPlus3.deseralize(xdr);
entries.add(e);
}
boolean eof = xdr.readBoolean();
EntryPlus3[] allEntries = new EntryPlus3[entries.size()];
entries.toArray(allEntries);
dirList = new DirListPlus3(allEntries, eof);
}
return new READDIRPLUS3Response(status, postOpDirAttr, cookieVerf, dirList);
}
use of org.apache.hadoop.nfs.nfs3.response.READDIRPLUS3Response.EntryPlus3 in project hadoop by apache.
the class TestReaddir method testReaddirPlus.
@Test
public // Test readdirplus
void testReaddirPlus() throws IOException {
// Get inodeId of /tmp
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
long dirId = status.getFileId();
// Create related part of the XDR request
XDR xdr_req = new XDR();
FileHandle handle = new FileHandle(dirId);
handle.serialize(xdr_req);
// cookie
xdr_req.writeLongAsHyper(0);
// verifier
xdr_req.writeLongAsHyper(0);
// dirCount
xdr_req.writeInt(100);
// maxCount
xdr_req.writeInt(1000);
READDIRPLUS3Response responsePlus = nfsd.readdirplus(xdr_req.asReadOnlyWrap(), securityHandler, new InetSocketAddress("localhost", 1234));
List<EntryPlus3> direntPlus = responsePlus.getDirListPlus().getEntries();
// including dot, dotdot
assertTrue(direntPlus.size() == 5);
// Test start listing from f2
status = nn.getRpcServer().getFileInfo(testdir + "/f2");
long f2Id = status.getFileId();
// Create related part of the XDR request
xdr_req = new XDR();
handle = new FileHandle(dirId);
handle.serialize(xdr_req);
// cookie
xdr_req.writeLongAsHyper(f2Id);
// verifier
xdr_req.writeLongAsHyper(0);
// dirCount
xdr_req.writeInt(100);
// maxCount
xdr_req.writeInt(1000);
responsePlus = nfsd.readdirplus(xdr_req.asReadOnlyWrap(), securityHandler, new InetSocketAddress("localhost", 1234));
direntPlus = responsePlus.getDirListPlus().getEntries();
assertTrue(direntPlus.size() == 1);
EntryPlus3 entryPlus = direntPlus.get(0);
assertTrue(entryPlus.getName().equals("f3"));
// When the cookie is deleted, list starts over no including dot, dotdot
hdfs.delete(new Path(testdir + "/f2"), false);
responsePlus = nfsd.readdirplus(xdr_req.asReadOnlyWrap(), securityHandler, new InetSocketAddress("localhost", 1234));
direntPlus = responsePlus.getDirListPlus().getEntries();
// No dot, dotdot
assertTrue(direntPlus.size() == 2);
}
Aggregations