You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/07/14 13:33:22 UTC
[iotdb] branch iotdb-3791 updated: add count
This is an automated email from the ASF dual-hosted git repository.
xingtanzjr pushed a commit to branch iotdb-3791
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/iotdb-3791 by this push:
new d6f5a5c702 add count
d6f5a5c702 is described below
commit d6f5a5c7024ea3410ed3ceffbbfa88a0f9a56469
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Thu Jul 14 21:33:03 2022 +0800
add count
---
.../multileader/MultiLeaderServerImpl.java | 54 +++++++++++++---------
1 file changed, 31 insertions(+), 23 deletions(-)
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderServerImpl.java b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderServerImpl.java
index 0a76a2aad5..1a96c0eb31 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderServerImpl.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderServerImpl.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.consensus.multileader;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.StepTracker;
import org.apache.iotdb.commons.client.IClientManager;
import org.apache.iotdb.consensus.IStateMachine;
import org.apache.iotdb.consensus.common.DataSet;
@@ -105,30 +106,37 @@ public class MultiLeaderServerImpl {
* records the index of the log and writes locally, and then asynchronous replication is performed
*/
public TSStatus write(IConsensusRequest request) {
- synchronized (stateMachine) {
- IndexedConsensusRequest indexedConsensusRequest =
- buildIndexedConsensusRequestForLocalRequest(request);
- if (indexedConsensusRequest.getSearchIndex() % 1000 == 0) {
- logger.info(
- "DataRegion[{}]: index after build: safeIndex: {}, searchIndex: {}",
- thisNode.getGroupId(),
- indexedConsensusRequest.getSafelyDeletedSearchIndex(),
- indexedConsensusRequest.getSearchIndex());
- }
- // TODO wal and memtable
- TSStatus result = stateMachine.write(indexedConsensusRequest);
- if (result.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
- logDispatcher.offer(indexedConsensusRequest);
- } else {
- logger.debug(
- "{}: write operation failed. searchIndex: {}. Code: {}",
- thisNode.getGroupId(),
- indexedConsensusRequest.getSearchIndex(),
- result.getCode());
- index.decrementAndGet();
+ long writeStartTime = System.nanoTime();
+ try {
+ long stateMachineWaitLock = System.nanoTime();
+ synchronized (stateMachine) {
+ StepTracker.trace("stateMachineWaitLock", 400, stateMachineWaitLock, System.nanoTime());
+ IndexedConsensusRequest indexedConsensusRequest =
+ buildIndexedConsensusRequestForLocalRequest(request);
+ if (indexedConsensusRequest.getSearchIndex() % 1000 == 0) {
+ logger.info(
+ "DataRegion[{}]: index after build: safeIndex: {}, searchIndex: {}",
+ thisNode.getGroupId(),
+ indexedConsensusRequest.getSafelyDeletedSearchIndex(),
+ indexedConsensusRequest.getSearchIndex());
+ }
+ // TODO wal and memtable
+ TSStatus result = stateMachine.write(indexedConsensusRequest);
+ if (result.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ logDispatcher.offer(indexedConsensusRequest);
+ } else {
+ logger.debug(
+ "{}: write operation failed. searchIndex: {}. Code: {}",
+ thisNode.getGroupId(),
+ indexedConsensusRequest.getSearchIndex(),
+ result.getCode());
+ index.decrementAndGet();
+ }
+
+ return result;
}
-
- return result;
+ } finally {
+ StepTracker.trace("MultiWriteOneRequest", 400, writeStartTime, System.nanoTime());
}
}