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/02/14 06:20:25 UTC

[iotdb] branch master updated: [IOTDB-5531] Update IoT Consensus Metric from ms precision to ns precision (#9058)

This is an automated email from the ASF dual-hosted git repository.

tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new e718dd8a30 [IOTDB-5531] Update IoT Consensus Metric from ms precision to ns precision (#9058)
e718dd8a30 is described below

commit e718dd8a3018c0254ca994dfcf0db1c162d3dc75
Author: ZhangHongYin <46...@users.noreply.github.com>
AuthorDate: Tue Feb 14 14:20:19 2023 +0800

    [IOTDB-5531] Update IoT Consensus Metric from ms precision to ns precision (#9058)
---
 .../apache/iotdb/consensus/iot/IoTConsensusServerImpl.java   | 12 ++++++------
 .../iotdb/consensus/iot/client/DispatchLogHandler.java       |  4 ++--
 .../iotdb/consensus/iot/logdispatcher/LogDispatcher.java     |  4 ++--
 .../Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json       |  6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java b/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
index 75a2fc2f98..c6b82afaa6 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
@@ -165,10 +165,10 @@ public class IoTConsensusServerImpl {
    * performed.
    */
   public TSStatus write(IConsensusRequest request) {
-    long consensusWriteStartTime = System.currentTimeMillis();
+    long consensusWriteStartTime = System.nanoTime();
     stateMachineLock.lock();
     try {
-      long getStateMachineLockTime = System.currentTimeMillis();
+      long getStateMachineLockTime = System.nanoTime();
       // statistic the time of acquiring stateMachine lock
       MetricService.getInstance()
           .getOrCreateHistogram(
@@ -200,7 +200,7 @@ public class IoTConsensusServerImpl {
           Thread.currentThread().interrupt();
         }
       }
-      long writeToStateMachineStartTime = System.currentTimeMillis();
+      long writeToStateMachineStartTime = System.nanoTime();
       IndexedConsensusRequest indexedConsensusRequest =
           buildIndexedConsensusRequestForLocalRequest(request);
       // statistic the time of checking write block
@@ -225,7 +225,7 @@ public class IoTConsensusServerImpl {
       // TODO wal and memtable
       IConsensusRequest planNode = stateMachine.deserializeRequest(indexedConsensusRequest);
       TSStatus result = stateMachine.write(planNode);
-      long writeToStateMachineEndTime = System.currentTimeMillis();
+      long writeToStateMachineEndTime = System.nanoTime();
       // statistic the time of writing request into stateMachine
       MetricService.getInstance()
           .getOrCreateHistogram(
@@ -260,7 +260,7 @@ public class IoTConsensusServerImpl {
                 "offerRequestToQueue",
                 Tag.REGION.toString(),
                 this.consensusGroupId)
-            .update(System.currentTimeMillis() - writeToStateMachineEndTime);
+            .update(System.nanoTime() - writeToStateMachineEndTime);
       } else {
         logger.debug(
             "{}: write operation failed. searchIndex: {}. Code: {}",
@@ -279,7 +279,7 @@ public class IoTConsensusServerImpl {
               "consensusWrite",
               Tag.REGION.toString(),
               this.consensusGroupId)
-          .update(System.currentTimeMillis() - consensusWriteStartTime);
+          .update(System.nanoTime() - consensusWriteStartTime);
       return result;
     } finally {
       stateMachineLock.unlock();
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/DispatchLogHandler.java b/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/DispatchLogHandler.java
index f9e08ac530..0005ba3ab9 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/DispatchLogHandler.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/DispatchLogHandler.java
@@ -46,7 +46,7 @@ public class DispatchLogHandler implements AsyncMethodCallback<TSyncLogEntriesRe
   public DispatchLogHandler(LogDispatcherThread thread, Batch batch) {
     this.thread = thread;
     this.batch = batch;
-    this.createTime = System.currentTimeMillis();
+    this.createTime = System.nanoTime();
   }
 
   @Override
@@ -74,7 +74,7 @@ public class DispatchLogHandler implements AsyncMethodCallback<TSyncLogEntriesRe
             "syncLogTimePerRequest",
             Tag.REGION.toString(),
             this.thread.getPeer().getGroupId().toString())
-        .update((System.currentTimeMillis() - createTime) / batch.getLogEntries().size());
+        .update((System.nanoTime() - createTime) / batch.getLogEntries().size());
   }
 
   private boolean needRetry(int statusCode) {
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 4bd1e5a129..b75a4f4810 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
@@ -303,7 +303,7 @@ public class LogDispatcher {
       try {
         Batch batch;
         while (!Thread.interrupted() && !stopped) {
-          long startTime = System.currentTimeMillis();
+          long startTime = System.nanoTime();
           while ((batch = getBatch()).isEmpty()) {
             // we may block here if there is no requests in the queue
             IndexedConsensusRequest request =
@@ -326,7 +326,7 @@ public class LogDispatcher {
                   "constructBatch",
                   Tag.REGION.toString(),
                   peer.getGroupId().toString())
-              .update((System.currentTimeMillis() - startTime) / batch.getLogEntries().size());
+              .update((System.nanoTime() - startTime) / batch.getLogEntries().size());
           // we may block here if the synchronization pipeline is full
           syncStatus.addNextBatch(batch);
           logEntriesFromWAL.addAndGet(batch.getLogEntriesNumFromWAL());
diff --git a/docs/UserGuide/Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json b/docs/UserGuide/Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json
index b237258cf8..e7775acac5 100644
--- a/docs/UserGuide/Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json
+++ b/docs/UserGuide/Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json
@@ -11496,7 +11496,7 @@
                   }
                 ]
               },
-              "unit": "ms"
+              "unit": "ns"
             },
             "overrides": []
           },
@@ -11587,7 +11587,7 @@
                   }
                 ]
               },
-              "unit": "ms"
+              "unit": "ns"
             },
             "overrides": [
               {
@@ -11708,7 +11708,7 @@
                   }
                 ]
               },
-              "unit": "ms"
+              "unit": "ns"
             },
             "overrides": []
           },