You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "OneSizeFitsQuorum (via GitHub)" <gi...@apache.org> on 2023/01/31 03:45:02 UTC
[GitHub] [iotdb] OneSizeFitsQuorum commented on a diff in pull request #8863: [IOTDB-5257] Optimize SyncLog Logic in IoT Consensus
OneSizeFitsQuorum commented on code in PR #8863:
URL: https://github.com/apache/iotdb/pull/8863#discussion_r1091399771
##########
consensus/src/test/java/org/apache/iotdb/consensus/EmptyStateMachine.java:
##########
@@ -38,6 +38,11 @@ public TSStatus write(IConsensusRequest IConsensusRequest) {
return new TSStatus(0);
}
+ @Override
+ public IConsensusRequest deserializeRequest(IConsensusRequest IConsensusRequest) {
Review Comment:
use a different parameter name
##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/statemachine/ConfigNodeRegionStateMachine.java:
##########
@@ -96,28 +96,36 @@ public void setConfigManager(ConfigManager configManager) {
@Override
public TSStatus write(IConsensusRequest request) {
- ConfigPhysicalPlan plan;
+ if (request == null) {
Review Comment:
maybe this way is more elegant
```return Optional.ofNullable(request).map(this::write).orElseGet(() -> new TSStatus(TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()));```
##########
consensus/src/main/java/org/apache/iotdb/consensus/common/request/DeserializedBatchIndexedConsensusRequest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.iotdb.consensus.common.request;
+
+import java.nio.ByteBuffer;
+import java.util.LinkedList;
+import java.util.List;
+
+public class DeserializedBatchIndexedConsensusRequest
+ implements IConsensusRequest, Comparable<DeserializedBatchIndexedConsensusRequest> {
+ private long startSyncIndex;
+ private long endSyncIndex;
+ private final List<IConsensusRequest> insertNodes;
+
+ public DeserializedBatchIndexedConsensusRequest(long startSyncIndex, long endSyncIndex) {
+ this.startSyncIndex = startSyncIndex;
+ this.endSyncIndex = endSyncIndex;
+ this.insertNodes = new LinkedList<>();
+ }
+
+ public long getStartSyncIndex() {
+ return startSyncIndex;
+ }
+
+ public long getEndSyncIndex() {
+ return endSyncIndex;
+ }
+
+ public List<IConsensusRequest> getInsertNodes() {
+ return insertNodes;
+ }
+
+ public void add(IConsensusRequest insertNode) {
+ this.insertNodes.add(insertNode);
Review Comment:
We seem to be able to eliminate the overhead of expanding the array because every time it's a certain size, right?
##########
server/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java:
##########
@@ -183,4 +186,13 @@ public static synchronized IConsensus setupAndGetInstance() {
}
return INSTANCE;
}
+
+ private static DataRegionStateMachine createDataRegionStateMachine(ConsensusGroupId gid) {
+ DataRegion dataRegion = StorageEngine.getInstance().getDataRegion((DataRegionId) gid);
+ if (conf.getDataRegionConsensusProtocolClass().contains("IoTConsensus")) {
Review Comment:
`ConsensusFactory.IOT_CONSENSUS.equals(dataRegionConsensusProtocolClass )`?
##########
server/src/main/java/org/apache/iotdb/db/consensus/statemachine/SchemaRegionStateMachine.java:
##########
@@ -77,6 +81,11 @@ public TSStatus write(IConsensusRequest request) {
}
}
+ @Override
+ public IConsensusRequest deserializeRequest(IConsensusRequest request) {
+ return request;
Review Comment:
This one needs to be deserialized as well?
##########
consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java:
##########
@@ -216,7 +223,9 @@ public TSStatus write(IConsensusRequest request) {
indexedConsensusRequest.getSearchIndex());
}
// TODO wal and memtable
- TSStatus result = stateMachine.write(indexedConsensusRequest);
+ IConsensusRequest deserializedRequest =
Review Comment:
Can we skip this as we know this function is not going to do anything?
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org