You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ni...@apache.org on 2020/02/07 14:26:02 UTC

[kylin] 07/44: KYLIN-4225 close hive session manually

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

nic pushed a commit to branch 3.0.x
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit 6635c0464a9ef9882ae20f69d911af19e823afe1
Author: Zhou Kang <zh...@xiaomi.com>
AuthorDate: Wed Oct 30 10:14:57 2019 +0800

    KYLIN-4225 close hive session manually
---
 .../org/apache/kylin/metrics/lib/impl/hive/HiveProducer.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/metrics-reporter-hive/src/main/java/org/apache/kylin/metrics/lib/impl/hive/HiveProducer.java b/metrics-reporter-hive/src/main/java/org/apache/kylin/metrics/lib/impl/hive/HiveProducer.java
index 8b67e8a..5082b6a 100644
--- a/metrics-reporter-hive/src/main/java/org/apache/kylin/metrics/lib/impl/hive/HiveProducer.java
+++ b/metrics-reporter-hive/src/main/java/org/apache/kylin/metrics/lib/impl/hive/HiveProducer.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.ql.Driver;
+import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse;
 import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.kylin.common.util.Pair;
 import org.apache.kylin.metrics.lib.ActiveReservoirReporter;
@@ -174,8 +175,15 @@ public class HiveProducer {
             hql.append(")");
             logger.debug("create partition by {}.", hql);
             Driver driver = new Driver(hiveConf);
-            SessionState.start(new CliSessionState(hiveConf));
-            driver.run(hql.toString());
+            CliSessionState session = new CliSessionState(hiveConf);
+            SessionState.start(session);
+            CommandProcessorResponse res = driver.run(hql.toString());
+            if (res.getResponseCode() != 0) {
+                logger.warn("Fail to add partition. HQL: {}; Cause by: {}",
+                        hql.toString(),
+                        res.toString());
+            }
+            session.close();
             driver.close();
         }