Return-Path: X-Original-To: apmail-argus-commits-archive@minotaur.apache.org Delivered-To: apmail-argus-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D845911160 for ; Fri, 29 Aug 2014 22:32:47 +0000 (UTC) Received: (qmail 42740 invoked by uid 500); 29 Aug 2014 22:32:47 -0000 Delivered-To: apmail-argus-commits-archive@argus.apache.org Received: (qmail 42722 invoked by uid 500); 29 Aug 2014 22:32:47 -0000 Mailing-List: contact commits-help@argus.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@argus.incubator.apache.org Delivered-To: mailing list commits@argus.incubator.apache.org Received: (qmail 42713 invoked by uid 99); 29 Aug 2014 22:32:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2014 22:32:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 29 Aug 2014 22:32:45 +0000 Received: (qmail 42511 invoked by uid 99); 29 Aug 2014 22:32:25 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2014 22:32:25 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 437229A9475; Fri, 29 Aug 2014 22:32:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: madhan@apache.org To: commits@argus.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: ARGUS-28:Added getHbaseStatus to fix HBase TestConnection issue and removed log statements Date: Fri, 29 Aug 2014 22:32:25 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-argus Updated Branches: refs/heads/master 41842dff5 -> 10de28040 ARGUS-28:Added getHbaseStatus to fix HBase TestConnection issue and removed log statements Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/10de2804 Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/10de2804 Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/10de2804 Branch: refs/heads/master Commit: 10de28040e0ca864868a549a636be3170828b080 Parents: 41842df Author: vperiasamy Authored: Fri Aug 29 14:57:15 2014 -0700 Committer: mneethiraj Committed: Fri Aug 29 15:31:05 2014 -0700 ---------------------------------------------------------------------- .../com/xasecure/hbase/client/HBaseClient.java | 58 +++++++++++++++++++- .../main/java/com/xasecure/biz/AssetMgr.java | 12 ++-- 2 files changed, 59 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/10de2804/lookup-client/src/main/java/com/xasecure/hbase/client/HBaseClient.java ---------------------------------------------------------------------- diff --git a/lookup-client/src/main/java/com/xasecure/hbase/client/HBaseClient.java b/lookup-client/src/main/java/com/xasecure/hbase/client/HBaseClient.java index 6a19cbf..0dec8f1 100644 --- a/lookup-client/src/main/java/com/xasecure/hbase/client/HBaseClient.java +++ b/lookup-client/src/main/java/com/xasecure/hbase/client/HBaseClient.java @@ -4,7 +4,9 @@ import java.io.IOException; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map.Entry; import javax.security.auth.Subject; @@ -39,7 +41,6 @@ public class HBaseClient extends BaseClient { //TODO: temporary solution - to be added to the UI for HBase private static HashMap addDefaultHBaseProp(HashMap connectionProp) { if (connectionProp != null) { - String param = "zookeeper.znode.parent" ; String unsecuredPath = "/hbase-unsecure" ; String authParam = "hadoop.security.authorization" ; @@ -58,27 +59,78 @@ public class HBaseClient extends BaseClient { return connectionProp; } - public void initHBase() { try { if (UserGroupInformation.isSecurityEnabled()) { + LOG.info("initHBase:security enabled"); if (getConfigHolder().getKeyTabFile() == null) { + LOG.info("initHBase: using username/password"); subj = SecureClientLogin.loginUserWithPassword(getConfigHolder().getUserName(), getConfigHolder().getPassword()) ; } else { + LOG.info("initHBase: using username/keytab"); subj = SecureClientLogin.loginUserFromKeytab(getConfigHolder().getUserName() , getConfigHolder().getKeyTabFile()) ; } } else { + LOG.info("initHBase: security not enabled, using username"); subj = SecureClientLogin.login(getConfigHolder().getUserName()) ; } } catch (IOException e) { - LOG.error("Unable to perform secure login to Hive environment [" + getConfigHolder().getDatasourceName() + "]", e); + LOG.error("Unable to perform secure login to Hbase environment [" + getConfigHolder().getDatasourceName() + "]", e); } } + public boolean getHBaseStatus() { + boolean hbaseStatus = false; + + if (subj != null) { + ClassLoader prevCl = Thread.currentThread().getContextClassLoader() ; + try { + Thread.currentThread().setContextClassLoader(getConfigHolder().getClassLoader()); + hbaseStatus = Subject.doAs(subj, new PrivilegedAction() { + @Override + public Boolean run() { + Boolean hbaseStatus1 = false; + try { + LOG.info("getHBaseStatus: creating default Hbase configuration"); + Configuration conf = HBaseConfiguration.create() ; + LOG.info("getHBaseStatus: setting config values from client"); + setClientConfigValues(conf); + LOG.info("getHBaseStatus: checking HbaseAvailability with the new config"); + HBaseAdmin.checkHBaseAvailable(conf); + LOG.info("getHBaseStatus: no exception: HbaseAvailability true"); + hbaseStatus1 = true; + } catch (Throwable e) { + LOG.error("getHBaseStatus: Unable to check availability of Hbase environment [" + getConfigHolder().getDatasourceName() + "]", e); + hbaseStatus1 = false; + } + return hbaseStatus1; + } + }) ; + } finally { + Thread.currentThread().setContextClassLoader(prevCl); + } + } else { + LOG.error("getHBaseStatus: secure login not done, subject is null"); + } + + return hbaseStatus; + } + private void setClientConfigValues(Configuration conf) { + if (this.connectionProperties == null) return; + Iterator> i = this.connectionProperties.entrySet().iterator(); + while (i.hasNext()) { + Entry e = i.next(); + String v = conf.get(e.getKey()); + if (v != null && !v.equalsIgnoreCase(e.getValue())) { + conf.set(e.getKey(), e.getValue()); + } + } + } + public List getTableList(final String tableNameMatching) { List ret = null ; http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/10de2804/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java b/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java index 439363e..a4ae899 100644 --- a/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java +++ b/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java @@ -21,6 +21,7 @@ import javax.naming.ldap.Rdn; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; +import org.apache.hive.com.esotericsoftware.minlog.Log; import org.apache.log4j.Logger; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; @@ -1521,14 +1522,9 @@ public class AssetMgr extends AssetMgrBase { HBaseClient connectionObj = new HBaseClient(vXAsset.getName(), configMap); if (connectionObj != null) { - connectivityStatus = true; - // TODO: A getConnectionStatus() method should be - // implemented in HBaseClient class to avoid tables lookup - // in HBase - List testResult = connectionObj.getTableList(".*"); - if (testResult != null && testResult.size() != 0) { - connectivityStatus = true; - } + connectivityStatus = connectionObj.getHBaseStatus(); + } else { + Log.error("testConfig: Not able to create HBaseClient"); } } else if (assetType == AppConstants.ASSET_KNOX) { KnoxClient knoxClient = assetConnectionMgr.getKnoxClient(