You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/11/13 03:44:50 UTC
[iotdb] branch QueryMetrics0.13 updated: add server rt
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch QueryMetrics0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/QueryMetrics0.13 by this push:
new 69a5fd754e add server rt
69a5fd754e is described below
commit 69a5fd754eadbdca9fdaee0e46d04635f89b32ee
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Sun Nov 13 11:44:42 2022 +0800
add server rt
---
.../java/org/apache/iotdb/db/query/control/QueryStatistics.java | 2 ++
.../org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/server/src/main/java/org/apache/iotdb/db/query/control/QueryStatistics.java b/server/src/main/java/org/apache/iotdb/db/query/control/QueryStatistics.java
index c07fb59310..2522b0419f 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/control/QueryStatistics.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/control/QueryStatistics.java
@@ -53,6 +53,8 @@ public class QueryStatistics {
"SeriesRawDataBatchReader.hasNextBatch()";
public static final String PAGE_READER = "PageReader";
+ public static final String SERVER_RPC_RT = "ServerRpcRT";
+
private QueryStatistics() {
ScheduledExecutorService scheduledExecutor =
IoTDBThreadPoolFactory.newScheduledThreadPool(1, "Query-Statistics-Print");
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
index d8102cbe08..5344a9da30 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
@@ -654,6 +654,7 @@ public class TSServiceImpl implements TSIService.Iface {
@Override
public TSExecuteStatementResp executeQueryStatement(TSExecuteStatementReq req) {
+ long startTimeNanos = System.nanoTime();
IClientSession session = SESSION_MANAGER.getCurrSession();
try {
TSStatus loginStatus = checkLoginStatus(session);
@@ -683,6 +684,9 @@ public class TSServiceImpl implements TSIService.Iface {
return RpcUtils.getTSExecuteStatementResp(
onQueryException(
e, "\"" + req.getStatement() + "\". " + OperationType.EXECUTE_QUERY_STATEMENT));
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.SERVER_RPC_RT, System.nanoTime() - startTimeNanos);
}
}
@@ -1005,6 +1009,7 @@ public class TSServiceImpl implements TSIService.Iface {
@SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
@Override
public TSFetchResultsResp fetchResults(TSFetchResultsReq req) {
+ long startTimeNanos = System.nanoTime();
try {
IClientSession session = SESSION_MANAGER.getCurrSession();
TSStatus loginStatus = checkLoginStatus(session);
@@ -1026,6 +1031,9 @@ public class TSServiceImpl implements TSIService.Iface {
return RpcUtils.getTSFetchResultsResp(onQueryException(e, OperationType.FETCH_RESULTS));
} catch (Exception e) {
return RpcUtils.getTSFetchResultsResp(onQueryException(e, OperationType.FETCH_RESULTS));
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.SERVER_RPC_RT, System.nanoTime() - startTimeNanos);
}
}