Author: szetszwo Date: Thu May 10 21:41:25 2012 New Revision: 1336909 URL: http://svn.apache.org/viewvc?rev=1336909&view=rev Log: HDFS-3369. Rename {get|set|add}INode(..) methods in BlockManager and BlocksMap to {get|set|add}BlockCollection(..). Contributed by John George
Modified: hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyRaid.java hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/test/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockPlacementPolicyRaid.java Modified: hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyRaid.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyRaid.java?rev=1336909&r1=1336908&r2=1336909&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyRaid.java (original) +++ hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyRaid.java Thu May 10 21:41:25 2012 @@ -144,25 +144,25 @@ public class BlockPlacementPolicyRaid ex /** {@inheritDoc} */ @Override - public DatanodeDescriptor chooseReplicaToDelete(BlockCollection inode, + public DatanodeDescriptor chooseReplicaToDelete(BlockCollection bc, Block block, short replicationFactor, Collection<DatanodeDescriptor> first, Collection<DatanodeDescriptor> second) { DatanodeDescriptor chosenNode = null; try { - String path = cachedFullPathNames.get(inode); + String path = cachedFullPathNames.get(bc); FileType type = getFileType(path); if (type == FileType.NOT_RAID) { return defaultPolicy.chooseReplicaToDelete( - inode, block, replicationFactor, first, second); + bc, block, replicationFactor, first, second); } List<LocatedBlock> companionBlocks = getCompanionBlocks(path, type, block); if (companionBlocks == null || companionBlocks.size() == 0) { // Use the default method if it is not a valid raided or parity file return defaultPolicy.chooseReplicaToDelete( - inode, block, replicationFactor, first, second); + bc, block, replicationFactor, first, second); } // Delete from the first collection first // This ensures the number of unique rack of this block is not reduced @@ -174,12 +174,12 @@ public class BlockPlacementPolicyRaid ex return chosenNode; } return defaultPolicy.chooseReplicaToDelete( - inode, block, replicationFactor, first, second); + bc, block, replicationFactor, first, second); } catch (Exception e) { LOG.debug("Error happend when choosing replica to delete" + StringUtils.stringifyException(e)); return defaultPolicy.chooseReplicaToDelete( - inode, block, replicationFactor, first, second); + bc, block, replicationFactor, first, second); } } @@ -446,25 +446,25 @@ public class BlockPlacementPolicyRaid ex }; static private class INodeWithHashCode { - BlockCollection inode; - INodeWithHashCode(BlockCollection inode) { - this.inode = inode; + BlockCollection bc; + INodeWithHashCode(BlockCollection bc) { + this.bc= bc; } @Override public boolean equals(Object obj) { - return inode == obj; + return bc== obj; } @Override public int hashCode() { - return System.identityHashCode(inode); + return System.identityHashCode(bc); } String getFullPathName() { - return inode.getName(); + return bc.getName(); } } - public String get(BlockCollection inode) throws IOException { - return cacheInternal.get(new INodeWithHashCode(inode)); + public String get(BlockCollection bc) throws IOException { + return cacheInternal.get(new INodeWithHashCode(bc)); } } Modified: hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/test/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockPlacementPolicyRaid.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/test/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockPlacementPolicyRaid.java?rev=1336909&r1=1336908&r2=1336909&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/test/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockPlacementPolicyRaid.java (original) +++ hadoop/common/trunk/hadoop-mapreduce-project/src/contrib/raid/src/test/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockPlacementPolicyRaid.java Thu May 10 21:41:25 2012 @@ -240,19 +240,19 @@ public class TestBlockPlacementPolicyRai // test full path cache CachedFullPathNames cachedFullPathNames = new CachedFullPathNames(namesystem); - final BlockCollection[] inodes = NameNodeRaidTestUtil.getBlockCollections( + final BlockCollection[] bcs = NameNodeRaidTestUtil.getBlockCollections( namesystem, file1, file2); - verifyCachedFullPathNameResult(cachedFullPathNames, inodes[0]); - verifyCachedFullPathNameResult(cachedFullPathNames, inodes[0]); - verifyCachedFullPathNameResult(cachedFullPathNames, inodes[1]); - verifyCachedFullPathNameResult(cachedFullPathNames, inodes[1]); + verifyCachedFullPathNameResult(cachedFullPathNames, bcs[0]); + verifyCachedFullPathNameResult(cachedFullPathNames, bcs[0]); + verifyCachedFullPathNameResult(cachedFullPathNames, bcs[1]); + verifyCachedFullPathNameResult(cachedFullPathNames, bcs[1]); try { Thread.sleep(1200L); } catch (InterruptedException e) { } - verifyCachedFullPathNameResult(cachedFullPathNames, inodes[1]); - verifyCachedFullPathNameResult(cachedFullPathNames, inodes[0]); + verifyCachedFullPathNameResult(cachedFullPathNames, bcs[1]); + verifyCachedFullPathNameResult(cachedFullPathNames, bcs[0]); } finally { if (cluster != null) { cluster.shutdown(); @@ -476,14 +476,14 @@ public class TestBlockPlacementPolicyRai } private void verifyCachedFullPathNameResult( - CachedFullPathNames cachedFullPathNames, BlockCollection inode) + CachedFullPathNames cachedFullPathNames, BlockCollection bc) throws IOException { - String res1 = inode.getName(); - String res2 = cachedFullPathNames.get(inode); + String res1 = bc.getName(); + String res2 = cachedFullPathNames.get(bc); LOG.info("Actual path name: " + res1); LOG.info("Cached path name: " + res2); - Assert.assertEquals(cachedFullPathNames.get(inode), - inode.getName()); + Assert.assertEquals(cachedFullPathNames.get(bc), + bc.getName()); } private void verifyCachedBlocksResult(CachedLocatedBlocks cachedBlocks, @@ -502,7 +502,7 @@ public class TestBlockPlacementPolicyRai private Collection<LocatedBlock> getCompanionBlocks( FSNamesystem namesystem, BlockPlacementPolicyRaid policy, ExtendedBlock block) throws IOException { - INodeFile inode = (INodeFile)blockManager.blocksMap.getINode(block + INodeFile inode = (INodeFile)blockManager.blocksMap.getBlockCollection(block .getLocalBlock()); FileType type = policy.getFileType(inode.getFullPathName()); return policy.getCompanionBlocks(inode.getFullPathName(), type,