use of org.apache.hadoop.nfs.nfs3.request.SetAttr3.SetAttrField in project hadoop by apache.
the class RpcProgramNfs3 method setattrInternal.
// Set attribute, don't support setting "size". For file/dir creation, mode is
// set during creation and setMode should be false here.
private void setattrInternal(DFSClient dfsClient, String fileIdPath, SetAttr3 newAttr, boolean setMode) throws IOException {
EnumSet<SetAttrField> updateFields = newAttr.getUpdateFields();
if (setMode && updateFields.contains(SetAttrField.MODE)) {
if (LOG.isDebugEnabled()) {
LOG.debug("set new mode: " + newAttr.getMode());
}
dfsClient.setPermission(fileIdPath, new FsPermission((short) (newAttr.getMode())));
}
if (updateFields.contains(SetAttrField.UID) || updateFields.contains(SetAttrField.GID)) {
String uname = updateFields.contains(SetAttrField.UID) ? iug.getUserName(newAttr.getUid(), IdMappingConstant.UNKNOWN_USER) : null;
String gname = updateFields.contains(SetAttrField.GID) ? iug.getGroupName(newAttr.getGid(), IdMappingConstant.UNKNOWN_GROUP) : null;
dfsClient.setOwner(fileIdPath, uname, gname);
}
long atime = updateFields.contains(SetAttrField.ATIME) ? newAttr.getAtime().getMilliSeconds() : -1;
long mtime = updateFields.contains(SetAttrField.MTIME) ? newAttr.getMtime().getMilliSeconds() : -1;
if (atime != -1 || mtime != -1) {
if (LOG.isDebugEnabled()) {
LOG.debug("set atime: " + +atime + " mtime: " + mtime);
}
dfsClient.setTimes(fileIdPath, mtime, atime);
}
}
Aggregations