zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] BELUGABEHR commented on a change in pull request #876: ZOOKEEPER-3020: Review of SyncRequestProcessor
Date Tue, 09 Apr 2019 00:05:18 GMT
BELUGABEHR commented on a change in pull request #876: ZOOKEEPER-3020: Review of SyncRequestProcessor
URL: https://github.com/apache/zookeeper/pull/876#discussion_r273283081
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/SyncRequestProcessor.java
 ##########
 @@ -102,103 +108,96 @@ public void run() {
 
             // we do this in an attempt to ensure that not all of the servers
             // in the ensemble take a snapshot at the same time
-            int randRoll = r.nextInt(snapCount/2);
+            int randRoll = ThreadLocalRandom.current().nextInt(snapCount / 2, snapCount);
             while (true) {
-                Request si = null;
-                if (toFlush.isEmpty()) {
+                Request si = queuedRequests.poll();
 
 Review comment:
   > Retrieves and removes the head of this queue, waiting if necessary until an element
becomes available.
   
   https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html#take()
   
   The only way a 'null' could become available here is if a 'null' value is inserted into
the collection.  However, that is prevented on line 212.
   
   I believe this is a good improvement because previously it was always checking 'isEmpty'
to make a decision about how to interact with the 'queuedRequests' queue.  I have removed
that condition and it will just go ahead and try to pull something from the queue.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message