You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2023/03/02 10:56:21 UTC
[iotdb] 01/01: finish
This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch fix_single_replica_unnecessary_serialization
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 4ba182bfd6025b2c761148c744822bf921924477
Author: OneSizeFitQuorum <ta...@apache.org>
AuthorDate: Thu Mar 2 18:56:04 2023 +0800
finish
Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
.../iotdb/consensus/common/request/IndexedConsensusRequest.java | 9 +++++++++
.../apache/iotdb/consensus/iot/logdispatcher/LogDispatcher.java | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/common/request/IndexedConsensusRequest.java b/consensus/src/main/java/org/apache/iotdb/consensus/common/request/IndexedConsensusRequest.java
index 0be89ce1be..a04230eb98 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/common/request/IndexedConsensusRequest.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/common/request/IndexedConsensusRequest.java
@@ -54,6 +54,15 @@ public class IndexedConsensusRequest implements IConsensusRequest {
this.syncIndex = syncIndex;
}
+ public void buildSerializedRequests() {
+ this.requests.forEach(
+ r -> {
+ ByteBuffer buffer = r.serializeToByteBuffer();
+ this.serializedRequests.add(buffer);
+ this.serializedSize += buffer.capacity();
+ });
+ }
+
@Override
public ByteBuffer serializeToByteBuffer() {
throw new UnsupportedOperationException();
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/LogDispatcher.java b/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/LogDispatcher.java
index 68a988558e..52e61ae360 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/LogDispatcher.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/LogDispatcher.java
@@ -156,6 +156,10 @@ public class LogDispatcher {
}
public void offer(IndexedConsensusRequest request) {
+ if (!threads.isEmpty()) {
+ // we don't need to serialize request when replicaNum is 1.
+ request.buildSerializedRequests();
+ }
synchronized (this) {
threads.forEach(
thread -> {