From hcatalog-commits-return-1120-apmail-incubator-hcatalog-commits-archive=incubator.apache.org@incubator.apache.org Thu Dec 13 01:20:21 2012 Return-Path: X-Original-To: apmail-incubator-hcatalog-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-hcatalog-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 7C6FFD144 for ; Thu, 13 Dec 2012 01:20:21 +0000 (UTC) Received: (qmail 97468 invoked by uid 500); 13 Dec 2012 01:20:21 -0000 Delivered-To: apmail-incubator-hcatalog-commits-archive@incubator.apache.org Received: (qmail 97404 invoked by uid 500); 13 Dec 2012 01:20:20 -0000 Mailing-List: contact hcatalog-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hcatalog-dev@incubator.apache.org Delivered-To: mailing list hcatalog-commits@incubator.apache.org Received: (qmail 97393 invoked by uid 99); 13 Dec 2012 01:20:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Dec 2012 01:20:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Dec 2012 01:20:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 411282388C74; Thu, 13 Dec 2012 01:19:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1421056 - in /incubator/hcatalog/trunk: ./ webhcat/java-client/src/main/java/org/apache/hcatalog/api/ webhcat/java-client/src/test/java/org/apache/hcatalog/api/ Date: Thu, 13 Dec 2012 01:19:55 -0000 To: hcatalog-commits@incubator.apache.org From: avandana@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121213011956.411282388C74@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: avandana Date: Thu Dec 13 01:19:53 2012 New Revision: 1421056 URL: http://svn.apache.org/viewvc?rev=1421056&view=rev Log: HCAT-562 HCatClient should allow for a table's message-topic-name to be queried for. Modified: incubator/hcatalog/trunk/CHANGES.txt incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClient.java incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java incubator/hcatalog/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java Modified: incubator/hcatalog/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1421056&r1=1421055&r2=1421056&view=diff ============================================================================== --- incubator/hcatalog/trunk/CHANGES.txt (original) +++ incubator/hcatalog/trunk/CHANGES.txt Thu Dec 13 01:19:53 2012 @@ -151,6 +151,8 @@ Trunk (unreleased changes) OPTIMIZATIONS BUG FIXES + HCAT-562 HCatClient should allow for a table's message-topic-name to be queried for. (mithunr via avandana) + HCAT-561 HCatClient should differentiate between "partition not available" and other generic errors.(mithunr via avandana) HCAT-563 hcat script should look in the correct dir for the storage handler jars (arpitgupta via khorgath) Modified: incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClient.java URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClient.java?rev=1421056&r1=1421055&r2=1421056&view=diff ============================================================================== --- incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClient.java (original) +++ incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClient.java Thu Dec 13 01:19:53 2012 @@ -319,6 +319,16 @@ public abstract class HCatClient { throws HCatException; /** + * Retrieve Message-bus topic for a table. + * + * @param dbName The name of the DB. + * @param tableName The name of the table. + * @return Topic-name for the message-bus on which messages will be sent for the specified table. + * By default, this is set to .. Returns null when not set. + */ + public abstract String getMessageBusTopicName(String dbName, String tableName) throws HCatException; + + /** * Close the hcatalog client. * * @throws HCatException Modified: incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java?rev=1421056&r1=1421055&r2=1421056&view=diff ============================================================================== --- incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java (original) +++ incubator/hcatalog/trunk/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java Thu Dec 13 01:19:53 2012 @@ -42,6 +42,7 @@ import org.apache.hadoop.hive.metastore. import org.apache.hadoop.hive.metastore.api.UnknownDBException; import org.apache.hadoop.hive.metastore.api.UnknownPartitionException; import org.apache.hadoop.hive.metastore.api.UnknownTableException; +import org.apache.hcatalog.common.HCatConstants; import org.apache.hcatalog.common.HCatException; import org.apache.hcatalog.common.HCatUtil; import org.apache.hcatalog.data.schema.HCatFieldSchema; @@ -674,4 +675,19 @@ public class HCatClientHMSImpl extends H return numPartitions; } + @Override + public String getMessageBusTopicName(String dbName, String tableName) throws HCatException { + try { + return hmsClient.getTable(dbName, tableName).getParameters().get(HCatConstants.HCAT_MSGBUS_TOPIC_NAME); + } + catch (MetaException e) { + throw new HCatException("MetaException while retrieving JMS Topic name.", e); + } catch (TException e) { + throw new ConnectionFailureException( + "TException while retrieving JMS Topic name.", e); + } catch (NoSuchObjectException e) { + throw new HCatException("Could not find DB:" + dbName + " or Table:" + tableName, e); + } + } + } Modified: incubator/hcatalog/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java?rev=1421056&r1=1421055&r2=1421056&view=diff ============================================================================== --- incubator/hcatalog/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java (original) +++ incubator/hcatalog/trunk/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java Thu Dec 13 01:19:53 2012 @@ -36,6 +36,7 @@ import org.apache.hadoop.hive.serde2.col import org.apache.hadoop.mapred.TextInputFormat; import org.apache.hcatalog.cli.SemanticAnalysis.HCatSemanticAnalyzer; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; +import org.apache.hcatalog.common.HCatConstants; import org.apache.hcatalog.common.HCatException; import org.apache.hcatalog.data.schema.HCatFieldSchema; import org.apache.hcatalog.data.schema.HCatFieldSchema.Type; @@ -477,4 +478,27 @@ public class TestHCatClient { assertTrue("Unexpected exception! " + t.getMessage(), false); } } + + @Test + public void testGetMessageBusTopicName() throws Exception { + try { + HCatClient client = HCatClient.create(new Configuration(hcatConf)); + String dbName = "testGetMessageBusTopicName_DBName"; + String tableName = "testGetMessageBusTopicName_TableName"; + client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE); + client.createDatabase(HCatCreateDBDesc.create(dbName).build()); + String messageBusTopicName = "MY.topic.name"; + Map tableProperties = new HashMap(1); + tableProperties.put(HCatConstants.HCAT_MSGBUS_TOPIC_NAME, messageBusTopicName); + client.createTable(HCatCreateTableDesc.create(dbName, tableName, Arrays.asList(new HCatFieldSchema("foo", Type.STRING, ""))).tblProps(tableProperties).build()); + + assertEquals("MessageBus topic-name doesn't match!", messageBusTopicName, client.getMessageBusTopicName(dbName, tableName)); + client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE); + client.close(); + } + catch (Exception exception) { + LOG.error("Unexpected exception.", exception); + assertTrue("Unexpected exception:" + exception.getMessage(), false); + } + } }