HDFS-6894. Add XDR parser method for each NFS response. Contributed by Brandon Li.
This commit is contained in:
parent
0eec4c187c
commit
5d2f325483
|
@ -43,9 +43,21 @@ public class ACCESS3Response extends NFS3Response {
|
|||
this.access = access;
|
||||
}
|
||||
|
||||
public static ACCESS3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
Nfs3FileAttributes postOpAttr = null;
|
||||
int access = 0;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
postOpAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
access = xdr.readInt();
|
||||
}
|
||||
return new ACCESS3Response(status, postOpAttr, access);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
if (this.getStatus() == Nfs3Status.NFS3_OK) {
|
||||
out.writeBoolean(true);
|
||||
postOpAttr.serialize(out);
|
||||
|
|
|
@ -47,9 +47,19 @@ public class COMMIT3Response extends NFS3Response {
|
|||
return verf;
|
||||
}
|
||||
|
||||
public static COMMIT3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
long verf = 0;
|
||||
WccData fileWcc = WccData.deserialize(xdr);
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
verf = xdr.readHyper();
|
||||
}
|
||||
return new COMMIT3Response(status, fileWcc, verf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
fileWcc.serialize(out);
|
||||
if (getStatus() == Nfs3Status.NFS3_OK) {
|
||||
out.writeLongAsHyper(verf);
|
||||
|
|
|
@ -55,9 +55,25 @@ public class CREATE3Response extends NFS3Response {
|
|||
return dirWcc;
|
||||
}
|
||||
|
||||
public static CREATE3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
FileHandle objHandle = new FileHandle();
|
||||
Nfs3FileAttributes postOpObjAttr = null;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
xdr.readBoolean();
|
||||
objHandle.deserialize(xdr);
|
||||
xdr.readBoolean();
|
||||
postOpObjAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
}
|
||||
|
||||
WccData dirWcc = WccData.deserialize(xdr);
|
||||
return new CREATE3Response(status, objHandle, postOpObjAttr, dirWcc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
if (getStatus() == Nfs3Status.NFS3_OK) {
|
||||
out.writeBoolean(true); // Handle follows
|
||||
objHandle.serialize(out);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import org.apache.hadoop.nfs.NfsTime;
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Status;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
@ -109,9 +110,41 @@ public class FSINFO3Response extends NFS3Response {
|
|||
this.properties = properties;
|
||||
}
|
||||
|
||||
public static FSINFO3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
xdr.readBoolean();
|
||||
Nfs3FileAttributes postOpObjAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
int rtmax = 0;
|
||||
int rtpref = 0;
|
||||
int rtmult = 0;
|
||||
int wtmax = 0;
|
||||
int wtpref = 0;
|
||||
int wtmult = 0;
|
||||
int dtpref = 0;
|
||||
long maxFileSize = 0;
|
||||
NfsTime timeDelta = null;
|
||||
int properties = 0;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
rtmax = xdr.readInt();
|
||||
rtpref = xdr.readInt();
|
||||
rtmult = xdr.readInt();
|
||||
wtmax = xdr.readInt();
|
||||
wtpref = xdr.readInt();
|
||||
wtmult = xdr.readInt();
|
||||
dtpref = xdr.readInt();
|
||||
maxFileSize = xdr.readHyper();
|
||||
timeDelta = NfsTime.deserialize(xdr);
|
||||
properties = xdr.readInt();
|
||||
}
|
||||
return new FSINFO3Response(status, postOpObjAttr, rtmax, rtpref, rtmult,
|
||||
wtmax, wtpref, wtmult, dtpref, maxFileSize, timeDelta, properties);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
out.writeBoolean(true);
|
||||
postOpAttr.serialize(out);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Status;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
@ -90,9 +91,34 @@ public class FSSTAT3Response extends NFS3Response {
|
|||
this.invarsec = invarsec;
|
||||
}
|
||||
|
||||
public static FSSTAT3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
xdr.readBoolean();
|
||||
Nfs3FileAttributes postOpAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
long tbytes = 0;
|
||||
long fbytes = 0;
|
||||
long abytes = 0;
|
||||
long tfiles = 0;
|
||||
long ffiles = 0;
|
||||
long afiles = 0;
|
||||
int invarsec = 0;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
tbytes = xdr.readHyper();
|
||||
fbytes = xdr.readHyper();
|
||||
abytes = xdr.readHyper();
|
||||
tfiles = xdr.readHyper();
|
||||
ffiles = xdr.readHyper();
|
||||
afiles = xdr.readHyper();
|
||||
invarsec = xdr.readInt();
|
||||
}
|
||||
return new FSSTAT3Response(status, postOpAttr, tbytes, fbytes, abytes,
|
||||
tfiles, ffiles, afiles, invarsec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
out.writeBoolean(true);
|
||||
if (postOpAttr == null) {
|
||||
postOpAttr = new Nfs3FileAttributes();
|
||||
|
|
|
@ -40,9 +40,16 @@ public class GETATTR3Response extends NFS3Response {
|
|||
this.postOpAttr = postOpAttr;
|
||||
}
|
||||
|
||||
public static GETATTR3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
Nfs3FileAttributes attr = (status == Nfs3Status.NFS3_OK) ? Nfs3FileAttributes
|
||||
.deserialize(xdr) : new Nfs3FileAttributes();
|
||||
return new GETATTR3Response(status, attr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
if (getStatus() == Nfs3Status.NFS3_OK) {
|
||||
postOpAttr.serialize(out);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Status;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
import org.apache.hadoop.oncrpc.security.Verifier;
|
||||
|
||||
|
@ -43,9 +45,17 @@ public class LINK3Response extends NFS3Response {
|
|||
return linkDirWcc;
|
||||
}
|
||||
|
||||
public static LINK3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
WccData fromDirWcc = WccData.deserialize(xdr);
|
||||
WccData linkDirWcc = WccData.deserialize(xdr);
|
||||
return new LINK3Response(status, fromDirWcc, linkDirWcc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
fromDirWcc.serialize(out);
|
||||
linkDirWcc.serialize(out);
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ public class LOOKUP3Response extends NFS3Response {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
if (this.status == Nfs3Status.NFS3_OK) {
|
||||
fileHandle.serialize(out);
|
||||
out.writeBoolean(true); // Attribute follows
|
||||
|
|
|
@ -55,9 +55,25 @@ public class MKDIR3Response extends NFS3Response {
|
|||
return dirWcc;
|
||||
}
|
||||
|
||||
public static MKDIR3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
FileHandle objFileHandle = new FileHandle();
|
||||
Nfs3FileAttributes objAttr = null;
|
||||
WccData dirWcc;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
xdr.readBoolean();
|
||||
objFileHandle.deserialize(xdr);
|
||||
xdr.readBoolean();
|
||||
objAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
}
|
||||
dirWcc = WccData.deserialize(xdr);
|
||||
return new MKDIR3Response(status, objFileHandle, objAttr, dirWcc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
if (getStatus() == Nfs3Status.NFS3_OK) {
|
||||
out.writeBoolean(true); // Handle follows
|
||||
objFileHandle.serialize(out);
|
||||
|
|
|
@ -52,9 +52,25 @@ public class MKNOD3Response extends NFS3Response {
|
|||
return dirWcc;
|
||||
}
|
||||
|
||||
public static MKNOD3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
FileHandle objFileHandle = new FileHandle();
|
||||
Nfs3FileAttributes objPostOpAttr = null;
|
||||
WccData dirWcc;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
xdr.readBoolean();
|
||||
objFileHandle.deserialize(xdr);
|
||||
xdr.readBoolean();
|
||||
objPostOpAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
}
|
||||
dirWcc = WccData.deserialize(xdr);
|
||||
return new MKNOD3Response(status, objFileHandle, objPostOpAttr, dirWcc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
if (this.getStatus() == Nfs3Status.NFS3_OK) {
|
||||
out.writeBoolean(true);
|
||||
objFileHandle.serialize(out);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class NFS3Response {
|
|||
* Write the response, along with the rpc header (including verifier), to the
|
||||
* XDR.
|
||||
*/
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
RpcAcceptedReply reply = RpcAcceptedReply.getAcceptInstance(xid, verifier);
|
||||
reply.write(out);
|
||||
out.writeInt(this.getStatus());
|
||||
|
|
|
@ -77,9 +77,32 @@ public class PATHCONF3Response extends NFS3Response {
|
|||
this.casePreserving = casePreserving;
|
||||
}
|
||||
|
||||
public static PATHCONF3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
xdr.readBoolean();
|
||||
Nfs3FileAttributes objPostOpAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
int linkMax = 0;
|
||||
int nameMax = 0;
|
||||
boolean noTrunc = false;
|
||||
boolean chownRestricted = false;
|
||||
boolean caseInsensitive = false;
|
||||
boolean casePreserving = false;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
linkMax = xdr.readInt();
|
||||
nameMax = xdr.readInt();
|
||||
noTrunc = xdr.readBoolean();
|
||||
chownRestricted = xdr.readBoolean();
|
||||
caseInsensitive = xdr.readBoolean();
|
||||
casePreserving = xdr.readBoolean();
|
||||
}
|
||||
return new PATHCONF3Response(status, objPostOpAttr, linkMax, nameMax,
|
||||
noTrunc, chownRestricted, caseInsensitive, casePreserving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
out.writeBoolean(true);
|
||||
postOpAttr.serialize(out);
|
||||
|
||||
|
|
|
@ -62,9 +62,29 @@ public class READ3Response extends NFS3Response {
|
|||
return data;
|
||||
}
|
||||
|
||||
public static READ3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
xdr.readBoolean();
|
||||
Nfs3FileAttributes postOpAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
int count = 0;
|
||||
boolean eof = false;
|
||||
byte[] data = new byte[0];
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
count = xdr.readInt();
|
||||
eof = xdr.readBoolean();
|
||||
int len = xdr.readInt();
|
||||
assert (len == count);
|
||||
data = xdr.readFixedOpaque(count);
|
||||
}
|
||||
|
||||
return new READ3Response(status, postOpAttr, count, eof,
|
||||
ByteBuffer.wrap(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
out.writeBoolean(true); // Attribute follows
|
||||
postOpAttr.serialize(out);
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -59,6 +61,19 @@ public class READDIR3Response extends NFS3Response {
|
|||
long getCookie() {
|
||||
return cookie;
|
||||
}
|
||||
|
||||
static Entry3 deserialzie(XDR xdr) {
|
||||
long fileId = xdr.readHyper();
|
||||
String name = xdr.readString();
|
||||
long cookie = xdr.readHyper();
|
||||
return new Entry3(fileId, name, cookie);
|
||||
}
|
||||
|
||||
void seralize(XDR xdr) {
|
||||
xdr.writeLongAsHyper(getFileId());
|
||||
xdr.writeString(getName());
|
||||
xdr.writeLongAsHyper(getCookie());
|
||||
}
|
||||
}
|
||||
|
||||
public static class DirList3 {
|
||||
|
@ -104,9 +119,31 @@ public class READDIR3Response extends NFS3Response {
|
|||
return dirList;
|
||||
}
|
||||
|
||||
public static READDIR3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
xdr.readBoolean();
|
||||
Nfs3FileAttributes postOpDirAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
long cookieVerf = 0;
|
||||
ArrayList<Entry3> entries = new ArrayList<Entry3>();
|
||||
DirList3 dirList = null;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
cookieVerf = xdr.readHyper();
|
||||
while (xdr.readBoolean()) {
|
||||
Entry3 e = Entry3.deserialzie(xdr);
|
||||
entries.add(e);
|
||||
}
|
||||
boolean eof = xdr.readBoolean();
|
||||
Entry3[] allEntries = new Entry3[entries.size()];
|
||||
entries.toArray(allEntries);
|
||||
dirList = new DirList3(allEntries, eof);
|
||||
}
|
||||
return new READDIR3Response(status, postOpDirAttr, cookieVerf, dirList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR xdr, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(xdr, xid, verifier);
|
||||
public XDR serialize(XDR xdr, int xid, Verifier verifier) {
|
||||
super.serialize(xdr, xid, verifier);
|
||||
xdr.writeBoolean(true); // Attributes follow
|
||||
postOpDirAttr.serialize(xdr);
|
||||
|
||||
|
@ -114,9 +151,7 @@ public class READDIR3Response extends NFS3Response {
|
|||
xdr.writeLongAsHyper(cookieVerf);
|
||||
for (Entry3 e : dirList.entries) {
|
||||
xdr.writeBoolean(true); // Value follows
|
||||
xdr.writeLongAsHyper(e.getFileId());
|
||||
xdr.writeString(e.getName());
|
||||
xdr.writeLongAsHyper(e.getCookie());
|
||||
e.seralize(xdr);
|
||||
}
|
||||
|
||||
xdr.writeBoolean(false);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -24,6 +25,8 @@ import java.util.List;
|
|||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Status;
|
||||
import org.apache.hadoop.nfs.nfs3.response.READDIR3Response.DirList3;
|
||||
import org.apache.hadoop.nfs.nfs3.response.READDIR3Response.Entry3;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
import org.apache.hadoop.oncrpc.security.Verifier;
|
||||
|
||||
|
@ -58,6 +61,17 @@ public class READDIRPLUS3Response extends NFS3Response {
|
|||
return name;
|
||||
}
|
||||
|
||||
static EntryPlus3 deseralize(XDR xdr) {
|
||||
long fileId = xdr.readHyper();
|
||||
String name = xdr.readString();
|
||||
long cookie = xdr.readHyper();
|
||||
xdr.readBoolean();
|
||||
Nfs3FileAttributes nameAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
FileHandle objFileHandle = new FileHandle();
|
||||
objFileHandle.deserialize(xdr);
|
||||
return new EntryPlus3(fileId, name, cookie, nameAttr, objFileHandle);
|
||||
}
|
||||
|
||||
void seralize(XDR xdr) {
|
||||
xdr.writeLongAsHyper(fileId);
|
||||
xdr.writeString(name);
|
||||
|
@ -105,9 +119,31 @@ public class READDIRPLUS3Response extends NFS3Response {
|
|||
this.dirListPlus = dirListPlus;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
out.writeBoolean(true); // attributes follow
|
||||
if (postOpDirAttr == null) {
|
||||
postOpDirAttr = new Nfs3FileAttributes();
|
||||
|
|
|
@ -41,9 +41,22 @@ public class READLINK3Response extends NFS3Response {
|
|||
System.arraycopy(path, 0, this.path, 0, path.length);
|
||||
}
|
||||
|
||||
public static READLINK3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
xdr.readBoolean();
|
||||
Nfs3FileAttributes postOpSymlinkAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
byte path[] = new byte[0];
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
path = xdr.readVariableOpaque();
|
||||
}
|
||||
|
||||
return new READLINK3Response(status, postOpSymlinkAttr, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
out.writeBoolean(true); // Attribute follows
|
||||
postOpSymlinkAttr.serialize(out);
|
||||
if (getStatus() == Nfs3Status.NFS3_OK) {
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Status;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
import org.apache.hadoop.oncrpc.security.Verifier;
|
||||
|
||||
|
@ -35,9 +37,15 @@ public class REMOVE3Response extends NFS3Response {
|
|||
this.dirWcc = dirWcc;
|
||||
}
|
||||
|
||||
public static REMOVE3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
WccData dirWcc = WccData.deserialize(xdr);
|
||||
return new REMOVE3Response(status, dirWcc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
if (dirWcc == null) {
|
||||
dirWcc = new WccData(null, null);
|
||||
}
|
||||
|
|
|
@ -45,9 +45,16 @@ public class RENAME3Response extends NFS3Response {
|
|||
return toDirWcc;
|
||||
}
|
||||
|
||||
public static RENAME3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
WccData fromDirWcc = WccData.deserialize(xdr);
|
||||
WccData toDirWcc = WccData.deserialize(xdr);
|
||||
return new RENAME3Response(status, fromDirWcc, toDirWcc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
fromDirWcc.serialize(out);
|
||||
toDirWcc.serialize(out);
|
||||
return out;
|
||||
|
|
|
@ -39,9 +39,15 @@ public class RMDIR3Response extends NFS3Response {
|
|||
return dirWcc;
|
||||
}
|
||||
|
||||
public static RMDIR3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
WccData dirWcc = WccData.deserialize(xdr);
|
||||
return new RMDIR3Response(status, dirWcc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
dirWcc.serialize(out);
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -39,9 +39,15 @@ public class SETATTR3Response extends NFS3Response {
|
|||
return wccData;
|
||||
}
|
||||
|
||||
public static SETATTR3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
WccData wccData = WccData.deserialize(xdr);
|
||||
return new SETATTR3Response(status, wccData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
wccData.serialize(out);
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -55,9 +55,25 @@ public class SYMLINK3Response extends NFS3Response {
|
|||
return dirWcc;
|
||||
}
|
||||
|
||||
public static SYMLINK3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
FileHandle objFileHandle = new FileHandle();
|
||||
Nfs3FileAttributes objPostOpAttr = null;
|
||||
WccData dirWcc;
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
xdr.readBoolean();
|
||||
objFileHandle.deserialize(xdr);
|
||||
xdr.readBoolean();
|
||||
objPostOpAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
}
|
||||
|
||||
dirWcc = WccData.deserialize(xdr);
|
||||
return new SYMLINK3Response(status, objFileHandle, objPostOpAttr, dirWcc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
if (this.getStatus() == Nfs3Status.NFS3_OK) {
|
||||
out.writeBoolean(true);
|
||||
objFileHandle.serialize(out);
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
*/
|
||||
package org.apache.hadoop.nfs.nfs3.response;
|
||||
|
||||
import org.apache.hadoop.nfs.nfs3.FileHandle;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Constant;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Status;
|
||||
import org.apache.hadoop.nfs.nfs3.Nfs3Constant.WriteStableHow;
|
||||
import org.apache.hadoop.oncrpc.XDR;
|
||||
|
@ -58,9 +60,25 @@ public class WRITE3Response extends NFS3Response {
|
|||
return verifer;
|
||||
}
|
||||
|
||||
public static WRITE3Response deserialize(XDR xdr) {
|
||||
int status = xdr.readInt();
|
||||
WccData fileWcc = WccData.deserialize(xdr);
|
||||
int count = 0;
|
||||
WriteStableHow stableHow = null;
|
||||
long verifier = 0;
|
||||
|
||||
if (status == Nfs3Status.NFS3_OK) {
|
||||
count = xdr.readInt();
|
||||
int how = xdr.readInt();
|
||||
stableHow = WriteStableHow.values()[how];
|
||||
verifier = xdr.readHyper();
|
||||
}
|
||||
return new WRITE3Response(status, fileWcc, count, stableHow, verifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) {
|
||||
super.writeHeaderAndResponse(out, xid, verifier);
|
||||
public XDR serialize(XDR out, int xid, Verifier verifier) {
|
||||
super.serialize(out, xid, verifier);
|
||||
fileWcc.serialize(out);
|
||||
if (getStatus() == Nfs3Status.NFS3_OK) {
|
||||
out.writeInt(count);
|
||||
|
|
|
@ -52,6 +52,13 @@ public class WccAttr {
|
|||
this.ctime = ctime;
|
||||
}
|
||||
|
||||
public static WccAttr deserialize(XDR xdr) {
|
||||
long size = xdr.readHyper();
|
||||
NfsTime mtime = NfsTime.deserialize(xdr);
|
||||
NfsTime ctime = NfsTime.deserialize(xdr);
|
||||
return new WccAttr(size, mtime, ctime);
|
||||
}
|
||||
|
||||
public void serialize(XDR out) {
|
||||
out.writeLongAsHyper(size);
|
||||
if (mtime == null) {
|
||||
|
|
|
@ -49,6 +49,14 @@ public class WccData {
|
|||
: postOpAttr;
|
||||
}
|
||||
|
||||
public static WccData deserialize(XDR xdr) {
|
||||
xdr.readBoolean();
|
||||
WccAttr preOpAttr = WccAttr.deserialize(xdr);
|
||||
xdr.readBoolean();
|
||||
Nfs3FileAttributes postOpAttr = Nfs3FileAttributes.deserialize(xdr);
|
||||
return new WccData(preOpAttr, postOpAttr);
|
||||
}
|
||||
|
||||
public void serialize(XDR out) {
|
||||
out.writeBoolean(true); // attributes follow
|
||||
preOpAttr.serialize(out);
|
||||
|
|
|
@ -409,7 +409,7 @@ class OpenFileCtx {
|
|||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO,
|
||||
fileWcc, 0, request.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils.writeChannel(channel,
|
||||
response.writeHeaderAndResponse(new XDR(), xid, new VerifierNone()),
|
||||
response.serialize(new XDR(), xid, new VerifierNone()),
|
||||
xid);
|
||||
} else {
|
||||
// Update the write time first
|
||||
|
@ -435,7 +435,7 @@ class OpenFileCtx {
|
|||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
|
||||
fileWcc, request.getCount(), request.getStableHow(),
|
||||
Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils.writeChannel(channel, response.writeHeaderAndResponse(
|
||||
Nfs3Utils.writeChannel(channel, response.serialize(
|
||||
new XDR(), xid, new VerifierNone()), xid);
|
||||
}
|
||||
} else {
|
||||
|
@ -572,7 +572,7 @@ class OpenFileCtx {
|
|||
}
|
||||
updateLastAccessTime();
|
||||
Nfs3Utils.writeChannel(channel,
|
||||
response.writeHeaderAndResponse(new XDR(), xid, new VerifierNone()),
|
||||
response.serialize(new XDR(), xid, new VerifierNone()),
|
||||
xid);
|
||||
}
|
||||
|
||||
|
@ -644,7 +644,7 @@ class OpenFileCtx {
|
|||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
|
||||
fileWcc, count, stableHow, Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils
|
||||
.writeChannel(channel, response.writeHeaderAndResponse(new XDR(),
|
||||
.writeChannel(channel, response.serialize(new XDR(),
|
||||
xid, new VerifierNone()), xid);
|
||||
writeCtx.setReplied(true);
|
||||
}
|
||||
|
@ -1026,7 +1026,7 @@ class OpenFileCtx {
|
|||
COMMIT3Response response = new COMMIT3Response(status, wccData,
|
||||
Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils.writeChannelCommit(commit.getChannel(), response
|
||||
.writeHeaderAndResponse(new XDR(), commit.getXid(),
|
||||
.serialize(new XDR(), commit.getXid(),
|
||||
new VerifierNone()), commit.getXid());
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
@ -1107,7 +1107,7 @@ class OpenFileCtx {
|
|||
}
|
||||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK,
|
||||
fileWcc, count, stableHow, Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils.writeChannel(channel, response.writeHeaderAndResponse(
|
||||
Nfs3Utils.writeChannel(channel, response.serialize(
|
||||
new XDR(), xid, new VerifierNone()), xid);
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1119,7 @@ class OpenFileCtx {
|
|||
+ offset + " and length " + count, e);
|
||||
if (!writeCtx.getReplied()) {
|
||||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO);
|
||||
Nfs3Utils.writeChannel(channel, response.writeHeaderAndResponse(
|
||||
Nfs3Utils.writeChannel(channel, response.serialize(
|
||||
new XDR(), xid, new VerifierNone()), xid);
|
||||
// Keep stream open. Either client retries or SteamMonitor closes it.
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ class OpenFileCtx {
|
|||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO,
|
||||
fileWcc, 0, writeCtx.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils.writeChannel(writeCtx.getChannel(), response
|
||||
.writeHeaderAndResponse(new XDR(), writeCtx.getXid(),
|
||||
.serialize(new XDR(), writeCtx.getXid(),
|
||||
new VerifierNone()), writeCtx.getXid());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2163,7 +2163,7 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|||
return;
|
||||
}
|
||||
// TODO: currently we just return VerifierNone
|
||||
out = response.writeHeaderAndResponse(out, xid, new VerifierNone());
|
||||
out = response.serialize(out, xid, new VerifierNone());
|
||||
ChannelBuffer buf = ChannelBuffers.wrappedBuffer(out.asReadOnlyWrap()
|
||||
.buffer());
|
||||
RpcResponse rsp = new RpcResponse(buf, info.remoteAddress());
|
||||
|
|
|
@ -123,7 +123,7 @@ public class WriteManager {
|
|||
byte[] data = request.getData().array();
|
||||
if (data.length < count) {
|
||||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_INVAL);
|
||||
Nfs3Utils.writeChannel(channel, response.writeHeaderAndResponse(
|
||||
Nfs3Utils.writeChannel(channel, response.serialize(
|
||||
new XDR(), xid, new VerifierNone()), xid);
|
||||
return;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ public class WriteManager {
|
|||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_IO,
|
||||
fileWcc, count, request.getStableHow(),
|
||||
Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils.writeChannel(channel, response.writeHeaderAndResponse(
|
||||
Nfs3Utils.writeChannel(channel, response.serialize(
|
||||
new XDR(), xid, new VerifierNone()), xid);
|
||||
return;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class WriteManager {
|
|||
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3ERR_JUKEBOX,
|
||||
fileWcc, 0, request.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils.writeChannel(channel,
|
||||
response.writeHeaderAndResponse(new XDR(), xid, new VerifierNone()),
|
||||
response.serialize(new XDR(), xid, new VerifierNone()),
|
||||
xid);
|
||||
return;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ public class WriteManager {
|
|||
COMMIT3Response response = new COMMIT3Response(status, fileWcc,
|
||||
Nfs3Constant.WRITE_COMMIT_VERF);
|
||||
Nfs3Utils.writeChannelCommit(channel,
|
||||
response.writeHeaderAndResponse(new XDR(), xid, new VerifierNone()),
|
||||
response.serialize(new XDR(), xid, new VerifierNone()),
|
||||
xid);
|
||||
}
|
||||
|
||||
|
|
|
@ -275,6 +275,9 @@ Release 2.6.0 - UNRELEASED
|
|||
|
||||
HDFS-7158. Reduce the memory usage of WebImageViewer. (wheat9)
|
||||
|
||||
HDFS-6894. Add XDR parser method for each NFS response.
|
||||
(Brandon Li via wheat9)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-6690. Deduplicate xattr names in memory. (wang)
|
||||
|
|
Loading…
Reference in New Issue