From 94104cf43ad1789e086f1d460c6dc5a06d80afc3 Mon Sep 17 00:00:00 2001 From: "jia.ouyang" <2360580200@qq.com> Date: Tue, 26 Dec 2023 17:54:18 +0800 Subject: [PATCH] =?UTF-8?q?add=C2=A0=20metrics:[writer=20count]=20&&=20[co?= =?UTF-8?q?mpact=20time]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/apache/paimon/append/AppendOnlyWriter.java | 10 ++++++++++ .../java/org/apache/paimon/compact/CompactResult.java | 11 +++++++++++ .../paimon/operation/AbstractFileStoreWrite.java | 4 ++++ .../java/org/apache/paimon/utils/RecordWriter.java | 3 +++ 4 files changed, 28 insertions(+) diff --git a/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java b/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java index 0074f5ebd183..51ee83d0cbf6 100644 --- a/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java +++ b/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java @@ -77,6 +77,9 @@ public class AppendOnlyWriter implements RecordWriter, MemoryOwner private WriterMetrics writerMetrics; + /** The amount of time once compact takes*/ + private long compactTime; + public AppendOnlyWriter( FileIO fileIO, IOManager ioManager, @@ -210,6 +213,12 @@ public void close() throws Exception { sinkWriter.close(); } + @Override + public long getCompactTime() { + + return compactTime; + } + private RowDataRollingFileWriter createRollingRowWriter() { return new RowDataRollingFileWriter( fileIO, @@ -231,6 +240,7 @@ private void trySyncLatestCompaction(boolean blocking) result -> { compactBefore.addAll(result.before()); compactAfter.addAll(result.after()); + compactTime = result.compactTime(); }); } diff --git a/paimon-core/src/main/java/org/apache/paimon/compact/CompactResult.java b/paimon-core/src/main/java/org/apache/paimon/compact/CompactResult.java index 6a004d305202..18f8ac423d9e 100644 --- a/paimon-core/src/main/java/org/apache/paimon/compact/CompactResult.java +++ b/paimon-core/src/main/java/org/apache/paimon/compact/CompactResult.java @@ -31,6 +31,9 @@ public class CompactResult { private final List after; private final List changelog; + /** The amount of time once compact takes*/ + private long compactTime; + public CompactResult() { this(Collections.emptyList(), Collections.emptyList()); } @@ -62,6 +65,14 @@ public List changelog() { return changelog; } + public long compactTime() { + return compactTime; + } + + public void setCompactTime(long compactTime) { + this.compactTime = compactTime; + } + public void merge(CompactResult that) { before.addAll(that.before); after.addAll(that.after); diff --git a/paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreWrite.java b/paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreWrite.java index 083f23d53679..6391630568e2 100644 --- a/paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreWrite.java +++ b/paimon-core/src/main/java/org/apache/paimon/operation/AbstractFileStoreWrite.java @@ -420,6 +420,10 @@ public ExecutorService getCompactExecutor() { protected void notifyNewWriter(RecordWriter writer) {} + public Map>> getWriters() { + return writers; + } + protected abstract RecordWriter createWriter( BinaryRow partition, int bucket, diff --git a/paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java b/paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java index 6f46bc58ec3d..a7152df45221 100644 --- a/paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java +++ b/paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java @@ -69,4 +69,7 @@ public interface RecordWriter { /** Close this writer, the call will delete newly generated but not committed files. */ void close() throws Exception; + + /** get the time of once compact takes by compactManager*/ + long getCompactTime(); }