You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "chenjunjiedada (via GitHub)" <gi...@apache.org> on 2023/04/10 12:10:00 UTC

[GitHub] [iceberg] chenjunjiedada commented on a diff in pull request #7310: Hive: Clean up expired metastore clients

chenjunjiedada commented on code in PR #7310:
URL: https://github.com/apache/iceberg/pull/7310#discussion_r1161430375


##########
core/src/main/java/org/apache/iceberg/ClientPoolImpl.java:
##########
@@ -147,4 +147,8 @@ private void release(C client) {
   public int poolSize() {
     return poolSize;
   }
+
+  public boolean isClosed() {

Review Comment:
   Do we need this to be public? 



##########
hive-metastore/src/main/java/org/apache/iceberg/hive/CachedClientPool.java:
##########
@@ -97,10 +99,13 @@ HiveClientPool clientPool() {
 
   private synchronized void init() {
     if (clientPoolCache == null) {
+      // Since Caffeine does not ensure that removalListener will be involved after expiration
+      // We use a scheduler with 2 threads to clean up expired clients.
       clientPoolCache =
           Caffeine.newBuilder()
               .expireAfterAccess(evictionInterval, TimeUnit.MILLISECONDS)
               .removalListener((ignored, value, cause) -> ((HiveClientPool) value).close())
+              .scheduler(Scheduler.forScheduledExecutorService(Executors.newScheduledThreadPool(2)))

Review Comment:
   Nit: Iceberg has a thread pool util `ThreadPools.newScheduledPool` that you can use. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org