liaoyuxiangqin created HDFS-13479: ------------------------------------- Summary: Simplify find StorageInfo logical operation in BlocksMap::replaceBlock() Key: HDFS-13479 URL: https://issues.apache.org/jira/browse/HDFS-13479 Project: Hadoop HDFS Issue Type: Improvement Components: namenode Reporter: liaoyuxiangqin
When i read the replaceBlock() of BlocksMap class in hdfs-blockmanger, i found the following find storage code could be more simplify and easy to understand. {code:java|title=DataStreamer.java|borderStyle=solid} for (int i = currentBlock.numNodes() - 1; i >= 0; i--) { final DatanodeDescriptor dn = currentBlock.getDatanode(i); final DatanodeStorageInfo storage = currentBlock.findStorageInfo(dn); final boolean removed = storage.removeBlock(currentBlock); Preconditions.checkState(removed, "currentBlock not found."); final AddBlockResult result = storage.addBlock(newBlock); Preconditions.checkState(result == AddBlockResult.ADDED, "newBlock already exists."); } {code} as described above code segmet, i find that need't get dn and we can find storage by index directly, so i think this code logical could simplify more. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org