From 826200edc6ab713fd8885254bbe51d4d3dc34ed9 Mon Sep 17 00:00:00 2001 From: zouxxyy Date: Tue, 17 Dec 2024 19:14:17 +0800 Subject: [PATCH 1/2] 1 --- .../main/java/org/apache/paimon/client/ClientPool.java | 4 ++-- .../src/main/java/org/apache/paimon/hive/HiveCatalog.java | 2 +- .../org/apache/paimon/hive/pool/CachedClientPool.java | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) 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 c42a30b35310..6d0feec64dba 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 @@ -26,7 +26,7 @@ import java.util.function.Supplier; /** Client pool for using multiple clients to execute actions. */ -public interface ClientPool { +public interface ClientPool extends Closeable { /** Action interface with return object for client. */ interface Action { R run(C client) throws E; @@ -42,7 +42,7 @@ interface ExecuteAction { void execute(ExecuteAction action) throws E, InterruptedException; /** Default implementation for {@link ClientPool}. */ - abstract class ClientPoolImpl implements Closeable, ClientPool { + abstract class ClientPoolImpl implements ClientPool { private volatile LinkedBlockingDeque clients; diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java index a590ede6d2e6..052325e48635 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java @@ -1017,7 +1017,7 @@ public void repairTable(Identifier identifier) throws TableNotExistException { @Override public void close() throws Exception { - // do nothing + clients.close(); } @Override diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java index f1d09e297b45..027a213206ef 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java @@ -204,6 +204,14 @@ static Key extractKey(String clientClassName, String cacheKeys, Configuration co return Key.of(elements); } + @Override + public void close() throws IOException { + if (clientPoolCache != null) { + clientPoolCache.asMap().forEach((key, client) -> client.close()); + clientPoolCache.cleanUp(); + } + } + static class Key { private final List elements; From 975427ae9e6958e04f1397aae29e9b3121eb9f3e Mon Sep 17 00:00:00 2001 From: zouxxyy Date: Tue, 17 Dec 2024 19:33:29 +0800 Subject: [PATCH 2/2] 1 --- .../main/java/org/apache/paimon/hive/pool/CachedClientPool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java index 027a213206ef..7e3b45a5e0ae 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/pool/CachedClientPool.java @@ -207,7 +207,7 @@ static Key extractKey(String clientClassName, String cacheKeys, Configuration co @Override public void close() throws IOException { if (clientPoolCache != null) { - clientPoolCache.asMap().forEach((key, client) -> client.close()); + clientPoolCache.asMap().values().forEach(HiveClientPool::close); clientPoolCache.cleanUp(); } }