incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From avand...@apache.org
Subject svn commit: r1408429 - in /incubator/hcatalog/trunk: CHANGES.txt server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java
Date Mon, 12 Nov 2012 19:59:58 GMT
Author: avandana
Date: Mon Nov 12 19:59:57 2012
New Revision: 1408429

URL: http://svn.apache.org/viewvc?rev=1408429&view=rev
Log:
HCAT-548 Move topic creation in NotificationListener to a separate method 

Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    incubator/hcatalog/trunk/server-extensions/src/main/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=1408429&r1=1408428&r2=1408429&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Mon Nov 12 19:59:57 2012
@@ -44,6 +44,8 @@ Trunk (unreleased changes)
   HCAT-427 Document storage-based authorization (lefty via gates)
 
   IMPROVEMENTS
+  HCAT-548 Move topic creation in NotificationListener to a separate method (amalakar via
avandana)
+
   HCAT-538 HCatalogStorer fails for 100GB of data with dynamic partitioning, number of partition
is 300 (amalakar via toffer)
 
   HCAT-532 HiveClientCache shutdown hook should log at debug level (traviscrawford)

Modified: incubator/hcatalog/trunk/server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java?rev=1408429&r1=1408428&r2=1408429&view=diff
==============================================================================
--- incubator/hcatalog/trunk/server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java
(original)
+++ incubator/hcatalog/trunk/server-extensions/src/main/java/org/apache/hcatalog/listener/NotificationListener.java
Mon Nov 12 19:59:57 2012
@@ -34,6 +34,7 @@ import javax.jms.MapMessage;
 import javax.jms.Message;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
+import javax.jms.Topic;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -266,7 +267,6 @@ public class NotificationListener extend
      *          select messages in client side.
      */
     protected void send(Object msgBody, String topicName, String event) {
-
         try {
 
             Destination topic = null;
@@ -280,18 +280,7 @@ public class NotificationListener extend
                     return;
                 }
             }
-            try {
-                // Topics are created on demand. If it doesn't exist on broker it will
-                // be created when broker receives this message.
-                topic = session.createTopic(topicName);
-            } catch (IllegalStateException ise) {
-                // this will happen if we were able to establish connection once, but
-                // its no longer valid,
-                // ise is thrown, catch it and retry.
-                LOG.error("Seems like connection is lost. Retrying", ise);
-                createConnection();
-                topic = session.createTopic(topicName);
-            }
+            topic = getTopic(topicName);
             if (null == topic) {
                 // Still not successful, return from here.
                 LOG.error("Invalid session. Failed to send message on topic: "
@@ -318,8 +307,32 @@ public class NotificationListener extend
         } catch (Exception e) {
             // Gobble up the exception. Message delivery is best effort.
             LOG.error("Failed to send message on topic: " + topicName + " event: "
-                + event, e);
+                    + event, e);
+        }
+    }
+
+    /**
+     * Get the topic object for the topicName, it also tries to reconnect
+     * if the connection appears to be broken.
+     *
+     * @param topicName
+     * @return
+     * @throws JMSException
+     */
+    protected Topic getTopic(final String topicName) throws JMSException {
+        Topic topic;
+        try {
+            // Topics are created on demand. If it doesn't exist on broker it will
+            // be created when broker receives this message.
+            topic = session.createTopic(topicName);
+        } catch (IllegalStateException ise) {
+            // this will happen if we were able to establish connection once, but its no
longer valid,
+            // ise is thrown, catch it and retry.
+            LOG.error("Seems like connection is lost. Retrying", ise);
+            createConnection();
+            topic = session.createTopic(topicName);
         }
+        return topic;
     }
 
     protected void createConnection() {



Mime
View raw message