This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new c3515826f6d Metric: Add pipe linked tsfile size and count metric
(#14768) (#14852)
c3515826f6d is described below
commit c3515826f6de3b268c8d49b19b07c4ab41d6432e
Author: Peng Junzhi <[email protected]>
AuthorDate: Sat Feb 15 05:23:52 2025 -0600
Metric: Add pipe linked tsfile size and count metric (#14768) (#14852)
* add linked tsfile size count
* fix review
(cherry picked from commit a0eab8f5eabae7bdb1196bcb2bb703237a45348d)
---
.../apache/iotdb/db/pipe/metric/PipeResourceMetrics.java | 6 ++++++
.../pipe/resource/tsfile/PipeTsFileResourceManager.java | 15 +++++++++++++++
.../apache/iotdb/commons/service/metric/enums/Metric.java | 1 +
3 files changed, 22 insertions(+)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/metric/PipeResourceMetrics.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/metric/PipeResourceMetrics.java
index 854ff9ffb10..198bd3e42b7 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/metric/PipeResourceMetrics.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/metric/PipeResourceMetrics.java
@@ -67,6 +67,11 @@ public class PipeResourceMetrics implements IMetricSet {
MetricLevel.IMPORTANT,
PipeDataNodeResourceManager.tsfile(),
PipeTsFileResourceManager::getLinkedTsfileCount);
+ metricService.createAutoGauge(
+ Metric.PIPE_LINKED_TSFILE_SIZE.toString(),
+ MetricLevel.IMPORTANT,
+ PipeDataNodeResourceManager.tsfile(),
+ PipeTsFileResourceManager::getTotalLinkedTsfileSize);
// phantom reference count
metricService.createAutoGauge(
Metric.PIPE_PHANTOM_REFERENCE_COUNT.toString(),
@@ -85,6 +90,7 @@ public class PipeResourceMetrics implements IMetricSet {
// resource reference count
metricService.remove(MetricType.AUTO_GAUGE,
Metric.PIPE_PINNED_MEMTABLE_COUNT.toString());
metricService.remove(MetricType.AUTO_GAUGE,
Metric.PIPE_LINKED_TSFILE_COUNT.toString());
+ metricService.remove(MetricType.AUTO_GAUGE,
Metric.PIPE_LINKED_TSFILE_SIZE.toString());
// phantom reference count
metricService.remove(MetricType.AUTO_GAUGE,
Metric.PIPE_PHANTOM_REFERENCE_COUNT.toString());
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/tsfile/PipeTsFileResourceManager.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/tsfile/PipeTsFileResourceManager.java
index d7aa7ffb35e..b90ed59b4a4 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/tsfile/PipeTsFileResourceManager.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/tsfile/PipeTsFileResourceManager.java
@@ -167,6 +167,7 @@ public class PipeTsFileResourceManager {
isTsFile
? FileUtils.createHardLink(file, hardlinkOrCopiedFile)
: FileUtils.copyFile(file, hardlinkOrCopiedFile);
+
// If the file is not a hardlink or copied file, and there is no related
hardlink or copied
// file in pipe dir, create a hardlink or copy it to pipe dir, maintain
a reference count for
// the hardlink or copied file, and return the hardlink or copied file.
@@ -337,6 +338,20 @@ public class PipeTsFileResourceManager {
return hardlinkOrCopiedFileToPipeTsFileResourceMap.size();
}
+ public long getTotalLinkedTsfileSize() {
+ return hardlinkOrCopiedFileToPipeTsFileResourceMap.values().stream()
+ .mapToLong(
+ resource -> {
+ try {
+ return resource.getFileSize();
+ } catch (Exception e) {
+ LOGGER.warn("failed to get file size of linked TsFile {}: ",
resource, e);
+ return 0;
+ }
+ })
+ .sum();
+ }
+
/**
* Get the total size of linked TsFiles whose original TsFile is deleted (by
compaction or else)
*/
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
index f28f33fa587..cef90d673b7 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
@@ -158,6 +158,7 @@ public enum Metric {
PIPE_MEM("pipe_mem"),
PIPE_PINNED_MEMTABLE_COUNT("pipe_pinned_memtable_count"),
PIPE_LINKED_TSFILE_COUNT("pipe_linked_tsfile_count"),
+ PIPE_LINKED_TSFILE_SIZE("pipe_linked_tsfile_size"),
PIPE_PHANTOM_REFERENCE_COUNT("pipe_phantom_reference_count"),
PIPE_ASYNC_CONNECTOR_RETRY_EVENT_QUEUE_SIZE("pipe_async_connector_retry_event_queue_size"),
PIPE_EVENT_COMMIT_QUEUE_SIZE("pipe_event_commit_queue_size"),