This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 59ad255a81 [core] Introduce RetryWaiter to simplify FileStoreCommitImpl
59ad255a81 is described below
commit 59ad255a813ecefceb13479c941384febd2de76b
Author: JingsongLi <[email protected]>
AuthorDate: Wed Jan 7 19:04:34 2026 +0800
[core] Introduce RetryWaiter to simplify FileStoreCommitImpl
---
.../java/org/apache/paimon/utils/RetryWaiter.java | 46 ++++++++++++++++++++++
.../paimon/operation/FileStoreCommitImpl.java | 26 +++---------
2 files changed, 51 insertions(+), 21 deletions(-)
diff --git
a/paimon-common/src/main/java/org/apache/paimon/utils/RetryWaiter.java
b/paimon-common/src/main/java/org/apache/paimon/utils/RetryWaiter.java
new file mode 100644
index 0000000000..0016158792
--- /dev/null
+++ b/paimon-common/src/main/java/org/apache/paimon/utils/RetryWaiter.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.utils;
+
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+
+/** A waiter for retry. */
+public class RetryWaiter {
+
+ private final long minRetryWait;
+ private final long maxRetryWait;
+
+ public RetryWaiter(long minRetryWait, long maxRetryWait) {
+ this.minRetryWait = minRetryWait;
+ this.maxRetryWait = maxRetryWait;
+ }
+
+ public void retryWait(int retryCount) {
+ int retryWait = (int) Math.min(minRetryWait * Math.pow(2, retryCount),
maxRetryWait);
+ ThreadLocalRandom random = ThreadLocalRandom.current();
+ retryWait += random.nextInt(Math.max(1, (int) (retryWait * 0.2)));
+ try {
+ TimeUnit.MILLISECONDS.sleep(retryWait);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(ie);
+ }
+ }
+}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java
b/paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java
index ab96512175..c4f433d3a8 100644
---
a/paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java
+++
b/paimon-core/src/main/java/org/apache/paimon/operation/FileStoreCommitImpl.java
@@ -71,6 +71,7 @@ import org.apache.paimon.utils.FileStorePathFactory;
import org.apache.paimon.utils.IOUtils;
import org.apache.paimon.utils.InternalRowPartitionComputer;
import org.apache.paimon.utils.Pair;
+import org.apache.paimon.utils.RetryWaiter;
import org.apache.paimon.utils.SnapshotManager;
import org.slf4j.Logger;
@@ -88,8 +89,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static java.util.Collections.emptyList;
@@ -152,8 +151,7 @@ public class FileStoreCommitImpl implements FileStoreCommit
{
private final StatsFileHandler statsFileHandler;
private final BucketMode bucketMode;
private final long commitTimeout;
- private final long commitMinRetryWait;
- private final long commitMaxRetryWait;
+ private final RetryWaiter retryWaiter;
private final int commitMaxRetries;
private final InternalRowPartitionComputer partitionComputer;
private final boolean rowTrackingEnabled;
@@ -223,8 +221,7 @@ public class FileStoreCommitImpl implements FileStoreCommit
{
this.commitCallbacks = commitCallbacks;
this.commitMaxRetries = commitMaxRetries;
this.commitTimeout = commitTimeout;
- this.commitMinRetryWait = commitMinRetryWait;
- this.commitMaxRetryWait = commitMaxRetryWait;
+ this.retryWaiter = new RetryWaiter(commitMinRetryWait,
commitMaxRetryWait);
this.partitionComputer =
new InternalRowPartitionComputer(
options.partitionDefaultName(),
@@ -720,7 +717,7 @@ public class FileStoreCommitImpl implements FileStoreCommit
{
throw new RuntimeException(message, retryResult.exception);
}
- commitRetryWait(retryCount);
+ retryWaiter.retryWait(retryCount);
retryCount++;
}
return retryCount + 1;
@@ -1070,7 +1067,7 @@ public class FileStoreCommitImpl implements
FileStoreCommit {
commitTimeout, retryCount));
}
- commitRetryWait(retryCount);
+ retryWaiter.retryWait(retryCount);
retryCount++;
}
}
@@ -1155,19 +1152,6 @@ public class FileStoreCommitImpl implements
FileStoreCommit {
}
}
- private void commitRetryWait(int retryCount) {
- int retryWait =
- (int) Math.min(commitMinRetryWait * Math.pow(2, retryCount),
commitMaxRetryWait);
- ThreadLocalRandom random = ThreadLocalRandom.current();
- retryWait += random.nextInt(Math.max(1, (int) (retryWait * 0.2)));
- try {
- TimeUnit.MILLISECONDS.sleep(retryWait);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- throw new RuntimeException(ie);
- }
- }
-
@Override
public void close() {
IOUtils.closeAllQuietly(commitCallbacks);