From: <sc...@hy...> - 2010-03-08 03:58:19
|
Author: scottmf Date: 2010-03-07 19:58:08 -0800 (Sun, 07 Mar 2010) New Revision: 14353 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14353 Modified: trunk/src/org/hyperic/hq/galerts/processor/GalertProcessor.java Log: [HHQ-3747] changed so that each event is processed in its own session. Not doing it this way causes backups in the queue when one of the first events in the batch gets put into readwrite mode. Under heavy load it would consistly bring the server down due to OOM. Modified: trunk/src/org/hyperic/hq/galerts/processor/GalertProcessor.java =================================================================== --- trunk/src/org/hyperic/hq/galerts/processor/GalertProcessor.java 2010-03-07 09:26:52 UTC (rev 14352) +++ trunk/src/org/hyperic/hq/galerts/processor/GalertProcessor.java 2010-03-08 03:58:08 UTC (rev 14353) @@ -86,33 +86,15 @@ * Entry point to the processor from the {@link EventListener} * * @param events A list of {@link Zevent}s to process - * - * TODO: This needs to be optimized so that the EventListener buffers - * up many events and calls this method. The overhead of creating - * and checking session existance is too high on a per-event - * basis. */ void processEvents(final List events) { - try { - SessionManager.runInSession(new SessionRunner() { - public String getName() { - return "Event Processor"; - } - - public void run() throws Exception { - for (Iterator i=events.iterator(); i.hasNext(); ) { - Zevent z = (Zevent)i.next(); - - processEvent(z); - } - } - }); - } catch(Exception e) { - _log.warn("Error processing events", e); + for (Iterator i=events.iterator(); i.hasNext(); ) { + Zevent z = (Zevent)i.next(); + processEvent(z); } } - private void processEvent(Zevent event) { + private void processEvent(final Zevent event) { ZeventSourceId source = event.getSourceId(); Set listenerDupe; @@ -126,12 +108,23 @@ } for (Iterator i=listenerDupe.iterator(); i.hasNext(); ) { - Gtrigger t = (Gtrigger)i.next(); + final Gtrigger t = (Gtrigger)i.next(); // Synchronize around all event processing for a trigger, since // they keep state and will need to be flushed synchronized(t) { - t.processEvent(event); + try { + SessionManager.runInSession(new SessionRunner() { + public String getName() { + return "Event Processor"; + } + public void run() throws Exception { + t.processEvent(event); + } + }); + } catch (Exception e) { + _log.warn("Error processing events", e); + } } } } |