incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1196215 - in /incubator/hcatalog/trunk: CHANGES.txt src/java/org/apache/hcatalog/listener/NotificationListener.java
Date Tue, 01 Nov 2011 19:05:33 GMT
Author: hashutosh
Date: Tue Nov  1 19:05:33 2011
New Revision: 1196215

URL: http://svn.apache.org/viewvc?rev=1196215&view=rev
Log:
HCATALOG-148. Meaningful error message on failure to resolve topic name for partition event


Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    incubator/hcatalog/trunk/src/java/org/apache/hcatalog/listener/NotificationListener.java

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1196215&r1=1196214&r2=1196215&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Tue Nov  1 19:05:33 2011
@@ -69,6 +69,8 @@ Trunk (unreleased changes)
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-148. Meaningful error message on failure to resolve topic name for partition event
(thw via hashutosh)
+
   HCAT-136. Pig storer for export/import does maintain partition order (n_krishna_kumar via
khorgath)
 
   HCAT-134. Fix hbase build.xml to not affect root package target (khorgath via hashutosh)
 

Modified: incubator/hcatalog/trunk/src/java/org/apache/hcatalog/listener/NotificationListener.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/java/org/apache/hcatalog/listener/NotificationListener.java?rev=1196215&r1=1196214&r2=1196215&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/java/org/apache/hcatalog/listener/NotificationListener.java
(original)
+++ incubator/hcatalog/trunk/src/java/org/apache/hcatalog/listener/NotificationListener.java
Tue Nov  1 19:05:33 2011
@@ -52,14 +52,15 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.events.AddPartitionEvent;
+import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent;
 import org.apache.hadoop.hive.metastore.events.AlterTableEvent;
 import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent;
 import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
 import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent;
 import org.apache.hadoop.hive.metastore.events.DropPartitionEvent;
 import org.apache.hadoop.hive.metastore.events.DropTableEvent;
+import org.apache.hadoop.hive.metastore.events.ListenerEvent;
 import org.apache.hadoop.hive.metastore.events.LoadPartitionDoneEvent;
-import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent;
 import org.apache.hcatalog.common.HCatConstants;
 
 /**
@@ -87,6 +88,24 @@ public class NotificationListener extend
 		createConnection();
 	}
 
+	private static String getTopicName(Partition partition,
+			ListenerEvent partitionEvent) throws MetaException {
+		try {
+			String topicName = partitionEvent.getHandler()
+					.get_table(partition.getDbName(), partition.getTableName())
+					.getParameters().get(HCatConstants.HCAT_MSGBUS_TOPIC_NAME);
+			if (topicName == null) {
+				throw new MetaException(
+						"Topic name not found in metastore. Please do alter table set properties ("
+								+ HCatConstants.HCAT_MSGBUS_TOPIC_NAME
+								+ "=dbname.tablename) or whatever you want topic name to be.");
+			}
+			return topicName;
+		} catch (NoSuchObjectException e) {
+			throw new MetaException(e.toString());
+		}
+	}
+	
 	@Override
 	public void onAddPartition(AddPartitionEvent partitionEvent) throws MetaException {
 		// Subscriber can get notification of newly add partition in a 
@@ -95,13 +114,7 @@ public class NotificationListener extend
 		if(partitionEvent.getStatus()){
 
 			Partition partition = partitionEvent.getPartition();
-			String topicName;
-			try {
-				topicName = partitionEvent.getHandler().get_table(
-						partition.getDbName(), partition.getTableName()).getParameters().get(HCatConstants.HCAT_MSGBUS_TOPIC_NAME);
-			} catch (NoSuchObjectException e) {
-				throw new MetaException(e.toString());
-			}
+			String topicName = getTopicName(partition, partitionEvent);
 			send(partition, topicName, HCatConstants.HCAT_ADD_PARTITION_EVENT);			
 		}
 
@@ -123,13 +136,7 @@ public class NotificationListener extend
 			sd.setSortCols(new ArrayList<Order>());
 			sd.setParameters(new HashMap<String, String>());
 			sd.getSerdeInfo().setParameters(new HashMap<String, String>());
-			String topicName;
-			try {
-				topicName = partitionEvent.getHandler().get_table(
-						partition.getDbName(), partition.getTableName()).getParameters().get(HCatConstants.HCAT_MSGBUS_TOPIC_NAME);
-			} catch (NoSuchObjectException e) {
-				throw new MetaException(e.toString());
-			}
+			String topicName = getTopicName(partition, partitionEvent);
 			send(partition, topicName, HCatConstants.HCAT_DROP_PARTITION_EVENT);
 		}
 	}



Mime
View raw message