FAQ
Repository: hive
Updated Branches:
   refs/heads/master af36a8c35 -> 570dea850


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/570dea85
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/570dea85
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/570dea85

Branch: refs/heads/master
Commit: 570dea850958836637377164330f1ce9c43ceeba
Parents: af36a8c
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/570dea85/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/570dea85/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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedNov 3, '15 at 12:38a
activeNov 3, '15 at 12:38a
posts1
users1
websitehive.apache.org

1 user in discussion

Szehon: 1 post

People

Translate

site design / logo © 2021 Grokbase