HDFS-4679. Merge 1466721 from trunk
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1466729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9be0d30af4
commit
71a4677b36
|
@ -44,6 +44,9 @@ Release 2.0.5-beta - UNRELEASED
|
||||||
HDFS-3940. Add Gset#clear method and clear the block map when namenode is
|
HDFS-3940. Add Gset#clear method and clear the block map when namenode is
|
||||||
shutdown. (suresh)
|
shutdown. (suresh)
|
||||||
|
|
||||||
|
HDFS-4679. Namenode operation checks should be done in a consistent
|
||||||
|
manner. (suresh)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -1161,7 +1161,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot set permission for " + src, safeMode);
|
throw new SafeModeException("Cannot set permission for " + src, safeMode);
|
||||||
}
|
}
|
||||||
|
@ -1199,7 +1198,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot set owner for " + src, safeMode);
|
throw new SafeModeException("Cannot set owner for " + src, safeMode);
|
||||||
}
|
}
|
||||||
|
@ -1253,9 +1251,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
LocatedBlocks getBlockLocations(String src, long offset, long length,
|
LocatedBlocks getBlockLocations(String src, long offset, long length,
|
||||||
boolean doAccessTime, boolean needBlockToken, boolean checkSafeMode)
|
boolean doAccessTime, boolean needBlockToken, boolean checkSafeMode)
|
||||||
throws FileNotFoundException, UnresolvedLinkException, IOException {
|
throws FileNotFoundException, UnresolvedLinkException, IOException {
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
|
||||||
try {
|
try {
|
||||||
return getBlockLocationsInt(pc, src, offset, length, doAccessTime,
|
return getBlockLocationsInt(src, offset, length, doAccessTime,
|
||||||
needBlockToken, checkSafeMode);
|
needBlockToken, checkSafeMode);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
logAuditEvent(false, "open", src);
|
logAuditEvent(false, "open", src);
|
||||||
|
@ -1263,14 +1260,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocatedBlocks getBlockLocationsInt(FSPermissionChecker pc,
|
private LocatedBlocks getBlockLocationsInt(String src, long offset,
|
||||||
String src, long offset, long length, boolean doAccessTime,
|
long length, boolean doAccessTime, boolean needBlockToken,
|
||||||
boolean needBlockToken, boolean checkSafeMode)
|
boolean checkSafeMode)
|
||||||
throws FileNotFoundException, UnresolvedLinkException, IOException {
|
throws FileNotFoundException, UnresolvedLinkException, IOException {
|
||||||
if (isPermissionEnabled) {
|
|
||||||
checkPathAccess(pc, src, FsAction.READ);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
throw new HadoopIllegalArgumentException(
|
throw new HadoopIllegalArgumentException(
|
||||||
"Negative offset is not supported. File: " + src);
|
"Negative offset is not supported. File: " + src);
|
||||||
|
@ -1298,13 +1291,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
* Get block locations within the specified range, updating the
|
* Get block locations within the specified range, updating the
|
||||||
* access times if necessary.
|
* access times if necessary.
|
||||||
*/
|
*/
|
||||||
private LocatedBlocks getBlockLocationsUpdateTimes(String src,
|
private LocatedBlocks getBlockLocationsUpdateTimes(String src, long offset,
|
||||||
long offset,
|
long length, boolean doAccessTime, boolean needBlockToken)
|
||||||
long length,
|
throws FileNotFoundException,
|
||||||
boolean doAccessTime,
|
UnresolvedLinkException, IOException {
|
||||||
boolean needBlockToken)
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
throws FileNotFoundException, UnresolvedLinkException, IOException {
|
|
||||||
|
|
||||||
for (int attempt = 0; attempt < 2; attempt++) {
|
for (int attempt = 0; attempt < 2; attempt++) {
|
||||||
boolean isReadOp = (attempt == 0);
|
boolean isReadOp = (attempt == 0);
|
||||||
if (isReadOp) { // first attempt is with readlock
|
if (isReadOp) { // first attempt is with readlock
|
||||||
|
@ -1320,6 +1311,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
} else {
|
} else {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
}
|
}
|
||||||
|
if (isPermissionEnabled) {
|
||||||
|
checkPathAccess(pc, src, FsAction.READ);
|
||||||
|
}
|
||||||
|
|
||||||
// if the namenode is in safemode, then do not update access time
|
// if the namenode is in safemode, then do not update access time
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
|
@ -1362,6 +1356,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
*/
|
*/
|
||||||
void concat(String target, String [] srcs)
|
void concat(String target, String [] srcs)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
|
if(FSNamesystem.LOG.isDebugEnabled()) {
|
||||||
|
FSNamesystem.LOG.debug("concat " + Arrays.toString(srcs) +
|
||||||
|
" to " + target);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
concatInt(target, srcs);
|
concatInt(target, srcs);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
|
@ -1372,11 +1370,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
|
|
||||||
private void concatInt(String target, String [] srcs)
|
private void concatInt(String target, String [] srcs)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
if(FSNamesystem.LOG.isDebugEnabled()) {
|
|
||||||
FSNamesystem.LOG.debug("concat " + Arrays.toString(srcs) +
|
|
||||||
" to " + target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify args
|
// verify args
|
||||||
if(target.isEmpty()) {
|
if(target.isEmpty()) {
|
||||||
throw new IllegalArgumentException("Target file name is empty");
|
throw new IllegalArgumentException("Target file name is empty");
|
||||||
|
@ -1525,6 +1518,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
*/
|
*/
|
||||||
void setTimes(String src, long mtime, long atime)
|
void setTimes(String src, long mtime, long atime)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
|
if (!isAccessTimeSupported() && atime != -1) {
|
||||||
|
throw new IOException("Access time for hdfs is not configured. " +
|
||||||
|
" Please set " + DFS_NAMENODE_ACCESSTIME_PRECISION_KEY + " configuration parameter.");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
setTimesInt(src, mtime, atime);
|
setTimesInt(src, mtime, atime);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
|
@ -1535,16 +1532,15 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
|
|
||||||
private void setTimesInt(String src, long mtime, long atime)
|
private void setTimesInt(String src, long mtime, long atime)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
if (!isAccessTimeSupported() && atime != -1) {
|
|
||||||
throw new IOException("Access time for hdfs is not configured. " +
|
|
||||||
" Please set " + DFS_NAMENODE_ACCESSTIME_PRECISION_KEY + " configuration parameter.");
|
|
||||||
}
|
|
||||||
HdfsFileStatus resultingStat = null;
|
HdfsFileStatus resultingStat = null;
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
if (isInSafeMode()) {
|
||||||
|
throw new SafeModeException("Cannot set times " + src, safeMode);
|
||||||
|
}
|
||||||
|
|
||||||
// Write access is required to set access and modification times
|
// Write access is required to set access and modification times
|
||||||
if (isPermissionEnabled) {
|
if (isPermissionEnabled) {
|
||||||
|
@ -1569,6 +1565,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
void createSymlink(String target, String link,
|
void createSymlink(String target, String link,
|
||||||
PermissionStatus dirPerms, boolean createParent)
|
PermissionStatus dirPerms, boolean createParent)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
|
if (!DFSUtil.isValidName(link)) {
|
||||||
|
throw new InvalidPathException("Invalid file name: " + link);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
createSymlinkInt(target, link, dirPerms, createParent);
|
createSymlinkInt(target, link, dirPerms, createParent);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
|
@ -1580,17 +1579,34 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
private void createSymlinkInt(String target, String link,
|
private void createSymlinkInt(String target, String link,
|
||||||
PermissionStatus dirPerms, boolean createParent)
|
PermissionStatus dirPerms, boolean createParent)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
|
NameNode.stateChangeLog.debug("DIR* NameSystem.createSymlink: target="
|
||||||
|
+ target + " link=" + link);
|
||||||
|
}
|
||||||
HdfsFileStatus resultingStat = null;
|
HdfsFileStatus resultingStat = null;
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
if (isInSafeMode()) {
|
||||||
|
throw new SafeModeException("Cannot create symlink " + link, safeMode);
|
||||||
|
}
|
||||||
if (!createParent) {
|
if (!createParent) {
|
||||||
verifyParentDir(link);
|
verifyParentDir(link);
|
||||||
}
|
}
|
||||||
createSymlinkInternal(pc, target, link, dirPerms, createParent);
|
if (!dir.isValidToCreate(link)) {
|
||||||
|
throw new IOException("failed to create link " + link
|
||||||
|
+" either because the filename is invalid or the file exists");
|
||||||
|
}
|
||||||
|
if (isPermissionEnabled) {
|
||||||
|
checkAncestorAccess(pc, link, FsAction.WRITE);
|
||||||
|
}
|
||||||
|
// validate that we have enough inodes.
|
||||||
|
checkFsObjectLimit();
|
||||||
|
|
||||||
|
// add symbolic link to namespace
|
||||||
|
dir.addSymlink(link, target, dirPerms, createParent);
|
||||||
resultingStat = getAuditFileInfo(link, false);
|
resultingStat = getAuditFileInfo(link, false);
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
|
@ -1599,37 +1615,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
logAuditEvent(true, "createSymlink", link, target, resultingStat);
|
logAuditEvent(true, "createSymlink", link, target, resultingStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a symbolic link.
|
|
||||||
*/
|
|
||||||
private void createSymlinkInternal(FSPermissionChecker pc, String target,
|
|
||||||
String link, PermissionStatus dirPerms, boolean createParent)
|
|
||||||
throws IOException, UnresolvedLinkException {
|
|
||||||
assert hasWriteLock();
|
|
||||||
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.createSymlink: target=" +
|
|
||||||
target + " link=" + link);
|
|
||||||
}
|
|
||||||
if (isInSafeMode()) {
|
|
||||||
throw new SafeModeException("Cannot create symlink " + link, safeMode);
|
|
||||||
}
|
|
||||||
if (!DFSUtil.isValidName(link)) {
|
|
||||||
throw new InvalidPathException("Invalid file name: " + link);
|
|
||||||
}
|
|
||||||
if (!dir.isValidToCreate(link)) {
|
|
||||||
throw new IOException("failed to create link " + link
|
|
||||||
+" either because the filename is invalid or the file exists");
|
|
||||||
}
|
|
||||||
if (isPermissionEnabled) {
|
|
||||||
checkAncestorAccess(pc, link, FsAction.WRITE);
|
|
||||||
}
|
|
||||||
// validate that we have enough inodes.
|
|
||||||
checkFsObjectLimit();
|
|
||||||
|
|
||||||
// add symbolic link to namespace
|
|
||||||
dir.addSymlink(link, target, dirPerms, createParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set replication for an existing file.
|
* Set replication for an existing file.
|
||||||
*
|
*
|
||||||
|
@ -1747,12 +1732,23 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
short replication, long blockSize) throws AccessControlException,
|
short replication, long blockSize) throws AccessControlException,
|
||||||
SafeModeException, FileAlreadyExistsException, UnresolvedLinkException,
|
SafeModeException, FileAlreadyExistsException, UnresolvedLinkException,
|
||||||
FileNotFoundException, ParentNotDirectoryException, IOException {
|
FileNotFoundException, ParentNotDirectoryException, IOException {
|
||||||
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
|
NameNode.stateChangeLog.debug("DIR* NameSystem.startFile: src=" + src
|
||||||
|
+ ", holder=" + holder
|
||||||
|
+ ", clientMachine=" + clientMachine
|
||||||
|
+ ", createParent=" + createParent
|
||||||
|
+ ", replication=" + replication
|
||||||
|
+ ", createFlag=" + flag.toString());
|
||||||
|
}
|
||||||
|
if (!DFSUtil.isValidName(src)) {
|
||||||
|
throw new InvalidPathException(src);
|
||||||
|
}
|
||||||
|
|
||||||
boolean skipSync = false;
|
boolean skipSync = false;
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
|
||||||
startFileInternal(pc, src, permissions, holder, clientMachine, flag,
|
startFileInternal(pc, src, permissions, holder, clientMachine, flag,
|
||||||
createParent, replication, blockSize);
|
createParent, replication, blockSize);
|
||||||
} catch (StandbyException se) {
|
} catch (StandbyException se) {
|
||||||
|
@ -1793,21 +1789,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
AccessControlException, UnresolvedLinkException, FileNotFoundException,
|
AccessControlException, UnresolvedLinkException, FileNotFoundException,
|
||||||
ParentNotDirectoryException, IOException {
|
ParentNotDirectoryException, IOException {
|
||||||
assert hasWriteLock();
|
assert hasWriteLock();
|
||||||
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
checkOperation(OperationCategory.WRITE);
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.startFile: src=" + src
|
|
||||||
+ ", holder=" + holder
|
|
||||||
+ ", clientMachine=" + clientMachine
|
|
||||||
+ ", createParent=" + createParent
|
|
||||||
+ ", replication=" + replication
|
|
||||||
+ ", createFlag=" + flag.toString());
|
|
||||||
}
|
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot create file" + src, safeMode);
|
throw new SafeModeException("Cannot create file" + src, safeMode);
|
||||||
}
|
}
|
||||||
if (!DFSUtil.isValidName(src)) {
|
|
||||||
throw new InvalidPathException(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify that the destination does not exist as a directory already.
|
// Verify that the destination does not exist as a directory already.
|
||||||
boolean pathExists = dir.exists(src);
|
boolean pathExists = dir.exists(src);
|
||||||
if (pathExists && dir.isDir(src)) {
|
if (pathExists && dir.isDir(src)) {
|
||||||
|
@ -1942,21 +1927,20 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
*/
|
*/
|
||||||
boolean recoverLease(String src, String holder, String clientMachine)
|
boolean recoverLease(String src, String holder, String clientMachine)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
if (!DFSUtil.isValidName(src)) {
|
||||||
|
throw new IOException("Invalid file name: " + src);
|
||||||
|
}
|
||||||
|
|
||||||
boolean skipSync = false;
|
boolean skipSync = false;
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException(
|
throw new SafeModeException(
|
||||||
"Cannot recover the lease of " + src, safeMode);
|
"Cannot recover the lease of " + src, safeMode);
|
||||||
}
|
}
|
||||||
if (!DFSUtil.isValidName(src)) {
|
|
||||||
throw new IOException("Invalid file name: " + src);
|
|
||||||
}
|
|
||||||
|
|
||||||
final INodeFile inode = INodeFile.valueOf(dir.getINode(src), src);
|
final INodeFile inode = INodeFile.valueOf(dir.getINode(src), src);
|
||||||
if (!inode.isUnderConstruction()) {
|
if (!inode.isUnderConstruction()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -2080,13 +2064,20 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
"Append is not enabled on this NameNode. Use the " +
|
"Append is not enabled on this NameNode. Use the " +
|
||||||
DFS_SUPPORT_APPEND_KEY + " configuration option to enable it.");
|
DFS_SUPPORT_APPEND_KEY + " configuration option to enable it.");
|
||||||
}
|
}
|
||||||
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
|
NameNode.stateChangeLog.debug("DIR* NameSystem.appendFile: src=" + src
|
||||||
|
+ ", holder=" + holder
|
||||||
|
+ ", clientMachine=" + clientMachine);
|
||||||
|
}
|
||||||
|
if (!DFSUtil.isValidName(src)) {
|
||||||
|
throw new InvalidPathException(src);
|
||||||
|
}
|
||||||
|
|
||||||
LocatedBlock lb = null;
|
LocatedBlock lb = null;
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
|
||||||
|
|
||||||
lb = startFileInternal(pc, src, null, holder, clientMachine,
|
lb = startFileInternal(pc, src, null, holder, clientMachine,
|
||||||
EnumSet.of(CreateFlag.APPEND),
|
EnumSet.of(CreateFlag.APPEND),
|
||||||
false, blockManager.maxReplication, 0);
|
false, blockManager.maxReplication, 0);
|
||||||
|
@ -2378,21 +2369,21 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
boolean abandonBlock(ExtendedBlock b, String src, String holder)
|
boolean abandonBlock(ExtendedBlock b, String src, String holder)
|
||||||
throws LeaseExpiredException, FileNotFoundException,
|
throws LeaseExpiredException, FileNotFoundException,
|
||||||
UnresolvedLinkException, IOException {
|
UnresolvedLinkException, IOException {
|
||||||
|
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
|
NameNode.stateChangeLog.debug("BLOCK* NameSystem.abandonBlock: " + b
|
||||||
|
+ "of file " + src);
|
||||||
|
}
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
//
|
|
||||||
// Remove the block from the pending creates list
|
|
||||||
//
|
|
||||||
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
|
||||||
NameNode.stateChangeLog.debug("BLOCK* NameSystem.abandonBlock: "
|
|
||||||
+b+"of file "+src);
|
|
||||||
}
|
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot abandon block " + b +
|
throw new SafeModeException("Cannot abandon block " + b +
|
||||||
" for fle" + src, safeMode);
|
" for fle" + src, safeMode);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Remove the block from the pending creates list
|
||||||
|
//
|
||||||
INodeFileUnderConstruction file = checkLease(src, holder);
|
INodeFileUnderConstruction file = checkLease(src, holder);
|
||||||
dir.removeBlock(src, file, ExtendedBlock.getLocalBlock(b));
|
dir.removeBlock(src, file, ExtendedBlock.getLocalBlock(b));
|
||||||
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
|
@ -2450,19 +2441,23 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
*/
|
*/
|
||||||
boolean completeFile(String src, String holder, ExtendedBlock last)
|
boolean completeFile(String src, String holder, ExtendedBlock last)
|
||||||
throws SafeModeException, UnresolvedLinkException, IOException {
|
throws SafeModeException, UnresolvedLinkException, IOException {
|
||||||
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
|
NameNode.stateChangeLog.debug("DIR* NameSystem.completeFile: " +
|
||||||
|
src + " for " + holder);
|
||||||
|
}
|
||||||
checkBlock(last);
|
checkBlock(last);
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
|
||||||
|
|
||||||
success = completeFileInternal(src, holder,
|
success = completeFileInternal(src, holder,
|
||||||
ExtendedBlock.getLocalBlock(last));
|
ExtendedBlock.getLocalBlock(last));
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
|
NameNode.stateChangeLog.info("DIR* completeFile: " + src + " is closed by "
|
||||||
|
+ holder);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2470,10 +2465,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
String holder, Block last) throws SafeModeException,
|
String holder, Block last) throws SafeModeException,
|
||||||
UnresolvedLinkException, IOException {
|
UnresolvedLinkException, IOException {
|
||||||
assert hasWriteLock();
|
assert hasWriteLock();
|
||||||
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
checkOperation(OperationCategory.WRITE);
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.completeFile: " +
|
|
||||||
src + " for " + holder);
|
|
||||||
}
|
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot complete file " + src, safeMode);
|
throw new SafeModeException("Cannot complete file " + src, safeMode);
|
||||||
}
|
}
|
||||||
|
@ -2509,9 +2501,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
|
|
||||||
finalizeINodeFileUnderConstruction(src, pendingFile);
|
finalizeINodeFileUnderConstruction(src, pendingFile);
|
||||||
|
|
||||||
NameNode.stateChangeLog.info("DIR* completeFile: " + src + " is closed by "
|
|
||||||
+ holder);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2613,18 +2602,19 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
|
|
||||||
private boolean renameToInt(String src, String dst)
|
private boolean renameToInt(String src, String dst)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
boolean status = false;
|
|
||||||
HdfsFileStatus resultingStat = null;
|
|
||||||
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.renameTo: " + src +
|
NameNode.stateChangeLog.debug("DIR* NameSystem.renameTo: " + src +
|
||||||
" to " + dst);
|
" to " + dst);
|
||||||
}
|
}
|
||||||
|
if (!DFSUtil.isValidName(dst)) {
|
||||||
|
throw new IOException("Invalid name: " + dst);
|
||||||
|
}
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
boolean status = false;
|
||||||
|
HdfsFileStatus resultingStat = null;
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
|
||||||
|
|
||||||
status = renameToInternal(pc, src, dst);
|
status = renameToInternal(pc, src, dst);
|
||||||
if (status) {
|
if (status) {
|
||||||
resultingStat = getAuditFileInfo(dst, false);
|
resultingStat = getAuditFileInfo(dst, false);
|
||||||
|
@ -2644,12 +2634,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
private boolean renameToInternal(FSPermissionChecker pc, String src, String dst)
|
private boolean renameToInternal(FSPermissionChecker pc, String src, String dst)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
assert hasWriteLock();
|
assert hasWriteLock();
|
||||||
|
checkOperation(OperationCategory.WRITE);
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot rename " + src, safeMode);
|
throw new SafeModeException("Cannot rename " + src, safeMode);
|
||||||
}
|
}
|
||||||
if (!DFSUtil.isValidName(dst)) {
|
|
||||||
throw new IOException("Invalid name: " + dst);
|
|
||||||
}
|
|
||||||
if (isPermissionEnabled) {
|
if (isPermissionEnabled) {
|
||||||
//We should not be doing this. This is move() not renameTo().
|
//We should not be doing this. This is move() not renameTo().
|
||||||
//but for now,
|
//but for now,
|
||||||
|
@ -2671,16 +2659,18 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
/** Rename src to dst */
|
/** Rename src to dst */
|
||||||
void renameTo(String src, String dst, Options.Rename... options)
|
void renameTo(String src, String dst, Options.Rename... options)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
HdfsFileStatus resultingStat = null;
|
|
||||||
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.renameTo: with options - "
|
NameNode.stateChangeLog.debug("DIR* NameSystem.renameTo: with options - "
|
||||||
+ src + " to " + dst);
|
+ src + " to " + dst);
|
||||||
}
|
}
|
||||||
|
if (!DFSUtil.isValidName(dst)) {
|
||||||
|
throw new InvalidPathException("Invalid name: " + dst);
|
||||||
|
}
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
HdfsFileStatus resultingStat = null;
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
|
||||||
renameToInternal(pc, src, dst, options);
|
renameToInternal(pc, src, dst, options);
|
||||||
resultingStat = getAuditFileInfo(dst, false);
|
resultingStat = getAuditFileInfo(dst, false);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -2699,12 +2689,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
private void renameToInternal(FSPermissionChecker pc, String src, String dst,
|
private void renameToInternal(FSPermissionChecker pc, String src, String dst,
|
||||||
Options.Rename... options) throws IOException {
|
Options.Rename... options) throws IOException {
|
||||||
assert hasWriteLock();
|
assert hasWriteLock();
|
||||||
|
checkOperation(OperationCategory.WRITE);
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot rename " + src, safeMode);
|
throw new SafeModeException("Cannot rename " + src, safeMode);
|
||||||
}
|
}
|
||||||
if (!DFSUtil.isValidName(dst)) {
|
|
||||||
throw new InvalidPathException("Invalid name: " + dst);
|
|
||||||
}
|
|
||||||
if (isPermissionEnabled) {
|
if (isPermissionEnabled) {
|
||||||
checkParentAccess(pc, src, FsAction.WRITE);
|
checkParentAccess(pc, src, FsAction.WRITE);
|
||||||
checkAncestorAccess(pc, dst, FsAction.WRITE);
|
checkAncestorAccess(pc, dst, FsAction.WRITE);
|
||||||
|
@ -2881,16 +2869,15 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
HdfsFileStatus getFileInfo(String src, boolean resolveLink)
|
HdfsFileStatus getFileInfo(String src, boolean resolveLink)
|
||||||
throws AccessControlException, UnresolvedLinkException,
|
throws AccessControlException, UnresolvedLinkException,
|
||||||
StandbyException, IOException {
|
StandbyException, IOException {
|
||||||
|
if (!DFSUtil.isValidName(src)) {
|
||||||
|
throw new InvalidPathException("Invalid file name: " + src);
|
||||||
|
}
|
||||||
HdfsFileStatus stat = null;
|
HdfsFileStatus stat = null;
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.READ);
|
checkOperation(OperationCategory.READ);
|
||||||
readLock();
|
readLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.READ);
|
checkOperation(OperationCategory.READ);
|
||||||
|
|
||||||
if (!DFSUtil.isValidName(src)) {
|
|
||||||
throw new InvalidPathException("Invalid file name: " + src);
|
|
||||||
}
|
|
||||||
if (isPermissionEnabled) {
|
if (isPermissionEnabled) {
|
||||||
checkTraverse(pc, src);
|
checkTraverse(pc, src);
|
||||||
}
|
}
|
||||||
|
@ -2947,16 +2934,18 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
|
|
||||||
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;
|
|
||||||
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.mkdirs: " + src);
|
NameNode.stateChangeLog.debug("DIR* NameSystem.mkdirs: " + src);
|
||||||
}
|
}
|
||||||
|
if (!DFSUtil.isValidName(src)) {
|
||||||
|
throw new InvalidPathException(src);
|
||||||
|
}
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
HdfsFileStatus resultingStat = null;
|
||||||
|
boolean status = false;
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
|
||||||
status = mkdirsInternal(pc, src, permissions, createParent);
|
status = mkdirsInternal(pc, src, permissions, createParent);
|
||||||
if (status) {
|
if (status) {
|
||||||
resultingStat = dir.getFileInfo(src, false);
|
resultingStat = dir.getFileInfo(src, false);
|
||||||
|
@ -2978,6 +2967,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
PermissionStatus permissions, boolean createParent)
|
PermissionStatus permissions, boolean createParent)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
assert hasWriteLock();
|
assert hasWriteLock();
|
||||||
|
checkOperation(OperationCategory.WRITE);
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot create directory " + src, safeMode);
|
throw new SafeModeException("Cannot create directory " + src, safeMode);
|
||||||
}
|
}
|
||||||
|
@ -2989,9 +2979,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
// a new directory is not created.
|
// a new directory is not created.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!DFSUtil.isValidName(src)) {
|
|
||||||
throw new InvalidPathException(src);
|
|
||||||
}
|
|
||||||
if (isPermissionEnabled) {
|
if (isPermissionEnabled) {
|
||||||
checkAncestorAccess(pc, src, FsAction.WRITE);
|
checkAncestorAccess(pc, src, FsAction.WRITE);
|
||||||
}
|
}
|
||||||
|
@ -3262,8 +3249,15 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
boolean closeFile, boolean deleteblock, DatanodeID[] newtargets,
|
boolean closeFile, boolean deleteblock, DatanodeID[] newtargets,
|
||||||
String[] newtargetstorages)
|
String[] newtargetstorages)
|
||||||
throws IOException, UnresolvedLinkException {
|
throws IOException, UnresolvedLinkException {
|
||||||
String src = "";
|
LOG.info("commitBlockSynchronization(lastblock=" + lastblock
|
||||||
|
+ ", newgenerationstamp=" + newgenerationstamp
|
||||||
|
+ ", newlength=" + newlength
|
||||||
|
+ ", newtargets=" + Arrays.asList(newtargets)
|
||||||
|
+ ", closeFile=" + closeFile
|
||||||
|
+ ", deleteBlock=" + deleteblock
|
||||||
|
+ ")");
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
String src = "";
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
@ -3275,13 +3269,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
"Cannot commitBlockSynchronization while in safe mode",
|
"Cannot commitBlockSynchronization while in safe mode",
|
||||||
safeMode);
|
safeMode);
|
||||||
}
|
}
|
||||||
LOG.info("commitBlockSynchronization(lastblock=" + lastblock
|
|
||||||
+ ", newgenerationstamp=" + newgenerationstamp
|
|
||||||
+ ", newlength=" + newlength
|
|
||||||
+ ", newtargets=" + Arrays.asList(newtargets)
|
|
||||||
+ ", closeFile=" + closeFile
|
|
||||||
+ ", deleteBlock=" + deleteblock
|
|
||||||
+ ")");
|
|
||||||
final BlockInfo storedBlock = blockManager.getStoredBlock(ExtendedBlock
|
final BlockInfo storedBlock = blockManager.getStoredBlock(ExtendedBlock
|
||||||
.getLocalBlock(lastblock));
|
.getLocalBlock(lastblock));
|
||||||
if (storedBlock == null) {
|
if (storedBlock == null) {
|
||||||
|
@ -3371,7 +3358,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot renew lease for " + holder, safeMode);
|
throw new SafeModeException("Cannot renew lease for " + holder, safeMode);
|
||||||
}
|
}
|
||||||
|
@ -4847,11 +4833,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
*/
|
*/
|
||||||
void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
|
void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
NameNode.stateChangeLog.info("*DIR* reportBadBlocks");
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
|
||||||
NameNode.stateChangeLog.info("*DIR* reportBadBlocks");
|
|
||||||
for (int i = 0; i < blocks.length; i++) {
|
for (int i = 0; i < blocks.length; i++) {
|
||||||
ExtendedBlock blk = blocks[i].getBlock();
|
ExtendedBlock blk = blocks[i].getBlock();
|
||||||
DatanodeInfo[] nodes = blocks[i].getLocations();
|
DatanodeInfo[] nodes = blocks[i].getLocations();
|
||||||
|
@ -4914,6 +4899,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
ExtendedBlock newBlock, DatanodeID[] newNodes)
|
ExtendedBlock newBlock, DatanodeID[] newNodes)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
LOG.info("updatePipeline(block=" + oldBlock
|
||||||
|
+ ", newGenerationStamp=" + newBlock.getGenerationStamp()
|
||||||
|
+ ", newLength=" + newBlock.getNumBytes()
|
||||||
|
+ ", newNodes=" + Arrays.asList(newNodes)
|
||||||
|
+ ", clientName=" + clientName
|
||||||
|
+ ")");
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
@ -4923,12 +4914,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
assert newBlock.getBlockId()==oldBlock.getBlockId() : newBlock + " and "
|
assert newBlock.getBlockId()==oldBlock.getBlockId() : newBlock + " and "
|
||||||
+ oldBlock + " has different block identifier";
|
+ oldBlock + " has different block identifier";
|
||||||
LOG.info("updatePipeline(block=" + oldBlock
|
|
||||||
+ ", newGenerationStamp=" + newBlock.getGenerationStamp()
|
|
||||||
+ ", newLength=" + newBlock.getNumBytes()
|
|
||||||
+ ", newNodes=" + Arrays.asList(newNodes)
|
|
||||||
+ ", clientName=" + clientName
|
|
||||||
+ ")");
|
|
||||||
updatePipelineInternal(clientName, oldBlock, newBlock, newNodes);
|
updatePipelineInternal(clientName, oldBlock, newBlock, newNodes);
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
|
@ -5180,7 +5165,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
|
||||||
if (isInSafeMode()) {
|
if (isInSafeMode()) {
|
||||||
throw new SafeModeException("Cannot issue delegation token", safeMode);
|
throw new SafeModeException("Cannot issue delegation token", safeMode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class TestSafeMode {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testManualSafeMode() throws IOException {
|
public void testManualSafeMode() throws IOException {
|
||||||
fs = (DistributedFileSystem)cluster.getFileSystem();
|
fs = cluster.getFileSystem();
|
||||||
Path file1 = new Path("/tmp/testManualSafeMode/file1");
|
Path file1 = new Path("/tmp/testManualSafeMode/file1");
|
||||||
Path file2 = new Path("/tmp/testManualSafeMode/file2");
|
Path file2 = new Path("/tmp/testManualSafeMode/file2");
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class TestSafeMode {
|
||||||
// now bring up just the NameNode.
|
// now bring up just the NameNode.
|
||||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).format(false).build();
|
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).format(false).build();
|
||||||
cluster.waitActive();
|
cluster.waitActive();
|
||||||
dfs = (DistributedFileSystem)cluster.getFileSystem();
|
dfs = cluster.getFileSystem();
|
||||||
|
|
||||||
assertTrue("No datanode is started. Should be in SafeMode",
|
assertTrue("No datanode is started. Should be in SafeMode",
|
||||||
dfs.setSafeMode(SafeModeAction.SAFEMODE_GET));
|
dfs.setSafeMode(SafeModeAction.SAFEMODE_GET));
|
||||||
|
@ -322,11 +322,11 @@ public class TestSafeMode {
|
||||||
fs.rename(file1, new Path("file2"));
|
fs.rename(file1, new Path("file2"));
|
||||||
}});
|
}});
|
||||||
|
|
||||||
try {
|
runFsFun("Set time while in SM", new FSRun() {
|
||||||
fs.setTimes(file1, 0, 0);
|
@Override
|
||||||
} catch (IOException ioe) {
|
public void run(FileSystem fs) throws IOException {
|
||||||
fail("Set times failed while in SM");
|
fs.setTimes(file1, 0, 0);
|
||||||
}
|
}});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DFSTestUtil.readFile(fs, file1);
|
DFSTestUtil.readFile(fs, file1);
|
||||||
|
@ -350,7 +350,7 @@ public class TestSafeMode {
|
||||||
conf.setInt(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_MIN_DATANODES_KEY, 1);
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_MIN_DATANODES_KEY, 1);
|
||||||
|
|
||||||
cluster.restartNameNode();
|
cluster.restartNameNode();
|
||||||
fs = (DistributedFileSystem)cluster.getFileSystem();
|
fs = cluster.getFileSystem();
|
||||||
|
|
||||||
String tipMsg = cluster.getNamesystem().getSafemode();
|
String tipMsg = cluster.getNamesystem().getSafemode();
|
||||||
assertTrue("Safemode tip message looks right: " + tipMsg,
|
assertTrue("Safemode tip message looks right: " + tipMsg,
|
||||||
|
@ -375,7 +375,7 @@ public class TestSafeMode {
|
||||||
* @throws IOException when there's an issue connecting to the test DFS.
|
* @throws IOException when there's an issue connecting to the test DFS.
|
||||||
*/
|
*/
|
||||||
public void testSafeModeUtils() throws IOException {
|
public void testSafeModeUtils() throws IOException {
|
||||||
dfs = (DistributedFileSystem)cluster.getFileSystem();
|
dfs = cluster.getFileSystem();
|
||||||
|
|
||||||
// Enter safemode.
|
// Enter safemode.
|
||||||
dfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
|
dfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
|
||||||
|
|
Loading…
Reference in New Issue