Author: arp Date: Thu May 15 22:30:03 2014 New Revision: 1595065 URL: http://svn.apache.org/r1595065 Log: HDFS-4052. Merge r1595063 from branch-2 to branch-2.4
Modified: hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java Modified: hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1595065&r1=1595064&r2=1595065&view=diff ============================================================================== --- hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Thu May 15 22:30:03 2014 @@ -68,6 +68,9 @@ Release 2.4.1 - UNRELEASED HDFS-6326. WebHdfs ACL compatibility is broken. (cnauroth) + HDFS-4052. BlockManager#invalidateWork should print log outside the lock. + (Jing Zhao via suresh) + HDFS-6361. TestIdUserGroup.testUserUpdateSetting failed due to out of range nfsnobody Id. (Yongjun Zhang via brandonli) Modified: hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java?rev=1595065&r1=1595064&r2=1595065&view=diff ============================================================================== --- hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java (original) +++ hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java Thu May 15 22:30:03 2014 @@ -3190,6 +3190,9 @@ public class BlockManager { * @return number of blocks scheduled for removal during this iteration. */ private int invalidateWorkForOneNode(String nodeId) { + final List<Block> toInvalidate; + final DatanodeDescriptor dn; + namesystem.writeLock(); try { // blocks should not be replicated or removed if safe mode is on @@ -3199,10 +3202,23 @@ public class BlockManager { } // get blocks to invalidate for the nodeId assert nodeId != null; - return invalidateBlocks.invalidateWork(nodeId); + dn = datanodeManager.getDatanode(nodeId); + if (dn == null) { + invalidateBlocks.remove(nodeId); + return 0; + } + toInvalidate = invalidateBlocks.invalidateWork(nodeId, dn); + if (toInvalidate == null) { + return 0; + } } finally { namesystem.writeUnlock(); } + if (NameNode.stateChangeLog.isInfoEnabled()) { + NameNode.stateChangeLog.info("BLOCK* " + getClass().getSimpleName() + + ": ask " + dn + " to delete " + toInvalidate); + } + return toInvalidate.size(); } boolean blockHasEnoughRacks(Block b) { Modified: hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java?rev=1595065&r1=1595064&r2=1595065&view=diff ============================================================================== --- hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java (original) +++ hadoop/common/branches/branch-2.4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/InvalidateBlocks.java Thu May 15 22:30:03 2014 @@ -136,26 +136,7 @@ class InvalidateBlocks { return new ArrayList<String>(node2blocks.keySet()); } - /** Invalidate work for the storage. */ - int invalidateWork(final String storageId) { - final DatanodeDescriptor dn = datanodeManager.getDatanode(storageId); - if (dn == null) { - remove(storageId); - return 0; - } - final List<Block> toInvalidate = invalidateWork(storageId, dn); - if (toInvalidate == null) { - return 0; - } - - if (NameNode.stateChangeLog.isInfoEnabled()) { - NameNode.stateChangeLog.info("BLOCK* " + getClass().getSimpleName() - + ": ask " + dn + " to delete " + toInvalidate); - } - return toInvalidate.size(); - } - - private synchronized List<Block> invalidateWork( + synchronized List<Block> invalidateWork( final String storageId, final DatanodeDescriptor dn) { final LightWeightHashSet<Block> set = node2blocks.get(storageId); if (set == null) {