You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2020/05/10 06:19:15 UTC

[hive] branch master updated: HIVE-22419 : Improve Messages Emitted From HiveMetaStoreClient (David Mollitor via Ashutosh Chauhan)

This is an automated email from the ASF dual-hosted git repository.

hashutosh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 19e67cd  HIVE-22419 : Improve Messages Emitted From HiveMetaStoreClient (David Mollitor via Ashutosh Chauhan)
19e67cd is described below

commit 19e67cd54e2f980be901bed4e6d21ce002ebc9e1
Author: David Mollitor <dm...@apache.org>
AuthorDate: Sat May 9 23:17:50 2020 -0700

    HIVE-22419 : Improve Messages Emitted From HiveMetaStoreClient (David Mollitor via Ashutosh Chauhan)
    
    Signed-off-by: Ashutosh Chauhan <ha...@apache.org>
---
 .../hadoop/hive/metastore/HiveMetaStoreClient.java | 54 ++++++++++++----------
 .../hadoop/hive/metastore/utils/LogUtils.java      |  9 ----
 2 files changed, 29 insertions(+), 34 deletions(-)

diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index 1ec5839..64d3833 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -70,7 +70,6 @@ import org.apache.hadoop.hive.metastore.utils.FilterUtils;
 import org.apache.hadoop.hive.metastore.utils.JavaUtils;
 import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
 import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
-import org.apache.hadoop.hive.metastore.utils.LogUtils;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.StringUtils;
@@ -440,8 +439,8 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
       String newVar = MetastoreConf.getAsString(conf, oneVar);
       if (oldVar == null ||
           (oneVar.isCaseSensitive() ? !oldVar.equals(newVar) : !oldVar.equalsIgnoreCase(newVar))) {
-        LOG.info("Mestastore configuration " + oneVar.toString() +
-            " changed from " + oldVar + " to " + newVar);
+        LOG.info("Mestastore configuration {} changed from {} to {}",
+            oneVar, oldVar, newVar);
         compatible = false;
       }
     }
@@ -457,8 +456,8 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
   public void reconnect() throws MetaException {
     if (localMetaStore) {
       // For direct DB connections we don't yet support reestablishing connections.
-      throw new MetaException("For direct MetaStore DB connections, we don't support retries" +
-          " at the client level.");
+      throw new MetaException("Retries for direct MetaStore DB connections "
+          + "are not supported by this client");
     } else {
       close();
 
@@ -593,10 +592,13 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
               // Create an SSL socket and connect
               transport = SecurityUtils.getSSLSocket(store.getHost(), store.getPort(), clientSocketTimeout,
                   trustStorePath, trustStorePassword);
-              LOG.debug("Opened an SSL connection to metastore, current connections: " + connCount.incrementAndGet());
+              final int newCount = connCount.incrementAndGet();
+              LOG.debug(
+                  "Opened an SSL connection to metastore, current connections: {}",
+                  newCount);
               if (LOG.isTraceEnabled()) {
-                LOG.trace("", new LogUtils.StackTraceLogger("METASTORE SSL CONNECTION TRACE - open - " +
-                        System.identityHashCode(this)));
+                LOG.trace("METASTORE SSL CONNECTION TRACE - open [{}]",
+                    System.identityHashCode(this), new Exception());
               }
             } catch (IOException e) {
               throw new IllegalArgumentException(e);
@@ -632,7 +634,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
               transport = MetaStorePlainSaslHelper.getPlainTransport(userName, passwd, transport);
             } catch (IOException sasle) {
               // IOException covers SaslException
-              LOG.error("Couldn't create client transport", sasle);
+              LOG.error("Could not create client transport", sasle);
               throw new MetaException(sasle.toString());
             }
           } else if (useSasl) {
@@ -665,7 +667,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
                     transport, MetaStoreUtils.getMetaStoreSaslProperties(conf, useSSL));
               }
             } catch (IOException ioe) {
-              LOG.error("Couldn't create client transport", ioe);
+              LOG.error("Failed to create client transport", ioe);
               throw new MetaException(ioe.toString());
             }
           } else {
@@ -684,21 +686,23 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
           try {
             if (!transport.isOpen()) {
               transport.open();
-              LOG.info("Opened a connection to metastore, URI (" + store + ") current connections: " + connCount.incrementAndGet());
+              final int newCount = connCount.incrementAndGet();
+              LOG.info("Opened a connection to metastore, URI ({}) "
+                  + "current connections: {}", store, newCount);
               if (LOG.isTraceEnabled()) {
-                LOG.trace("", new LogUtils.StackTraceLogger("METASTORE CONNECTION TRACE - open - " +
-                        System.identityHashCode(this)));
+                LOG.trace("METASTORE CONNECTION TRACE - open [{}]",
+                    System.identityHashCode(this), new Exception());
               }
             }
             isConnected = true;
           } catch (TTransportException e) {
             tte = e;
-            if (LOG.isDebugEnabled()) {
-              LOG.warn("Failed to connect to the MetaStore Server URI (" + store + ")", e);
-            } else {
-              // Don't print full exception trace if DEBUG is not on.
-              LOG.warn("Failed to connect to the MetaStore Server URI (" + store + ")");
-            }
+            LOG.warn("Failed to connect to the MetaStore Server URI ({})",
+                store);
+
+            // Include stack trace in DEBUG logging
+            LOG.debug("Failed to connect to the MetaStore Server URI ({})",
+                store, e);
           }
 
           if (isConnected && !useSasl && !usePasswordAuth &&
@@ -751,8 +755,6 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
     }
 
     snapshotActiveConf();
-
-    LOG.info("Connected to metastore.");
   }
 
   private void snapshotActiveConf() {
@@ -782,10 +784,12 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
     // just in case, we make this call.
     if ((transport != null) && transport.isOpen()) {
       transport.close();
-      LOG.info("Closed a connection to metastore, current connections: " + connCount.decrementAndGet());
+      final int newCount = connCount.decrementAndGet();
+      LOG.info("Closed a connection to metastore, current connections: {}",
+          newCount);
       if (LOG.isTraceEnabled()) {
-        LOG.trace("", new LogUtils.StackTraceLogger("METASTORE CONNECTION TRACE - close - " +
-                System.identityHashCode(this)));
+        LOG.trace("METASTORE CONNECTION TRACE - close [{}]",
+            System.identityHashCode(this), new Exception());
       }
     }
   }
@@ -1931,7 +1935,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
         throw te;
       }
       throw new IncompatibleMetastoreException(
-          "Metastore doesn't support listPartitionsByExpr: " + te.getMessage());
+          "Metastore does not support listPartitionsByExpr: " + te.getMessage());
     }
 
     r.setPartitions(FilterUtils.filterPartitionsIfEnabled(isClientFilterEnabled, filterHook, r.getPartitions()));
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/LogUtils.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/LogUtils.java
index c93da38..26daeae 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/LogUtils.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/LogUtils.java
@@ -47,15 +47,6 @@ public class LogUtils {
   }
 
   /**
-   * This is an exception that can be passed to logger just for printing the stacktrace.
-   */
-  public static class StackTraceLogger extends Exception {
-    public StackTraceLogger(final String msg) {
-      super(msg);
-    }
-  }
-
-  /**
    * Initialize log4j.
    *
    * @return an message suitable for display to the user