You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/08/08 06:07:06 UTC

[GitHub] [iotdb] SpriCoder opened a new pull request, #6911: [IOTDB-3980][Metric] Use asynchronous way to collect some predefined metrics.

SpriCoder opened a new pull request, #6911:
URL: https://github.com/apache/iotdb/pull/6911

   See more details: https://issues.apache.org/jira/browse/IOTDB-3980.
   
   Use asynchronous way to collect some predefined metrics. they are `file_count`, `file_size`, `sys_disk_total_space`, `sys_disk_free_space`.
   Also, I add `asyncCollectPeriodInSecond` param for use to control the task that updated the metrics above.


-- 
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


[GitHub] [iotdb] xingtanzjr merged pull request #6911: [IOTDB-3980][Metric] Use asynchronous way to collect some predefined metrics.

Posted by GitBox <gi...@apache.org>.
xingtanzjr merged PR #6911:
URL: https://github.com/apache/iotdb/pull/6911


-- 
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


[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #6911: [IOTDB-3980][Metric] Use asynchronous way to collect some predefined metrics.

Posted by GitBox <gi...@apache.org>.
xingtanzjr commented on code in PR #6911:
URL: https://github.com/apache/iotdb/pull/6911#discussion_r941941356


##########
server/src/main/java/org/apache/iotdb/db/service/metrics/predefined/FileMetrics.java:
##########
@@ -146,4 +98,112 @@ public void bindTo(MetricManager metricManager) {
   public PredefinedMetric getType() {
     return PredefinedMetric.FILE;
   }
+
+  @Override
+  public void startAsyncCollectedMetrics() {
+    ScheduledExecutorUtil.safelyScheduleAtFixedRate(
+        service,
+        this::collect,
+        1,
+        MetricConfigDescriptor.getInstance().getMetricConfig().getAsyncCollectPeriodInSecond(),
+        TimeUnit.SECONDS);
+  }
+
+  @Override
+  public void stopAsyncCollectedMetrics() {
+    service.shutdown();
+  }
+
+  private void collect() {
+    walFileTotalSize = Stream.of(walDirs).mapToLong(FileUtils::getDirSize).sum();
+    sequenceFileTotalSize =
+        Stream.of(dataDirs)
+            .mapToLong(
+                dir -> {
+                  dir += File.separator + IoTDBConstant.SEQUENCE_FLODER_NAME;
+                  return FileUtils.getDirSize(dir);
+                })
+            .sum();
+    unsequenceFileTotalSize =
+        Stream.of(dataDirs)
+            .mapToLong(
+                dir -> {
+                  dir += File.separator + IoTDBConstant.UNSEQUENCE_FLODER_NAME;
+                  return FileUtils.getDirSize(dir);
+                })
+            .sum();
+    walFileTotalCount =

Review Comment:
   Let's use the new interface from WALNode to reduce calculation



-- 
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