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 07:04:07 UTC

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

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

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

commit 51dcec3507e761c6346a20af88b3f23c35843743
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 04a1f20..8062b12 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
@@ -34,6 +34,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;
@@ -151,8 +152,15 @@ public class HiveProducer {
             }
             hql.append(")");
             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();
         }
         Path partitionContentPath = new Path(partitionPath, CONTENT_FILE_NAME);