[
https://issues.apache.org/jira/browse/HDFS-7979?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14382622#comment-14382622
]
Colin Patrick McCabe commented on HDFS-7979:
--------------------------------------------
I think it's pretty unlikely that we would restart the DN machine and then
restart the DN exactly at the monotonic time in nanoseconds that we terminated
the old DN. For one thing, DNs usually stay up for days, and so you would have
to be starting the DN days after the PC started.
I guess I have to admit that choosing a number randomly has a smaller chance of
collision, though. In the random case you truly have a 1 / 2^^64 chance, and
you have a greater chance when using monotonic time.
{code}
return ++prevBlockReportId;
{code}
I think this should be like:
{code}
prevBlockReportId++;
while (prevBlockReportId == 0) {
prevBlockReportId = random.nextLong();
}
return prevBlockReportId;
{code}
To eliminate the (admittedly astronomically unlikely) chance of returning 0.
Also please don't create a new Random each time.
otherwise +1
> Initialize block report IDs with a random number
> ------------------------------------------------
>
> Key: HDFS-7979
> URL: https://issues.apache.org/jira/browse/HDFS-7979
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: datanode
> Affects Versions: 2.7.0
> Reporter: Andrew Wang
> Assignee: Andrew Wang
> Priority: Minor
> Attachments: HDFS-7979.001.patch
>
>
> Right now block report IDs use system nanotime. This isn't that random, so
> let's start it at a random number for some more safety.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)