From 3fa33b5c2c289ceaced30c6c5451f3569110459d Mon Sep 17 00:00:00 2001 From: Ming Ma Date: Fri, 4 Dec 2015 09:47:57 -0800 Subject: [PATCH] HDFS-9430 Remove waitForLoadingFSImage since checkNNStartup has ensured image loaded and namenode started. (Brahma Reddy Battula via mingma) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../hdfs/server/namenode/FSNamesystem.java | 38 ------------------- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 40fdc58861d..17cbe293550 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -2439,6 +2439,9 @@ Release 2.8.0 - UNRELEASED HDFS-9484. NNThroughputBenchmark$BlockReportStats should not send empty block reports. (Mingliang Liu via shv) + HDFS-9430. Remove waitForLoadingFSImage since checkNNStartup has ensured + image loaded and namenode started. (Brahma Reddy Battula via mingma) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 6af7265e709..9c9d9f5d554 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -563,25 +563,6 @@ protected void setImageLoaded(boolean flag) { imageLoaded = flag; } - /** - * Block until the object is imageLoaded to be used. - */ - void waitForLoadingFSImage() { - if (!imageLoaded) { - writeLock(); - try { - while (!imageLoaded) { - try { - cond.await(5000, TimeUnit.MILLISECONDS); - } catch (InterruptedException ignored) { - } - } - } finally { - writeUnlock(); - } - } - } - /** * Clear all loaded data */ @@ -1802,7 +1783,6 @@ LocatedBlocks getBlockLocations(String clientMachine, String srcArg, */ void concat(String target, String [] srcs, boolean logRetryCache) throws IOException { - waitForLoadingFSImage(); HdfsFileStatus stat = null; boolean success = false; writeLock(); @@ -1899,7 +1879,6 @@ void createSymlink(String target, String link, if (!FileSystem.areSymlinksEnabled()) { throw new UnsupportedOperationException("Symlinks not supported"); } - waitForLoadingFSImage(); HdfsFileStatus auditStat = null; writeLock(); try { @@ -1933,7 +1912,6 @@ void createSymlink(String target, String link, boolean setReplication(final String src, final short replication) throws IOException { boolean success = false; - waitForLoadingFSImage(); checkOperation(OperationCategory.WRITE); writeLock(); try { @@ -1961,7 +1939,6 @@ boolean setReplication(final String src, final short replication) */ void setStoragePolicy(String src, String policyName) throws IOException { HdfsFileStatus auditStat; - waitForLoadingFSImage(); checkOperation(OperationCategory.WRITE); writeLock(); try { @@ -1988,7 +1965,6 @@ void setStoragePolicy(String src, String policyName) throws IOException { */ BlockStoragePolicy getStoragePolicy(String src) throws IOException { checkOperation(OperationCategory.READ); - waitForLoadingFSImage(); readLock(); try { checkOperation(OperationCategory.READ); @@ -2003,7 +1979,6 @@ BlockStoragePolicy getStoragePolicy(String src) throws IOException { */ BlockStoragePolicy[] getStoragePolicies() throws IOException { checkOperation(OperationCategory.READ); - waitForLoadingFSImage(); readLock(); try { checkOperation(OperationCategory.READ); @@ -2132,7 +2107,6 @@ private HdfsFileStatus startFileInt(final String src, } FSPermissionChecker pc = getPermissionChecker(); - waitForLoadingFSImage(); /** * If the file is in an encryption zone, we optimistically create an @@ -2414,7 +2388,6 @@ LocatedBlock getAdditionalBlock( NameNode.stateChangeLog.debug("BLOCK* getAdditionalBlock: {} inodeId {}" + " for {}", src, fileId, clientName); - waitForLoadingFSImage(); LocatedBlock[] onRetryBlock = new LocatedBlock[1]; FSDirWriteFileOp.ValidateAddBlockResult r; FSPermissionChecker pc = getPermissionChecker(); @@ -2525,7 +2498,6 @@ void abandonBlock(ExtendedBlock b, long fileId, String src, String holder) throws IOException { NameNode.stateChangeLog.debug( "BLOCK* NameSystem.abandonBlock: {} of file {}", b, src); - waitForLoadingFSImage(); checkOperation(OperationCategory.WRITE); FSPermissionChecker pc = getPermissionChecker(); writeLock(); @@ -2593,7 +2565,6 @@ boolean completeFile(final String src, String holder, throws IOException { boolean success = false; checkOperation(OperationCategory.WRITE); - waitForLoadingFSImage(); FSPermissionChecker pc = getPermissionChecker(); writeLock(); try { @@ -2651,7 +2622,6 @@ boolean checkFileProgress(String src, INodeFile v, boolean checkall) { @Deprecated boolean renameTo(String src, String dst, boolean logRetryCache) throws IOException { - waitForLoadingFSImage(); FSDirRenameOp.RenameOldResult ret = null; writeLock(); try { @@ -2676,7 +2646,6 @@ boolean renameTo(String src, String dst, boolean logRetryCache) void renameTo(final String src, final String dst, boolean logRetryCache, Options.Rename... options) throws IOException { - waitForLoadingFSImage(); Map.Entry res = null; writeLock(); try { @@ -2712,7 +2681,6 @@ void renameTo(final String src, final String dst, */ boolean delete(String src, boolean recursive, boolean logRetryCache) throws IOException { - waitForLoadingFSImage(); BlocksMapUpdateInfo toRemovedBlocks = null; writeLock(); boolean ret = false; @@ -2940,7 +2908,6 @@ void fsync(String src, long fileId, String clientName, long lastBlockLength) byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src); FSPermissionChecker pc = getPermissionChecker(); - waitForLoadingFSImage(); writeLock(); try { checkOperation(OperationCategory.WRITE); @@ -3193,7 +3160,6 @@ void finalizeINodeFileUnderConstruction( // since we just remove the uc feature from pendingFile pendingFile.toCompleteFile(now()); - waitForLoadingFSImage(); // close file and persist block allocations for this file closeFile(src, pendingFile); @@ -3256,7 +3222,6 @@ void commitBlockSynchronization(ExtendedBlock oldBlock, + ")"); checkOperation(OperationCategory.WRITE); final String src; - waitForLoadingFSImage(); writeLock(); boolean copyTruncate = false; BlockInfo truncatedBlock = null; @@ -3602,7 +3567,6 @@ void checkAvailableResources() { */ private void closeFile(String path, INodeFile file) { assert hasWriteLock(); - waitForLoadingFSImage(); // file is closed getEditLog().logCloseFile(path, file); NameNode.stateChangeLog.debug("closeFile: {} with {} blocks is persisted" + @@ -4748,7 +4712,6 @@ void updatePipeline( + ", newNodes=" + Arrays.asList(newNodes) + ", client=" + clientName + ")"); - waitForLoadingFSImage(); writeLock(); try { checkOperation(OperationCategory.WRITE); @@ -6591,7 +6554,6 @@ ErasureCodingPolicy getErasureCodingPolicy(String src) */ ErasureCodingPolicy[] getErasureCodingPolicies() throws IOException { checkOperation(OperationCategory.READ); - waitForLoadingFSImage(); readLock(); try { checkOperation(OperationCategory.READ);