remove close to Proxy

Project: http://git-wip-us.apache.org/repos/asf/incubator-griffin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-griffin/commit/2a081942
Tree: http://git-wip-us.apache.org/repos/asf/incubator-griffin/tree/2a081942
Diff: http://git-wip-us.apache.org/repos/asf/incubator-griffin/diff/2a081942

Branch: refs/heads/master
Commit: 2a0819426b53c098e7cda28075393077656bac00
Parents: 7b4d48c
Author: Guo <[email protected]>
Authored: Thu Mar 2 10:34:33 2017 +0800
Committer: Guo <[email protected]>
Committed: Thu Mar 2 10:34:33 2017 +0800

----------------------------------------------------------------------
 .../core/metastore/HiveMetastoreProxy.java      | 27 +++++++++++++++++---
 .../core/metastore/HiveMetastoreService.java    |  9 +------
 2 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/2a081942/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreProxy.java
----------------------------------------------------------------------
diff --git 
a/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreProxy.java
 
b/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreProxy.java
index 0b0e896..96a5743 100644
--- 
a/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreProxy.java
+++ 
b/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreProxy.java
@@ -1,24 +1,45 @@
 package org.apache.griffin.core.metastore;
 
+import org.apache.griffin.core.GriffinWebApplication;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
 import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.stereotype.Component;
 
 @Component
-public class HiveMetastoreProxy {
+public class HiveMetastoreProxy
+{
+    private static final Logger log = 
LoggerFactory.getLogger(HiveMetastoreProxy.class);
+
     @Value("${hive.metastore.uris}")
     private String uris;
 
+
+    private HiveMetaStoreClient client = null;
+
     @Bean
-    public HiveMetaStoreClient getHiveMetastoreClient() throws MetaException {
+    public HiveMetaStoreClient initHiveMetastoreClient(){
         HiveConf hiveConf = new HiveConf();
         hiveConf.set("hive.metastore.local", "false");
         hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 
3);
         hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, uris);
-        return new HiveMetaStoreClient(hiveConf);
+        try {
+            client= new HiveMetaStoreClient(hiveConf);
+        } catch (MetaException e) {
+            log.error("Failed to connect hive metastore",e.getMessage());
+            client = null;
+        }
+
+        return client;
+    }
+
+    public void destroy() throws Exception {
+        if(null!=client) client.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/2a081942/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreService.java
----------------------------------------------------------------------
diff --git 
a/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreService.java
 
b/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreService.java
index 9a60244..c0409a9 100644
--- 
a/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreService.java
+++ 
b/service/src/main/java/org/apache/griffin/core/metastore/HiveMetastoreService.java
@@ -32,9 +32,7 @@ public class HiveMetastoreService {
         try {
             results = client.getAllDatabases();
         } catch (MetaException e) {
-            log.error("Can not get databases",e.getMessage());
-        }finally {
-//            client.close();
+            log.error("Can not get databases : ",e.getMessage());
         }
         return results;
     }
@@ -47,8 +45,6 @@ public class HiveMetastoreService {
             results = client.getAllTables(useDbName);
         } catch (Exception e) {
             log.warn("Exception fetching tables info" + e.getMessage());
-        }finally {
-//            client.close();
         }
         return results;
     }
@@ -61,9 +57,6 @@ public class HiveMetastoreService {
             result = client.getTable(useDbName, tableName);
         } catch (Exception e) {
             log.warn("Exception fetching table info : " +tableName + " : " + 
e.getMessage());
-        }finally {
-//            client.close();
-
         }
         return result;
     }

Reply via email to