hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject [17/55] [abbrv] hive git commit: HIVE-12235 : Improve beeline logging for dynamic service discovery (Szehon, reviewed by Vaibhav Gumashta)
Date Fri, 06 Nov 2015 17:32:59 GMT
HIVE-12235 : Improve beeline logging for dynamic service discovery (Szehon, reviewed by Vaibhav
Gumashta)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/492a10f1
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/492a10f1
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/492a10f1

Branch: refs/heads/master-fixed
Commit: 492a10f101471226004b6f571d7f8c8a79103664
Parents: 902a548
Author: Szehon Ho <szehon@cloudera.com>
Authored: Mon Nov 2 16:38:03 2015 -0800
Committer: Szehon Ho <szehon@cloudera.com>
Committed: Mon Nov 2 16:38:03 2015 -0800

----------------------------------------------------------------------
 beeline/src/main/resources/beeline-log4j2.xml   |  4 +++-
 .../org/apache/hive/jdbc/HiveConnection.java    | 21 ++++++++++++++------
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/492a10f1/beeline/src/main/resources/beeline-log4j2.xml
----------------------------------------------------------------------
diff --git a/beeline/src/main/resources/beeline-log4j2.xml b/beeline/src/main/resources/beeline-log4j2.xml
index a64f55e..55ec0f5 100644
--- a/beeline/src/main/resources/beeline-log4j2.xml
+++ b/beeline/src/main/resources/beeline-log4j2.xml
@@ -34,6 +34,8 @@
     <Root level="${sys:hive.log.level}">
       <AppenderRef ref="${sys:hive.root.logger}"/>
     </Root>
+    <!-- HiveConnection logs useful info for dynamic service discovery -->
+    <logger name="org.apache.hive.jdbc.HiveConnection" level="INFO"/>
   </Loggers>
 
-</Configuration>
+</Configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/492a10f1/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
index e38c585..f79d73d 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
@@ -204,16 +204,14 @@ public class HiveConnection implements java.sql.Connection {
                 .get(JdbcConnectionParams.AUTH_KERBEROS_AUTH_TYPE));
         transport = isHttpTransportMode() ? createHttpTransport() : createBinaryTransport();
         if (!transport.isOpen()) {
-          LOG.info("Will try to open client transport with JDBC Uri: " + jdbcUriString);
           transport.open();
+          logZkDiscoveryMessage("Connected to " + connParams.getHost() + ":" + connParams.getPort());
         }
         break;
       } catch (TTransportException e) {
-        LOG.info("Could not open client transport with JDBC Uri: " + jdbcUriString);
         // We'll retry till we exhaust all HiveServer2 nodes from ZooKeeper
-        if ((sessConfMap.get(JdbcConnectionParams.SERVICE_DISCOVERY_MODE) != null)
-            && (JdbcConnectionParams.SERVICE_DISCOVERY_MODE_ZOOKEEPER.equalsIgnoreCase(sessConfMap
-                .get(JdbcConnectionParams.SERVICE_DISCOVERY_MODE)))) {
+        if (isZkDynamicDiscoveryMode()) {
+          LOG.info("Failed to connect to " + connParams.getHost() + ":" + connParams.getPort());
           try {
             // Update jdbcUriString, host & port variables in connParams
             // Throw an exception if all HiveServer2 nodes have been exhausted,
@@ -228,7 +226,6 @@ public class HiveConnection implements java.sql.Connection {
           jdbcUriString = connParams.getJdbcUriString();
           host = connParams.getHost();
           port = connParams.getPort();
-          LOG.info("Will retry opening client transport");
         } else {
           LOG.info("Transport Used for JDBC connection: " +
             sessConfMap.get(JdbcConnectionParams.TRANSPORT_MODE));
@@ -650,6 +647,18 @@ public class HiveConnection implements java.sql.Connection {
     return false;
   }
 
+  private boolean isZkDynamicDiscoveryMode() {
+    return (sessConfMap.get(JdbcConnectionParams.SERVICE_DISCOVERY_MODE) != null)
+      && (JdbcConnectionParams.SERVICE_DISCOVERY_MODE_ZOOKEEPER.equalsIgnoreCase(sessConfMap
+      .get(JdbcConnectionParams.SERVICE_DISCOVERY_MODE)));
+  }
+
+  private void logZkDiscoveryMessage(String message) {
+    if (isZkDynamicDiscoveryMode()) {
+      LOG.info(message);
+    }
+  }
+
   /**
    * Lookup varName in sessConfMap, if its null or empty return the default
    * value varDefault


Mime
View raw message