Author: gates
Date: Tue Feb  7 04:30:16 2012
New Revision: 1241346

URL: http://svn.apache.org/viewvc?rev=1241346&view=rev
Log:
HCATALOG-238. Absence of msgbus.topic.name should not be deemed as 
notification-failure.

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=1241346&r1=1241345&r2=1241346&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Tue Feb  7 04:30:16 2012
@@ -76,6 +76,8 @@ Release 0.3.0 - Unreleased
   HCAT-63. RPM package integration with Hadoop (khorgath via hashutosh)
 
   IMPROVEMENTS
+  HCAT-238. Absence of msgbus.topic.name should not be deemed as 
notification-failure. (mithun via gates)
+
   HCAT-246. Exception masked in HCatSplit class (avandana via toffer)
 
   HCAT-211. Update tar ball installation documentation (vikram.dixit via 
khorgath)

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=1241346&r1=1241345&r2=1241346&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 Feb  7 04:30:16 2012
@@ -91,16 +91,9 @@ public class NotificationListener extend
        private static String getTopicName(Partition partition,
                        ListenerEvent partitionEvent) throws MetaException {
                try {
-                       String topicName = partitionEvent.getHandler()
+                       return 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());
                }
@@ -115,7 +108,16 @@ public class NotificationListener extend
 
                        Partition partition = partitionEvent.getPartition();
                        String topicName = getTopicName(partition, 
partitionEvent);
-                       send(partition, topicName, 
HCatConstants.HCAT_ADD_PARTITION_EVENT);                     
+      if (topicName != null && !topicName.equals("")) {
+                         send(partition, topicName, 
HCatConstants.HCAT_ADD_PARTITION_EVENT);
+      }
+      else {
+        LOG.info("Topic name not found in metastore. Suppressing HCatalog 
notification for " + partition.getDbName()
+            + "." + partition.getTableName()
+            + " To enable notifications for this table, please do alter table 
set properties ("
+            + HCatConstants.HCAT_MSGBUS_TOPIC_NAME
+            + "=<dbname>.<tablename>) or whatever you want topic name to be.");
+      }
                }
 
        }
@@ -137,7 +139,16 @@ public class NotificationListener extend
                        sd.setParameters(new HashMap<String, String>());
                        sd.getSerdeInfo().setParameters(new HashMap<String, 
String>());
                        String topicName = getTopicName(partition, 
partitionEvent);
-                       send(partition, topicName, 
HCatConstants.HCAT_DROP_PARTITION_EVENT);
+      if (topicName != null && !topicName.equals("")) {
+                         send(partition, topicName, 
HCatConstants.HCAT_DROP_PARTITION_EVENT);
+      }
+      else {
+        LOG.info("Topic name not found in metastore. Suppressing HCatalog 
notification for " + partition.getDbName()
+            + "." + partition.getTableName()
+            + " To enable notifications for this table, please do alter table 
set properties ("
+            + HCatConstants.HCAT_MSGBUS_TOPIC_NAME
+            + "=<dbname>.<tablename>) or whatever you want topic name to be.");
+      }
                }
        }
 


Reply via email to