diff --git a/docs/layouts/shortcodes/generated/catalog_configuration.html b/docs/layouts/shortcodes/generated/catalog_configuration.html
index cab6e731e851..94f456843fce 100644
--- a/docs/layouts/shortcodes/generated/catalog_configuration.html
+++ b/docs/layouts/shortcodes/generated/catalog_configuration.html
@@ -26,6 +26,18 @@
+
+ catalog-key |
+ (none) |
+ String |
+ Custom catalog key. |
+
+
+ client-pool-cache-eviction-interval-ms |
+ 300000 |
+ Long |
+ Client pool cache eviction interval ms. |
+
client-pool-size |
2 |
diff --git a/docs/layouts/shortcodes/generated/jdbc_catalog_configuration.html b/docs/layouts/shortcodes/generated/jdbc_catalog_configuration.html
index c2d6e287f31e..14637897d946 100644
--- a/docs/layouts/shortcodes/generated/jdbc_catalog_configuration.html
+++ b/docs/layouts/shortcodes/generated/jdbc_catalog_configuration.html
@@ -26,12 +26,6 @@
-
- catalog-key |
- "jdbc" |
- String |
- Custom jdbc catalog store key. |
-
lock-key-max-length |
255 |
diff --git a/paimon-common/src/main/java/org/apache/paimon/client/ClientPool.java b/paimon-common/src/main/java/org/apache/paimon/client/ClientPool.java
index deddf75a2452..34c59494653b 100644
--- a/paimon-common/src/main/java/org/apache/paimon/client/ClientPool.java
+++ b/paimon-common/src/main/java/org/apache/paimon/client/ClientPool.java
@@ -18,12 +18,21 @@
package org.apache.paimon.client;
+import org.apache.paimon.options.CatalogOptions;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.utils.StringUtils;
+
+import org.apache.paimon.shade.guava30.com.google.common.collect.Lists;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
+import java.io.IOException;
+import java.io.Serializable;
import java.util.ArrayDeque;
import java.util.Deque;
+import java.util.List;
import static org.apache.paimon.utils.Preconditions.checkState;
@@ -43,7 +52,8 @@ interface Action {
R run(Action action, boolean retry) throws E, InterruptedException;
/** Default implementation for {@link ClientPool}. */
- abstract class ClientPoolImpl implements Closeable, ClientPool {
+ abstract class ClientPoolImpl
+ implements Closeable, Serializable, ClientPool {
private static final Logger LOG = LoggerFactory.getLogger(ClientPoolImpl.class);
private final int poolSize;
@@ -169,4 +179,60 @@ public boolean isClosed() {
return closed;
}
}
+
+ /** Cached client pool for {@link ClientPool}. */
+ abstract class CachedClientPool
+ implements Closeable, Serializable, ClientPool {
+
+ protected static final String CONF_KEY_PREFIX = "confKey:";
+ protected final long evictionInterval;
+ protected final String key;
+ protected final String metadata;
+ private final Options options;
+
+ public CachedClientPool(Options options) {
+ this.options = options;
+ this.evictionInterval =
+ options.get(CatalogOptions.CLIENT_POOL_CACHE_EVICTION_INTERVAL_MS);
+ this.metadata = options.get(CatalogOptions.METASTORE);
+ this.key = extractKey(options);
+ init();
+ }
+
+ protected Options options() {
+ return options;
+ }
+
+ protected abstract void init();
+
+ protected abstract ClientPool clientPool();
+
+ @Override
+ public R run(Action action) throws E, InterruptedException {
+ return clientPool().run(action);
+ }
+
+ @Override
+ public R run(Action action, boolean retry) throws E, InterruptedException {
+ return clientPool().run(action, retry);
+ }
+
+ private String extractKey(Options options) {
+ List