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); } }
private static void addDeprecatedKeys() { Configuration.addDeprecations(new DeprecationDelta[] { new DeprecationDelta("nfs3.server.port", NfsConfigKeys.DFS_NFS_SERVER_PORT_KEY), new DeprecationDelta("nfs3.mountd.port", NfsConfigKeys.DFS_NFS_MOUNTD_PORT_KEY), new DeprecationDelta("dfs.nfs.exports.cache.size", Nfs3Constant.NFS_EXPORTS_CACHE_SIZE_KEY), new DeprecationDelta("dfs.nfs.exports.cache.expirytime.millis", Nfs3Constant.NFS_EXPORTS_CACHE_EXPIRYTIME_MILLIS_KEY), new DeprecationDelta("hadoop.nfs.userupdate.milly", IdMappingConstant.USERGROUPID_UPDATE_MILLIS_KEY), new DeprecationDelta("nfs.usergroup.update.millis", IdMappingConstant.USERGROUPID_UPDATE_MILLIS_KEY), new DeprecationDelta("nfs.static.mapping.file", IdMappingConstant.STATIC_ID_MAPPING_FILE_KEY), new DeprecationDelta("dfs.nfs3.enableDump", NfsConfigKeys.DFS_NFS_FILE_DUMP_KEY), new DeprecationDelta("dfs.nfs3.dump.dir", NfsConfigKeys.DFS_NFS_FILE_DUMP_DIR_KEY), new DeprecationDelta("dfs.nfs3.max.open.files", NfsConfigKeys.DFS_NFS_MAX_OPEN_FILES_KEY), new DeprecationDelta("dfs.nfs3.stream.timeout", NfsConfigKeys.DFS_NFS_STREAM_TIMEOUT_KEY), new DeprecationDelta("dfs.nfs3.export.point", NfsConfigKeys.DFS_NFS_EXPORT_POINT_KEY), new DeprecationDelta("nfs.allow.insecure.ports", NfsConfigKeys.DFS_NFS_PORT_MONITORING_DISABLED_KEY), new DeprecationDelta("dfs.nfs.keytab.file", NfsConfigKeys.DFS_NFS_KEYTAB_FILE_KEY), new DeprecationDelta("dfs.nfs.kerberos.principal", NfsConfigKeys.DFS_NFS_KERBEROS_PRINCIPAL_KEY), new DeprecationDelta("dfs.nfs.rtmax", NfsConfigKeys.DFS_NFS_MAX_READ_TRANSFER_SIZE_KEY), new DeprecationDelta("dfs.nfs.wtmax", NfsConfigKeys.DFS_NFS_MAX_WRITE_TRANSFER_SIZE_KEY), new DeprecationDelta("dfs.nfs.dtmax", NfsConfigKeys.DFS_NFS_MAX_READDIR_TRANSFER_SIZE_KEY) }); }
@Test public void testDeprecatedKeys() { NfsConfiguration conf = new NfsConfiguration(); conf.setInt("nfs3.server.port", 998); assertTrue(conf.getInt(NfsConfigKeys.DFS_NFS_SERVER_PORT_KEY, 0) == 998); conf.setInt("nfs3.mountd.port", 999); assertTrue(conf.getInt(NfsConfigKeys.DFS_NFS_MOUNTD_PORT_KEY, 0) == 999); conf.set("dfs.nfs.exports.allowed.hosts", "host1"); assertTrue(conf.get(CommonConfigurationKeys.NFS_EXPORTS_ALLOWED_HOSTS_KEY) .equals("host1")); conf.setInt("dfs.nfs.exports.cache.expirytime.millis", 1000); assertTrue(conf.getInt( Nfs3Constant.NFS_EXPORTS_CACHE_EXPIRYTIME_MILLIS_KEY, 0) == 1000); conf.setInt("hadoop.nfs.userupdate.milly", 10); assertTrue(conf.getInt(IdMappingConstant.USERGROUPID_UPDATE_MILLIS_KEY, 0) == 10); conf.set("dfs.nfs3.dump.dir", "/nfs/tmp"); assertTrue(conf.get(NfsConfigKeys.DFS_NFS_FILE_DUMP_DIR_KEY).equals( "/nfs/tmp")); conf.setBoolean("dfs.nfs3.enableDump", false); assertTrue(conf.getBoolean(NfsConfigKeys.DFS_NFS_FILE_DUMP_KEY, true) == false); conf.setInt("dfs.nfs3.max.open.files", 500); assertTrue(conf.getInt(NfsConfigKeys.DFS_NFS_MAX_OPEN_FILES_KEY, 0) == 500); conf.setInt("dfs.nfs3.stream.timeout", 6000); assertTrue(conf.getInt(NfsConfigKeys.DFS_NFS_STREAM_TIMEOUT_KEY, 0) == 6000); conf.set("dfs.nfs3.export.point", "/dir1"); assertTrue(conf.get(NfsConfigKeys.DFS_NFS_EXPORT_POINT_KEY).equals("/dir1")); }
@Override public String getUser() { return iug.getUserName(mCredentialsSys.getUID(), IdMappingConstant.UNKNOWN_USER); }