Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangchong committed Mar 27, 2024
1 parent 420cec7 commit b32f161
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ public HiveCatalog(
@Override
public Optional<CatalogLock.LockContext> lockContext() {
return Optional.of(
new HiveCatalogLock.HiveLockContext(clients, new SerializableHiveConf(hiveConf)));
new HiveCatalogLock.HiveLockContext(
new SerializableHiveConf(hiveConf), clientClassName, options));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -140,6 +144,11 @@ public String identifier() {
}
}

public static ClientPool<IMetaStoreClient, TException> creatClients(
HiveConf conf, Options options, String clientClassName) {
return new CachedClientPool(conf, options, clientClassName);
}

public static long checkMaxSleep(HiveConf conf) {
return TimeUtils.parseDuration(
conf.get(
Expand All @@ -157,13 +166,15 @@ public static long acquireTimeout(HiveConf conf) {
}

static class HiveLockContext implements LockContext {
private final ClientPool<IMetaStoreClient, TException> clients;
private final SerializableHiveConf hiveConf;
private final String clientClassName;
private final Options options;

public HiveLockContext(
ClientPool<IMetaStoreClient, TException> clients, SerializableHiveConf hiveConf) {
this.clients = clients;
SerializableHiveConf hiveConf, String clientClassName, Options options) {
this.hiveConf = hiveConf;
this.clientClassName = clientClassName;
this.options = options;
}
}
}

0 comments on commit b32f161

Please sign in to comment.