svn merge -c 1452435 FIXES: HDFS-4532. RPC call queue may fill due to current user lookup (daryn)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1452438 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
363d038e21
commit
b57b5cec27
|
@ -2088,6 +2088,8 @@ Release 0.23.7 - UNRELEASED
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
|
HDFS-4532. RPC call queue may fill due to current user lookup (daryn)
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
HDFS-4288. NN accepts incremental BR as IBR in safemode (daryn via kihwal)
|
HDFS-4288. NN accepts incremental BR as IBR in safemode (daryn via kihwal)
|
||||||
|
|
|
@ -238,10 +238,23 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
return !isDefaultAuditLogger || auditLog.isInfoEnabled();
|
return !isDefaultAuditLogger || auditLog.isInfoEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logAuditEvent(UserGroupInformation ugi,
|
private HdfsFileStatus getAuditFileInfo(String path, boolean resolveSymlink)
|
||||||
InetAddress addr, String cmd, String src, String dst,
|
throws IOException {
|
||||||
HdfsFileStatus stat) {
|
return (isAuditEnabled() && isExternalInvocation())
|
||||||
logAuditEvent(true, ugi, addr, cmd, src, dst, stat);
|
? dir.getFileInfo(path, resolveSymlink) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logAuditEvent(boolean succeeded, String cmd, String src)
|
||||||
|
throws IOException {
|
||||||
|
logAuditEvent(succeeded, cmd, src, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logAuditEvent(boolean succeeded, String cmd, String src,
|
||||||
|
String dst, HdfsFileStatus stat) throws IOException {
|
||||||
|
if (isAuditEnabled() && isExternalInvocation()) {
|
||||||
|
logAuditEvent(succeeded, getRemoteUser(), getRemoteIp(),
|
||||||
|
cmd, src, dst, stat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logAuditEvent(boolean succeeded,
|
private void logAuditEvent(boolean succeeded,
|
||||||
|
@ -1130,11 +1143,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
setPermissionInt(src, permission);
|
setPermissionInt(src, permission);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "setPermission", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"setPermission", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1153,18 +1162,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
checkOwner(pc, src);
|
checkOwner(pc, src);
|
||||||
dir.setPermission(src, permission);
|
dir.setPermission(src, permission);
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
resultingStat = getAuditFileInfo(src, false);
|
||||||
resultingStat = dir.getFileInfo(src, false);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "setPermission", src, null, resultingStat);
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"setPermission", src, null, resultingStat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1177,11 +1180,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
setOwnerInt(src, username, group);
|
setOwnerInt(src, username, group);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "setOwner", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"setOwner", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1208,18 +1207,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dir.setOwner(src, username, group);
|
dir.setOwner(src, username, group);
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
resultingStat = getAuditFileInfo(src, false);
|
||||||
resultingStat = dir.getFileInfo(src, false);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "setOwner", src, null, resultingStat);
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"setOwner", src, null, resultingStat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1259,11 +1252,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
return getBlockLocationsInt(pc, src, offset, length, doAccessTime,
|
return getBlockLocationsInt(pc, src, offset, length, doAccessTime,
|
||||||
needBlockToken, checkSafeMode);
|
needBlockToken, checkSafeMode);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "open", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"open", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1286,11 +1275,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
final LocatedBlocks ret = getBlockLocationsUpdateTimes(src,
|
final LocatedBlocks ret = getBlockLocationsUpdateTimes(src,
|
||||||
offset, length, doAccessTime, needBlockToken);
|
offset, length, doAccessTime, needBlockToken);
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "open", src);
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"open", src, null, null);
|
|
||||||
}
|
|
||||||
if (checkSafeMode && isInSafeMode()) {
|
if (checkSafeMode && isInSafeMode()) {
|
||||||
for (LocatedBlock b : ret.getLocatedBlocks()) {
|
for (LocatedBlock b : ret.getLocatedBlocks()) {
|
||||||
// if safemode & no block locations yet then throw safemodeException
|
// if safemode & no block locations yet then throw safemodeException
|
||||||
|
@ -1367,11 +1352,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
concatInt(target, srcs);
|
concatInt(target, srcs);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "concat", Arrays.toString(srcs), target, null);
|
||||||
logAuditEvent(false, UserGroupInformation.getLoginUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"concat", Arrays.toString(srcs), target, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1411,18 +1392,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
throw new SafeModeException("Cannot concat " + target, safeMode);
|
throw new SafeModeException("Cannot concat " + target, safeMode);
|
||||||
}
|
}
|
||||||
concatInternal(pc, target, srcs);
|
concatInternal(pc, target, srcs);
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
resultingStat = getAuditFileInfo(target, false);
|
||||||
resultingStat = dir.getFileInfo(target, false);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "concat", Arrays.toString(srcs), target, resultingStat);
|
||||||
logAuditEvent(UserGroupInformation.getLoginUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"concat", Arrays.toString(srcs), target, resultingStat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** See {@link #concat(String, String[])} */
|
/** See {@link #concat(String, String[])} */
|
||||||
|
@ -1539,11 +1514,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
setTimesInt(src, mtime, atime);
|
setTimesInt(src, mtime, atime);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "setTimes", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"setTimes", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1554,6 +1525,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
throw new IOException("Access time for hdfs is not configured. " +
|
throw new IOException("Access time for hdfs is not configured. " +
|
||||||
" Please set " + DFS_NAMENODE_ACCESSTIME_PRECISION_KEY + " configuration parameter.");
|
" Please set " + DFS_NAMENODE_ACCESSTIME_PRECISION_KEY + " configuration parameter.");
|
||||||
}
|
}
|
||||||
|
HdfsFileStatus resultingStat = null;
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1566,18 +1538,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
INode inode = dir.getINode(src);
|
INode inode = dir.getINode(src);
|
||||||
if (inode != null) {
|
if (inode != null) {
|
||||||
dir.setTimes(src, inode, mtime, atime, true);
|
dir.setTimes(src, inode, mtime, atime, true);
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
resultingStat = getAuditFileInfo(src, false);
|
||||||
final HdfsFileStatus stat = dir.getFileInfo(src, false);
|
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"setTimes", src, null, stat);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new FileNotFoundException("File/Directory " + src + " does not exist.");
|
throw new FileNotFoundException("File/Directory " + src + " does not exist.");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
|
logAuditEvent(true, "setTimes", src, null, resultingStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1589,11 +1557,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
createSymlinkInt(target, link, dirPerms, createParent);
|
createSymlinkInt(target, link, dirPerms, createParent);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "createSymlink", link, target, null);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"createSymlink", link, target, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1611,18 +1575,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
verifyParentDir(link);
|
verifyParentDir(link);
|
||||||
}
|
}
|
||||||
createSymlinkInternal(pc, target, link, dirPerms, createParent);
|
createSymlinkInternal(pc, target, link, dirPerms, createParent);
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
resultingStat = getAuditFileInfo(link, false);
|
||||||
resultingStat = dir.getFileInfo(link, false);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "createSymlink", link, target, resultingStat);
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"createSymlink", link, target, resultingStat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1674,11 +1632,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
return setReplicationInt(src, replication);
|
return setReplicationInt(src, replication);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "setReplication", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"setReplication", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1709,10 +1663,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
|
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
if (isFile && isAuditEnabled() && isExternalInvocation()) {
|
if (isFile) {
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
logAuditEvent(true, "setReplication", src);
|
||||||
getRemoteIp(),
|
|
||||||
"setReplication", src, null, null);
|
|
||||||
}
|
}
|
||||||
return isFile;
|
return isFile;
|
||||||
}
|
}
|
||||||
|
@ -1767,11 +1719,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
startFileInt(src, permissions, holder, clientMachine, flag, createParent,
|
startFileInt(src, permissions, holder, clientMachine, flag, createParent,
|
||||||
replication, blockSize);
|
replication, blockSize);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "create", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"create", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1799,13 +1747,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
final HdfsFileStatus stat = getAuditFileInfo(src, false);
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "create", src, null, stat);
|
||||||
final HdfsFileStatus stat = dir.getFileInfo(src, false);
|
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"create", src, null, stat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2102,11 +2045,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
return appendFileInt(src, holder, clientMachine);
|
return appendFileInt(src, holder, clientMachine);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "append", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"append", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2149,11 +2088,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
+" block size " + lb.getBlock().getNumBytes());
|
+" block size " + lb.getBlock().getNumBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "append", src);
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"append", src, null, null);
|
|
||||||
}
|
|
||||||
return lb;
|
return lb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2643,11 +2578,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
return renameToInt(src, dst);
|
return renameToInt(src, dst);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "rename", src, dst, null);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"rename", src, dst, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2666,17 +2597,15 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
|
||||||
status = renameToInternal(pc, src, dst);
|
status = renameToInternal(pc, src, dst);
|
||||||
if (status && isAuditEnabled() && isExternalInvocation()) {
|
if (status) {
|
||||||
resultingStat = dir.getFileInfo(dst, false);
|
resultingStat = getAuditFileInfo(dst, false);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
if (status && isAuditEnabled() && isExternalInvocation()) {
|
if (status) {
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
logAuditEvent(true, "rename", src, dst, resultingStat);
|
||||||
getRemoteIp(),
|
|
||||||
"rename", src, dst, resultingStat);
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -2723,20 +2652,17 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
renameToInternal(pc, src, dst, options);
|
renameToInternal(pc, src, dst, options);
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
resultingStat = getAuditFileInfo(dst, false);
|
||||||
resultingStat = dir.getFileInfo(dst, false);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
if (resultingStat != null) {
|
||||||
StringBuilder cmd = new StringBuilder("rename options=");
|
StringBuilder cmd = new StringBuilder("rename options=");
|
||||||
for (Rename option : options) {
|
for (Rename option : options) {
|
||||||
cmd.append(option.value()).append(" ");
|
cmd.append(option.value()).append(" ");
|
||||||
}
|
}
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(), getRemoteIp(),
|
logAuditEvent(true, cmd.toString(), src, dst, resultingStat);
|
||||||
cmd.toString(), src, dst, resultingStat);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2769,11 +2695,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
return deleteInt(src, recursive);
|
return deleteInt(src, recursive);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "delete", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"delete", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2785,10 +2707,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.delete: " + src);
|
NameNode.stateChangeLog.debug("DIR* NameSystem.delete: " + src);
|
||||||
}
|
}
|
||||||
boolean status = deleteInternal(src, recursive, true);
|
boolean status = deleteInternal(src, recursive, true);
|
||||||
if (status && isAuditEnabled() && isExternalInvocation()) {
|
if (status) {
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
logAuditEvent(true, "delete", src);
|
||||||
getRemoteIp(),
|
|
||||||
"delete", src, null, null);
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -2944,20 +2864,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
stat = dir.getFileInfo(src, resolveLink);
|
stat = dir.getFileInfo(src, resolveLink);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "getfileinfo", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"getfileinfo", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
readUnlock();
|
readUnlock();
|
||||||
}
|
}
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "getfileinfo", src);
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"getfileinfo", src, null, null);
|
|
||||||
}
|
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2969,17 +2881,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
return mkdirsInt(src, permissions, createParent);
|
return mkdirsInt(src, permissions, createParent);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "mkdirs", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"mkdirs", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mkdirsInt(String src, PermissionStatus permissions,
|
private boolean mkdirsInt(String src, PermissionStatus permissions,
|
||||||
boolean createParent) throws IOException, UnresolvedLinkException {
|
boolean createParent) throws IOException, UnresolvedLinkException {
|
||||||
|
HdfsFileStatus resultingStat = null;
|
||||||
boolean status = false;
|
boolean status = false;
|
||||||
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.mkdirs: " + src);
|
NameNode.stateChangeLog.debug("DIR* NameSystem.mkdirs: " + src);
|
||||||
|
@ -2989,15 +2898,15 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
status = mkdirsInternal(pc, src, permissions, createParent);
|
status = mkdirsInternal(pc, src, permissions, createParent);
|
||||||
|
if (status) {
|
||||||
|
resultingStat = dir.getFileInfo(src, false);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
if (status && isAuditEnabled() && isExternalInvocation()) {
|
if (status) {
|
||||||
final HdfsFileStatus stat = dir.getFileInfo(src, false);
|
logAuditEvent(true, "mkdirs", src, null, resultingStat);
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"mkdirs", src, null, stat);
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -3426,11 +3335,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
try {
|
try {
|
||||||
return getListingInt(src, startAfter, needLocation);
|
return getListingInt(src, startAfter, needLocation);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(false, "listStatus", src);
|
||||||
logAuditEvent(false, UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"listStatus", src, null, null);
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3451,11 +3356,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
checkTraverse(pc, src);
|
checkTraverse(pc, src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isAuditEnabled() && isExternalInvocation()) {
|
logAuditEvent(true, "listStatus", src);
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
|
||||||
getRemoteIp(),
|
|
||||||
"listStatus", src, null, null);
|
|
||||||
}
|
|
||||||
dl = dir.getListing(src, startAfter, needLocation);
|
dl = dir.getListing(src, startAfter, needLocation);
|
||||||
} finally {
|
} finally {
|
||||||
readUnlock();
|
readUnlock();
|
||||||
|
@ -5202,7 +5103,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
|
UserGroupInformation ugi = getRemoteUser();
|
||||||
String user = ugi.getUserName();
|
String user = ugi.getUserName();
|
||||||
Text owner = new Text(user);
|
Text owner = new Text(user);
|
||||||
Text realUser = null;
|
Text realUser = null;
|
||||||
|
@ -5243,7 +5144,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"Delegation Token can be renewed only with kerberos or web authentication");
|
"Delegation Token can be renewed only with kerberos or web authentication");
|
||||||
}
|
}
|
||||||
String renewer = UserGroupInformation.getCurrentUser().getShortUserName();
|
String renewer = getRemoteUser().getShortUserName();
|
||||||
expiryTime = dtSecretManager.renewToken(token, renewer);
|
expiryTime = dtSecretManager.renewToken(token, renewer);
|
||||||
DelegationTokenIdentifier id = new DelegationTokenIdentifier();
|
DelegationTokenIdentifier id = new DelegationTokenIdentifier();
|
||||||
ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier());
|
ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier());
|
||||||
|
@ -5271,7 +5172,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot cancel delegation token", safeMode);
|
throw new SafeModeException("Cannot cancel delegation token", safeMode);
|
||||||
}
|
}
|
||||||
String canceller = UserGroupInformation.getCurrentUser().getUserName();
|
String canceller = getRemoteUser().getUserName();
|
||||||
DelegationTokenIdentifier id = dtSecretManager
|
DelegationTokenIdentifier id = dtSecretManager
|
||||||
.cancelToken(token, canceller);
|
.cancelToken(token, canceller);
|
||||||
getEditLog().logCancelDelegationToken(id);
|
getEditLog().logCancelDelegationToken(id);
|
||||||
|
@ -5340,7 +5241,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
*/
|
*/
|
||||||
private AuthenticationMethod getConnectionAuthenticationMethod()
|
private AuthenticationMethod getConnectionAuthenticationMethod()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
|
UserGroupInformation ugi = getRemoteUser();
|
||||||
AuthenticationMethod authMethod = ugi.getAuthenticationMethod();
|
AuthenticationMethod authMethod = ugi.getAuthenticationMethod();
|
||||||
if (authMethod == AuthenticationMethod.PROXY) {
|
if (authMethod == AuthenticationMethod.PROXY) {
|
||||||
authMethod = ugi.getRealUser().getAuthenticationMethod();
|
authMethod = ugi.getRealUser().getAuthenticationMethod();
|
||||||
|
@ -5364,12 +5265,22 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
return NamenodeWebHdfsMethods.getRemoteIp();
|
return NamenodeWebHdfsMethods.getRemoteIp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optimize ugi lookup for RPC operations to avoid a trip through
|
||||||
|
// UGI.getCurrentUser which is synch'ed
|
||||||
|
private static UserGroupInformation getRemoteUser() throws IOException {
|
||||||
|
UserGroupInformation ugi = null;
|
||||||
|
if (Server.isRpcInvocation()) {
|
||||||
|
ugi = Server.getRemoteUser();
|
||||||
|
}
|
||||||
|
return (ugi != null) ? ugi : UserGroupInformation.getCurrentUser();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log fsck event in the audit log
|
* Log fsck event in the audit log
|
||||||
*/
|
*/
|
||||||
void logFsckEvent(String src, InetAddress remoteAddress) throws IOException {
|
void logFsckEvent(String src, InetAddress remoteAddress) throws IOException {
|
||||||
if (isAuditEnabled()) {
|
if (isAuditEnabled()) {
|
||||||
logAuditEvent(UserGroupInformation.getCurrentUser(),
|
logAuditEvent(true, getRemoteUser(),
|
||||||
remoteAddress,
|
remoteAddress,
|
||||||
"fsck", src, null, null);
|
"fsck", src, null, null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue