hangc0276 commented on code in PR #2021:
URL: https://github.com/apache/zookeeper/pull/2021#discussion_r1241004943
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/PrepRequestProcessor.java:
##########
@@ -101,7 +101,7 @@ public class PrepRequestProcessor extends
ZooKeeperCriticalThread implements Req
*/
private static boolean failCreate = false;
- LinkedBlockingQueue<Request> submittedRequests = new
LinkedBlockingQueue<>();
+ BatchedArrayBlockingQueue<Request> submittedRequests = new
BatchedArrayBlockingQueue<>(10240);
Review Comment:
You changed the queue from an unbounded queue to a bounded queue of max size
10240, does it have any side effects?
##########
zookeeper-server/src/main/java/org/apache/zookeeper/common/BatchedArrayBlockingQueue.java:
##########
@@ -0,0 +1,408 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.common;
+
+import java.util.AbstractQueue;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+
+/**
+ * This implements a {@link BlockingQueue} backed by an array with fixed
capacity.
+ *
+ * <p>This queue only allows 1 consumer thread to dequeue items and multiple
producer threads.
+ */
+public class BatchedArrayBlockingQueue<T>
Review Comment:
We need a unit test to cover this impl.
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/RequestThrottler.java:
##########
@@ -61,7 +61,7 @@ public class RequestThrottler extends ZooKeeperCriticalThread
{
private static final Logger LOG =
LoggerFactory.getLogger(RequestThrottler.class);
- private final LinkedBlockingQueue<Request> submittedRequests = new
LinkedBlockingQueue<>();
+ private final BatchedArrayBlockingQueue<Request> submittedRequests = new
BatchedArrayBlockingQueue<>(10000);
Review Comment:
The same with above
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]