Stephen O'Donnell created HDFS-15574:
----------------------------------------
Summary: Remove unnecessary sort of block list in DirectoryScanner
Key: HDFS-15574
URL: https://issues.apache.org/jira/browse/HDFS-15574
Project: Hadoop HDFS
Issue Type: Improvement
Affects Versions: 3.4.0
Reporter: Stephen O'Donnell
Assignee: Stephen O'Donnell
These lines of code in DirectoryScanner#scan(), obtain a snapshot of the
finalized blocks from memory, and then sort them, under the DN lock. However
the blocks are stored in a sorted structure (FoldedTreeSet) and hence the sort
should be unnecessary.
{code}
final List<ReplicaInfo> bl = dataset.getFinalizedBlocks(bpid);
Collections.sort(bl); // Sort based on blockId
{code}
This Jira removes the sort, and renames the getFinalizedBlocks to
getSortedFinalizedBlocks to make the intent of the method more clear.
Also added a test, just in case the underlying block structure is ever changed
to something unsorted.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]