[rhq] Branch 'feature/hadoop-plugin' - modules/core

lkrejci lkrejci at fedoraproject.org
Mon Aug 6 17:56:55 UTC 2012


 modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/MultiLineLogEntryProcessor.java |    3 +
 modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventPollerRunner.java               |   24 ++++++++--
 2 files changed, 23 insertions(+), 4 deletions(-)

New commits:
commit c82eb40efe105f8d719cbc16592add9e259dbd10
Author: Lukas Krejci <lkrejci at redhat.com>
Date:   Mon Aug 6 19:56:30 2012 +0200

    More rigorous error handling while processing the log files to prevent
    a runtime exception cancel the scheduled job for log processing for given
    resource.

diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/MultiLineLogEntryProcessor.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/MultiLineLogEntryProcessor.java
index ade5078..0967bc9 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/MultiLineLogEntryProcessor.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/MultiLineLogEntryProcessor.java
@@ -137,6 +137,9 @@ public abstract class MultiLineLogEntryProcessor implements LogEntryProcessor {
             } catch (java.text.ParseException e) {
                 throw new ParseException("Unable to parse date [" + dateString + "] using date format [" + dateFormat
                     + "].", e);
+            } catch (RuntimeException e) {
+                throw new ParseException("Unable to parse date [" + dateString + "] using date format [" + dateFormat
+                    + "].", e);
             }
             setDateIfNotSet(timestamp);
         }
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventPollerRunner.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventPollerRunner.java
index ac8c39b..2817956 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventPollerRunner.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventPollerRunner.java
@@ -24,9 +24,12 @@ package org.rhq.core.pc.event;
 
 import java.util.Set;
 
-import org.rhq.core.pluginapi.event.EventPoller;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.rhq.core.domain.event.Event;
 import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pluginapi.event.EventPoller;
 
 /**
  * A thread for running an {@link EventPoller} to check for new {@link Event}s of a certain type from a particular
@@ -35,6 +38,9 @@ import org.rhq.core.domain.resource.Resource;
  * @author Ian Springer
  */
 public class EventPollerRunner implements Runnable {    
+
+    private static final Log LOG = LogFactory.getLog(EventPollerRunner.class);
+    
     private EventPoller eventPoller;
     private Resource resource;
     private EventManager eventManager;
@@ -46,9 +52,19 @@ public class EventPollerRunner implements Runnable {
     }
 
     public void run() {
-        Set<Event> events = this.eventPoller.poll();
-        if (events != null) {
-            this.eventManager.publishEvents(events, this.resource);
+        try {
+            Set<Event> events = this.eventPoller.poll();
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Gathered " + (events == null ? "no" : events.size()) + " events on resource " + resource + " using the poller " + eventPoller);
+            }
+            if (events != null) {
+                this.eventManager.publishEvents(events, this.resource);
+            }
+        } catch (RuntimeException e) {
+            LOG.error("Event poller for resource " + resource + 
+                " failed with a unhandled exception. No future events will be reported for the resource until the plugin container is restarted. "
+                + "This is an error and should not have happened. Please report this as a bug.", e);
+            throw e;
         }
     }
 }
\ No newline at end of file




More information about the rhq-commits mailing list