deniskuzZ commented on code in PR #5955: URL: https://github.com/apache/hive/pull/5955#discussion_r2224508598
########## standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/client/builder/HiveMetaStoreClientBuilder.java: ########## @@ -18,65 +18,89 @@ package org.apache.hadoop.hive.metastore.client.builder; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.metastore.HiveMetaHookLoader; -import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.RetryingMetaStoreClient; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.client.HookEnabledMetaStoreClient; import org.apache.hadoop.hive.metastore.client.SynchronizedMetaStoreClient; import org.apache.hadoop.hive.metastore.client.ThriftHiveMetaStoreClient; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.utils.JavaUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; import java.util.Objects; import java.util.function.Function; public class HiveMetaStoreClientBuilder { + private static final Logger LOG = LoggerFactory.getLogger(HiveMetaStoreClientBuilder.class); - private final Configuration conf; - private IMetaStoreClient client; + private final Configuration conf; + private IMetaStoreClient client; - public HiveMetaStoreClientBuilder(Configuration conf) { - this.conf = Objects.requireNonNull(conf); - } + public HiveMetaStoreClientBuilder(Configuration conf) { + this.conf = Objects.requireNonNull(conf); + } - public HiveMetaStoreClientBuilder newClient() throws MetaException { - this.client = new HiveMetaStoreClient(conf); - return this; - } + public HiveMetaStoreClientBuilder newClient(boolean allowEmbedded) throws MetaException { + this.client = createClient(conf, allowEmbedded); + return this; + } - public HiveMetaStoreClientBuilder newThriftClient(boolean allowEmbedded) throws MetaException { - this.client = ThriftHiveMetaStoreClient.newClient(conf, allowEmbedded); - return this; - } + public HiveMetaStoreClientBuilder client(IMetaStoreClient client) { + this.client = client; + return this; + } - public HiveMetaStoreClientBuilder client(IMetaStoreClient client) { - this.client = client; - return this; - } + public HiveMetaStoreClientBuilder enhanceWith(Function<IMetaStoreClient, IMetaStoreClient> wrapperFunction) { + client = wrapperFunction.apply(client); + return this; + } - public HiveMetaStoreClientBuilder enhanceWith(Function<IMetaStoreClient, IMetaStoreClient> wrapperFunction) { - client = wrapperFunction.apply(client); - return this; - } + public HiveMetaStoreClientBuilder withHooks(HiveMetaHookLoader hookLoader) { + this.client = HookEnabledMetaStoreClient.newClient(conf, hookLoader, client); + return this; + } - public HiveMetaStoreClientBuilder withHooks(HiveMetaHookLoader hookLoader) { - this.client = HookEnabledMetaStoreClient.newClient(conf, hookLoader, client); - return this; - } + public HiveMetaStoreClientBuilder withRetry(Map<String, Long> metaCallTimeMap) throws MetaException { + client = RetryingMetaStoreClient.getProxy(conf, metaCallTimeMap, client); + return this; + } - public HiveMetaStoreClientBuilder withRetry(Map<String, Long> metaCallTimeMap) throws MetaException { - client = RetryingMetaStoreClient.getProxy(conf, metaCallTimeMap, client); - return this; - } + public HiveMetaStoreClientBuilder threadSafe() { + this.client = SynchronizedMetaStoreClient.newClient(conf, client); + return this; + } - public HiveMetaStoreClientBuilder threadSafe() { - this.client = SynchronizedMetaStoreClient.newClient(conf, client); - return this; - } + public IMetaStoreClient build() { + return Objects.requireNonNull(client); + } - public IMetaStoreClient build() { - return Objects.requireNonNull(client); + public static IMetaStoreClient createClient(Configuration conf, boolean allowEmbedded) throws MetaException { Review Comment: should be private -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org