lvfangmin commented on a change in pull request #869: ZOOKEEPER-3020: Review of 
SyncRequestProcessor
URL: https://github.com/apache/zookeeper/pull/869#discussion_r270100909
 
 

 ##########
 File path: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/SyncRequestProcessor.java
 ##########
 @@ -46,36 +50,38 @@
  */
 public class SyncRequestProcessor extends ZooKeeperCriticalThread implements
         RequestProcessor {
+
     private static final Logger LOG = 
LoggerFactory.getLogger(SyncRequestProcessor.class);
+
+    /** The number of log entries to log before starting a snapshot */
+    private static int snapCount = ZooKeeperServer.getSnapCount();
+
+    private static final Request REQUEST_OF_DEATH = Request.requestOfDeath;
+
+    private final static int FLUSH_SIZE = 1000;
+
     private final ZooKeeperServer zks;
-    private final LinkedBlockingQueue<Request> queuedRequests =
+
+    private final BlockingQueue<Request> queuedRequests =
         new LinkedBlockingQueue<Request>();
+
     private final RequestProcessor nextProcessor;
 
-    private Thread snapInProcess = null;
-    volatile private boolean running;
+    private final Semaphore snapThreadMutex = new Semaphore(1);
 
     /**
      * Transactions that have been written and are waiting to be flushed to
      * disk. Basically this is the list of SyncItems whose callbacks will be
      * invoked after flush returns successfully.
      */
-    private final LinkedList<Request> toFlush = new LinkedList<Request>();
-    private final Random r = new Random();
-    /**
-     * The number of log entries to log before starting a snapshot
-     */
-    private static int snapCount = ZooKeeperServer.getSnapCount();
-
-    private final Request requestOfDeath = Request.requestOfDeath;
+    private final Queue<Request> toFlush = new ArrayDeque<>(FLUSH_SIZE);
 
 Review comment:
   Can you give  some detail why we changed from LinkedList to Queue? I believe 
there is something you've thought to be useful, which is not quite clear to the 
reviewer.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to