use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes 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.Nfs3FileAttributes in project hadoop by apache.
the class SYMLINK3Response method deserialize.
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);
}
use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes in project hadoop by apache.
the class FSSTAT3Response method deserialize.
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);
}
use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes in project hadoop by apache.
the class GETATTR3Response method deserialize.
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);
}
use of org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes in project hadoop by apache.
the class RpcProgramNfs3 method write.
@VisibleForTesting
WRITE3Response write(XDR xdr, Channel channel, int xid, SecurityHandler securityHandler, SocketAddress remoteAddress) {
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK);
DFSClient dfsClient = clientCache.getDfsClient(securityHandler.getUser());
if (dfsClient == null) {
response.setStatus(Nfs3Status.NFS3ERR_SERVERFAULT);
return response;
}
WRITE3Request request;
try {
request = WRITE3Request.deserialize(xdr);
} catch (IOException e) {
LOG.error("Invalid WRITE request");
return new WRITE3Response(Nfs3Status.NFS3ERR_INVAL);
}
long offset = request.getOffset();
int count = request.getCount();
WriteStableHow stableHow = request.getStableHow();
byte[] data = request.getData().array();
if (data.length < count) {
LOG.error("Invalid argument, data size is less than count in request");
return new WRITE3Response(Nfs3Status.NFS3ERR_INVAL);
}
FileHandle handle = request.getHandle();
if (LOG.isDebugEnabled()) {
LOG.debug("NFS WRITE fileId: " + handle.getFileId() + " offset: " + offset + " length: " + count + " stableHow: " + stableHow.getValue() + " xid: " + xid + " client: " + remoteAddress);
}
Nfs3FileAttributes preOpAttr = null;
try {
preOpAttr = writeManager.getFileAttr(dfsClient, handle, iug);
if (preOpAttr == null) {
LOG.error("Can't get path for fileId: " + handle.getFileId());
return new WRITE3Response(Nfs3Status.NFS3ERR_STALE);
}
if (!checkAccessPrivilege(remoteAddress, AccessPrivilege.READ_WRITE)) {
return new WRITE3Response(Nfs3Status.NFS3ERR_ACCES, new WccData(Nfs3Utils.getWccAttr(preOpAttr), preOpAttr), 0, stableHow, Nfs3Constant.WRITE_COMMIT_VERF);
}
if (LOG.isDebugEnabled()) {
LOG.debug("requested offset=" + offset + " and current filesize=" + preOpAttr.getSize());
}
writeManager.handleWrite(dfsClient, request, channel, xid, preOpAttr);
} catch (IOException e) {
LOG.info("Error writing to fileId " + handle.getFileId() + " at offset " + offset + " and length " + data.length, e);
// Try to return WccData
Nfs3FileAttributes postOpAttr = null;
try {
postOpAttr = writeManager.getFileAttr(dfsClient, handle, iug);
} catch (IOException e1) {
LOG.info("Can't get postOpAttr for fileId: " + handle.getFileId(), e1);
}
WccAttr attr = preOpAttr == null ? null : Nfs3Utils.getWccAttr(preOpAttr);
WccData fileWcc = new WccData(attr, postOpAttr);
int status = mapErrorStatus(e);
return new WRITE3Response(status, fileWcc, 0, request.getStableHow(), Nfs3Constant.WRITE_COMMIT_VERF);
}
return null;
}
Aggregations