deniskuzZ commented on code in PR #6595:
URL: https://github.com/apache/hive/pull/6595#discussion_r4587971680


##########
standalone-metastore/metastore-search/src/main/java/org/apache/hive/search/metastore/MetastoreIndexer.java:
##########
@@ -0,0 +1,370 @@
+/*
+ * 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.hive.search.metastore;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.DatabaseName;
+import org.apache.hadoop.hive.metastore.IMetaStoreClient;
+import org.apache.hadoop.hive.metastore.RetryingMetaStoreClient;
+import org.apache.hadoop.hive.metastore.api.NotificationEventRequest;
+import org.apache.hadoop.hive.metastore.leader.LeaderElection;
+import org.apache.hive.search.mapping.TableDocument;
+import org.apache.hive.search.exception.IndexNotHealthyException;
+import org.apache.hive.search.config.IndexOptions;
+import org.apache.hive.search.index.Indexer;
+import org.apache.hive.search.index.IndexManager;
+import org.apache.hive.search.index.store.IndexManifest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class MetastoreIndexer implements Closeable {
+  private static final Logger LOG = 
LoggerFactory.getLogger(MetastoreIndexer.class);
+
+  private final MetastoreClientProvider clientProvider;
+  private final long lastEventId;
+  private final Indexer indexer;
+  private final MetastoreCluster cluster;
+  private final MetastoreEventHandler handler;
+  private final IndexManager indexManager;
+  private final FlushIndexListener flushIndexListener;
+  private final IMetaStoreClient client;
+
+  public static MetastoreIndexer getMetastoreIndexer(Configuration 
configuration,
+      IndexManager indexManager, Indexer indexer, MetastoreClientProvider 
clientProvider)
+      throws Exception {
+    if (clientProvider == null) {
+      IMetaStoreClient client = 
RetryingMetaStoreClient.getProxy(configuration, true);
+      Thread currentThread = Thread.currentThread();
+      clientProvider = conf -> {

Review Comment:
   With this provider, the event poller isn’t the constructing thread, so every 
getNextMetastoreEvents call (once a second by default when idle) opens and 
closes a new RetryingMetaStoreClient. That’s a Thrift connection, plus a SASL 
handshake on Kerberos, every second. 
   
   Could the poller hold one client for its lifetime, and each bootstrap fetch 
worker one client rather than one per batch? That would also remove the need to 
decide by which thread is calling.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to