deniskuzZ commented on code in PR #5771: URL: https://github.com/apache/hive/pull/5771#discussion_r2187642254
########## standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/client/SynchronizedMetaStoreClient.java: ########## @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hive.metastore.client; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.IMetaStoreClient; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +/** + * A synchronized wrapper for {@link IMetaStoreClient}. + * The reflection logic originally comes from {@link org.apache.hadoop.hive.metastore.HiveMetaStoreClient}. + * This should be used by multi-thread applications unless all the underlying layers are thread-safe. + */ +public class SynchronizedMetaStoreClient extends MetaStoreClientProxy implements IMetaStoreClient { + public static SynchronizedMetaStoreClient newClient(Configuration conf, IMetaStoreClient delegate) { + return new SynchronizedMetaStoreClient(conf, delegate); + } + + public SynchronizedMetaStoreClient(Configuration conf, IMetaStoreClient delegate) { + super(newSynchronizedClient(delegate), conf); + } + + /** + * Creates a synchronized wrapper for any {@link IMetaStoreClient}. + * This may be used by multi-threaded applications until we have + * fixed all reentrancy bugs. + * + * @param client unsynchronized client + * @return synchronized client + */ + public static IMetaStoreClient newSynchronizedClient(IMetaStoreClient client) { + return (IMetaStoreClient) Proxy.newProxyInstance( + ThriftHiveMetaStoreClient.class.getClassLoader(), Review Comment: why ThriftHiveMetaStoreClient? -- 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