You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by asdf2014 <gi...@git.apache.org> on 2018/04/16 03:02:53 UTC

[GitHub] zookeeper pull request #303: ZOOKEEPER-2840: Should using `System.nanoTime()...

Github user asdf2014 commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/303#discussion_r181613274
  
    --- Diff: src/java/main/org/apache/zookeeper/client/StaticHostProvider.java ---
    @@ -71,7 +71,7 @@
          *             if serverAddresses is empty or resolves to an empty list
          */
         public StaticHostProvider(Collection<InetSocketAddress> serverAddresses) {
    -       sourceOfRandomness = new Random(System.currentTimeMillis() ^ this.hashCode());
    +       sourceOfRandomness = new Random(System.nanoTime() ^ this.hashCode());
    --- End diff --
    
    Hi, @maoling. Sorry for my belated comment. Indeed, i hadn't been considered this case that different clients will own different `hashcode`s. Because, in my sistuation, our Zookeeper clusters only give service to some apointed BigData components, e.g., [HBase](https://yuzhouwan.com/posts/45888/), [Druid.io](https://yuzhouwan.com/posts/5845/), [Hadoop](https://yuzhouwan.com/posts/60504/), [Kafka](https://yuzhouwan.com/posts/26002/) etc. Inside these components will have settled clients, so them can not offer too many different `hashcode`s.


---