areyouok commented on a change in pull request #3659: URL: https://github.com/apache/rocketmq/pull/3659#discussion_r788719612
########## File path: broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullNotifyQueue.java ########## @@ -0,0 +1,147 @@ +/* + * 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.rocketmq.broker.longpolling; + +import java.util.LinkedList; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; + +class PullNotifyQueue<T> { + private PullNotifyQueueConfig config; + + private final LinkedBlockingQueue<T> queue; + + private int activeConsumeQueueCount = 1; + private long activeConsumeQueueEpochTime = System.nanoTime(); + // only change in unit test + private long activeConsumeQueueRefreshTime = 1_000_000_000; + + private long lastBatchDrainTime; + + public PullNotifyQueue(PullNotifyQueueConfig config) { + queue = new LinkedBlockingQueue<>(500_000); + this.config = config; + } + + public void put(T data) throws InterruptedException { + queue.put(data); + } + + public LinkedList<T> drain() throws InterruptedException { + LinkedList<T> result = new LinkedList<>(); + long tps = config.getTps(); + if (tps <= config.getTpsThreshold()) { + T data = queue.poll(100, TimeUnit.MILLISECONDS); Review comment: we can modify the threshold to a greater number, such as 150000. In case tps greater than 150000 and a lot of queue is writing, I think the latency is not so important. -- 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]
