You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/11/18 00:43:46 UTC
[GitHub] [ratis] SzyWilliam commented on a diff in pull request #782: RATIS-1743. (superseded)
SzyWilliam commented on code in PR #782:
URL: https://github.com/apache/ratis/pull/782#discussion_r1025879696
##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogWorker.java:
##########
@@ -132,29 +139,83 @@ synchronized void updateIndex(long i) {
}
}
+ static class Queues implements ToIntFunction<String> {
+ private final DataBlockingQueue<Task> taskQueue;
+ private final WriteLogTasks writeTasks = new WriteLogTasks();
+
+ Queues(String name, RaftProperties properties) {
+ final SizeInBytes queueByteLimit = RaftServerConfigKeys.Log.queueByteLimit(properties);
+ final int queueElementLimit = RaftServerConfigKeys.Log.queueElementLimit(properties);
+ this.taskQueue = new DataBlockingQueue<>(name, queueByteLimit, queueElementLimit, Task::getSerializedSize);
+ }
+
+ DataBlockingQueue<Task> getTaskQueue() {
+ return taskQueue;
+ }
+
+ WriteLogTasks getWriteTasks() {
+ return writeTasks;
+ }
+
+ @Override
+ public int applyAsInt(String type) {
+ if (type.equals(SegmentedRaftLogMetrics.RAFT_LOG_DATA_QUEUE_SIZE)) {
+ return taskQueue.getNumElements();
+ } else if (type.equals(SegmentedRaftLogMetrics.RAFT_LOG_WORKER_QUEUE_SIZE)) {
+ return writeTasks.getQueueSize();
+ }
+ throw new IllegalArgumentException("Unknown type " + type);
+ }
+
+ @Override
+ public String toString() {
+ return "#tasks=" + taskQueue.getNumElements()
+ + ", #writes=" + writeTasks.getQueueSize();
+ }
+ }
+
+ static class Buffers {
+ private final ByteBuffer writeBuffer;
+ private final Supplier<byte[]> sharedBuffer;
Review Comment:
@szetszwo Thanks for sharing! Learned a lot from this article.
--
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: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org