zratkai commented on code in PR #5145:
URL: https://github.com/apache/hive/pull/5145#discussion_r1881663151


##########
standalone-metastore/metastore-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogActor.java:
##########
@@ -0,0 +1,274 @@
+/*
+ * 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.iceberg.rest;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.pool2.BasePooledObjectFactory;
+import org.apache.commons.pool2.ObjectPool;
+import org.apache.commons.pool2.PooledObject;
+import org.apache.commons.pool2.impl.DefaultPooledObject;
+import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.HMSHandler;
+import org.apache.hadoop.hive.metastore.HMSHandlerProxyFactory;
+import org.apache.hadoop.hive.metastore.IHMSHandler;
+import org.apache.hadoop.hive.metastore.api.CheckLockRequest;
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
+import org.apache.hadoop.hive.metastore.api.GetTableRequest;
+import org.apache.hadoop.hive.metastore.api.GetTablesRequest;
+import org.apache.hadoop.hive.metastore.api.GetTablesResult;
+import org.apache.hadoop.hive.metastore.api.HeartbeatRequest;
+import org.apache.hadoop.hive.metastore.api.LockRequest;
+import org.apache.hadoop.hive.metastore.api.LockResponse;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.ShowLocksRequest;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponse;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.api.UnlockRequest;
+import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
+import org.apache.iceberg.BaseMetastoreTableOperations;
+import org.apache.iceberg.TableMetadata;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.hive.HiveActor;
+import org.apache.iceberg.hive.HiveLock;
+import org.apache.iceberg.hive.MetastoreLock;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HMSCatalogActor implements HiveActor {
+  private static final Logger LOG = 
LoggerFactory.getLogger(HMSCatalogActor.class);
+  /** The actor name (catalog). */
+  private final String name;
+  /** The configuration (the Hadoop).  */
+  private final Configuration conf;
+  /** The client pool. */
+  private final ObjectPool<IHMSHandler> handlers;
+
+  private static IHMSHandler getHandler(Configuration configuration) throws 
MetaException {
+    IHMSHandler hmsHandler = new HMSHandler("HMSHandler", configuration);
+    try {
+      return HMSHandlerProxyFactory.getProxy(configuration, hmsHandler, true);
+    } catch (MetaException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  public HMSCatalogActor(String name, Configuration configuration) {
+    this.name = name;
+    this.conf = configuration;
+    this.handlers = new GenericObjectPool<>(new 
BasePooledObjectFactory<IHMSHandler>() {
+      @Override
+      public IHMSHandler create() throws Exception {
+        return getHandler(new Configuration(conf));
+      }
+
+      @Override
+      public PooledObject<IHMSHandler> wrap(IHMSHandler ihmsHandler) {
+        return new DefaultPooledObject<>(ihmsHandler);
+      }
+    });
+  }
+
+  @FunctionalInterface
+  interface Action<R> {
+    R execute(IHMSHandler handler) throws TException;
+  }
+
+  private <R> R run(Action<R> action) throws TException {
+    IHMSHandler handler = null;
+    try {
+      try {

Review Comment:
   This double try seems strange. Could you please use just one level of 
try-catch-finally here? It seems unnecessary to complicate.



-- 
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

Reply via email to