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 cbc084f67136..5a2356944fd6 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 @@ -155,7 +155,8 @@ public HiveCatalog( @Override public Optional lockContext() { return Optional.of( - new HiveCatalogLock.HiveLockContext(clients, new SerializableHiveConf(hiveConf))); + new HiveCatalogLock.HiveLockContext( + new SerializableHiveConf(hiveConf), clientClassName, options)); } @Override diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalogLock.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalogLock.java index 12cbaa567584..48c3f2fe7162 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalogLock.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalogLock.java @@ -20,6 +20,8 @@ import org.apache.paimon.catalog.CatalogLock; import org.apache.paimon.client.ClientPool; +import org.apache.paimon.hive.pool.CachedClientPool; +import org.apache.paimon.options.Options; import org.apache.paimon.utils.TimeUtils; import org.apache.hadoop.hive.conf.HiveConf; @@ -131,7 +133,9 @@ public CatalogLock create(LockContext context) { HiveLockContext hiveLockContext = (HiveLockContext) context; HiveConf conf = hiveLockContext.hiveConf.conf(); return new HiveCatalogLock( - hiveLockContext.clients, checkMaxSleep(conf), acquireTimeout(conf)); + creatClients(conf, hiveLockContext.options, hiveLockContext.clientClassName), + checkMaxSleep(conf), + acquireTimeout(conf)); } @Override @@ -140,6 +144,11 @@ public String identifier() { } } + public static ClientPool creatClients( + HiveConf conf, Options options, String clientClassName) { + return new CachedClientPool(conf, options, clientClassName); + } + public static long checkMaxSleep(HiveConf conf) { return TimeUtils.parseDuration( conf.get( @@ -157,13 +166,15 @@ public static long acquireTimeout(HiveConf conf) { } static class HiveLockContext implements LockContext { - private final ClientPool clients; private final SerializableHiveConf hiveConf; + private final String clientClassName; + private final Options options; public HiveLockContext( - ClientPool clients, SerializableHiveConf hiveConf) { - this.clients = clients; + SerializableHiveConf hiveConf, String clientClassName, Options options) { this.hiveConf = hiveConf; + this.clientClassName = clientClassName; + this.options = options; } } }