incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From avand...@apache.org
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 GMT
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 <db-name>.<table-name>. 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<String, String> tableProperties = new HashMap<String, String>(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);
+        }
+    }
 }



Mime
View raw message