[ 
https://issues.apache.org/jira/browse/HDFS-9267?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14979062#comment-14979062
 ] 

Colin Patrick McCabe commented on HDFS-9267:
--------------------------------------------

I don't see why you have to load all replicas into a map.  An iterator could 
just store the file name of the previous replica, and know how to look up the 
next one.

bq. Also it is less readable to implement isEmpty() using iterator (i.e., using 
it.hasNext()) in the following code:

If you know that the number of elements will be small (or 0) then just load 
them all into a list using Guava's Lists class or whatever.

{code}
while (!Lists.newArrayList(utils.getStoredReplicas(bpid)).isEmpty()) {
    Thread.sleep(100);
}
{code}

The Iterator interface will work for large-scale tests and small-scale ones 
equally well, the collection one only works for small-scale tests.  It's better 
to use an iterator.

> TestDiskError should get stored replicas through FsDatasetTestUtils.
> --------------------------------------------------------------------
>
>                 Key: HDFS-9267
>                 URL: https://issues.apache.org/jira/browse/HDFS-9267
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: test
>    Affects Versions: 2.7.1
>            Reporter: Lei (Eddy) Xu
>            Assignee: Lei (Eddy) Xu
>            Priority: Minor
>         Attachments: HDFS-9267.00.patch, HDFS-9267.01.patch, 
> HDFS-9267.02.patch
>
>
> {{TestDiskError#testReplicationError}} scans local directories to verify 
> blocks and metadata files, which leaks the details of {{FsDataset}} 
> implementation. 
> This JIRA will abstract the "scanning" operation to {{FsDatasetTestUtils}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to