File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
datanode/src/main/java/org/apache/iotdb/db/pipe
node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,11 @@ public void bindTo(final AbstractMetricService metricService) {
6767 MetricLevel .IMPORTANT ,
6868 PipeDataNodeResourceManager .tsfile (),
6969 PipeTsFileResourceManager ::getLinkedTsfileCount );
70+ metricService .createAutoGauge (
71+ Metric .PIPE_LINKED_TSFILE_SIZE .toString (),
72+ MetricLevel .IMPORTANT ,
73+ PipeDataNodeResourceManager .tsfile (),
74+ PipeTsFileResourceManager ::getTotalLinkedTsfileSize );
7075 // phantom reference count
7176 metricService .createAutoGauge (
7277 Metric .PIPE_PHANTOM_REFERENCE_COUNT .toString (),
@@ -85,6 +90,7 @@ public void unbindFrom(final AbstractMetricService metricService) {
8590 // resource reference count
8691 metricService .remove (MetricType .AUTO_GAUGE , Metric .PIPE_PINNED_MEMTABLE_COUNT .toString ());
8792 metricService .remove (MetricType .AUTO_GAUGE , Metric .PIPE_LINKED_TSFILE_COUNT .toString ());
93+ metricService .remove (MetricType .AUTO_GAUGE , Metric .PIPE_LINKED_TSFILE_SIZE .toString ());
8894 // phantom reference count
8995 metricService .remove (MetricType .AUTO_GAUGE , Metric .PIPE_PHANTOM_REFERENCE_COUNT .toString ());
9096 }
Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ public File increaseFileReference(
166166 isTsFile
167167 ? FileUtils .createHardLink (file , hardlinkOrCopiedFile )
168168 : FileUtils .copyFile (file , hardlinkOrCopiedFile );
169+
169170 // If the file is not a hardlink or copied file, and there is no related hardlink or copied
170171 // file in pipe dir, create a hardlink or copy it to pipe dir, maintain a reference count for
171172 // the hardlink or copied file, and return the hardlink or copied file.
@@ -335,6 +336,20 @@ public int getLinkedTsfileCount() {
335336 return hardlinkOrCopiedFileToPipeTsFileResourceMap .size ();
336337 }
337338
339+ public long getTotalLinkedTsfileSize () {
340+ return hardlinkOrCopiedFileToPipeTsFileResourceMap .values ().stream ()
341+ .mapToLong (
342+ resource -> {
343+ try {
344+ return resource .getFileSize ();
345+ } catch (Exception e ) {
346+ LOGGER .warn ("failed to get file size of linked TsFile {}: " , resource , e );
347+ return 0 ;
348+ }
349+ })
350+ .sum ();
351+ }
352+
338353 /**
339354 * Get the total size of linked TsFiles whose original TsFile is deleted (by compaction or else)
340355 */
Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ public enum Metric {
159159 PIPE_MEM ("pipe_mem" ),
160160 PIPE_PINNED_MEMTABLE_COUNT ("pipe_pinned_memtable_count" ),
161161 PIPE_LINKED_TSFILE_COUNT ("pipe_linked_tsfile_count" ),
162+ PIPE_LINKED_TSFILE_SIZE ("pipe_linked_tsfile_size" ),
162163 PIPE_PHANTOM_REFERENCE_COUNT ("pipe_phantom_reference_count" ),
163164 PIPE_ASYNC_CONNECTOR_RETRY_EVENT_QUEUE_SIZE ("pipe_async_connector_retry_event_queue_size" ),
164165 PIPE_EVENT_COMMIT_QUEUE_SIZE ("pipe_event_commit_queue_size" ),
You can’t perform that action at this time.
0 commit comments