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

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

Well, I was going by 
http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Random.html#nextDouble%28%29,
 which includes this text:

bq. The general contract of nextDouble is that one double value, chosen 
(approximately) uniformly from the range 0.0d (inclusive) to 1.0d (exclusive), 
is pseudorandomly generated and returned. All 2^53 possible float values of the 
form m x 2^53 , where m is a positive integer less than 2^53, are produced with 
(approximately) equal probability.

I haven't done the analysis myself so I don't know how they came to this 
number.  If you think you've found a bug in Oracle's docs, you should 
definitely let them know.

We have a lot of other time periods that are given as longs.  I just don't like 
mixing and matching types, because the potential for mistakes is too high.  At 
the same time, it's silly to make something a long and then throw an exception 
if it's greater than 31 bits.  Just my 2 cents.
                
> blockReportInterval is long value but when we take the random value it uses 
> getRandom().nextInt,it is causing frequently BR
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HDFS-3456
>                 URL: https://issues.apache.org/jira/browse/HDFS-3456
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: data-node
>    Affects Versions: 2.0.0-alpha
>            Reporter: Brahma Reddy Battula
>            Assignee: Colin Patrick McCabe
>            Priority: Minor
>         Attachments: HDFS-3456.001.patch, HDFS-3456.002.patch, 
> HDFS-3456.003.patch, HDFS-3456.004.patch
>
>
> blockReportInterval is long value but when we take the random value it uses 
> getRandom().nextInt.
> Due to this, offerService can throw exception as long may get rotated to 
> negative value.
> So, block report may send very frequently.
> {code}
>       if (resetBlockReportTime) {
>         lastBlockReport = startTime - 
> DFSUtil.getRandom().nextInt((int)(dnConf.blockReportInterval));
>       resetBlockReportTime = false;
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to