From 3c29cd2e324f4f52a9e8b0cba1a39c9fd97a00ed Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 29 Jul 2005 13:30:45 +0000 Subject: [PATCH] * Use Hashtable instead of WeakHashMap for activeCronJobs - we're using function names as keys, so it's actually bogus to use WeakHashMap, plus WeakHashMap is not synchronized. * Add event log statements each time cron jobs are executed: List of cron jobs we're going to execute, and the map of cron jobs still active from last time. * Add log statement if CronRunner catches an exception, just so it behaves like the same-thread cron execution code. --- src/helma/framework/core/Application.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index 7ea2490f..9a0d0177 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -163,7 +163,7 @@ public final class Application implements IPathElement, Runnable { private String xmlrpcHandlerName; // the list of currently active cron jobs - private Map activeCronJobs = null; + Hashtable activeCronJobs = null; // the list of custom cron jobs Hashtable customCronJobs = null; @@ -361,7 +361,7 @@ public final class Application implements IPathElement, Runnable { } activeRequests = new Hashtable(); - activeCronJobs = new WeakHashMap(); + activeCronJobs = new Hashtable(); customCronJobs = new Hashtable(); // create the skin manager @@ -1492,6 +1492,9 @@ public final class Application implements IPathElement, Runnable { jobs.addAll(customCronJobs.values()); CronJob.sort(jobs); + logEvent("Running cron jobs: " + jobs); + logEvent("Cron jobs still running from last minute: " + activeCronJobs); + for (Iterator i = jobs.iterator(); i.hasNext();) { CronJob job = (CronJob) i.next(); @@ -1522,16 +1525,16 @@ public final class Application implements IPathElement, Runnable { // the job is run from an extra thread if ((job.getTimeout() > 20000) || (CronJob.millisToNextFullMinute() < 30000)) { - CronRunner r = new CronRunner(evaluator, job); + CronRunner runner = new CronRunner(evaluator, job); - activeCronJobs.put(job.getName(), r); - r.start(); + activeCronJobs.put(job.getName(), runner); + runner.start(); } else { try { evaluator.invokeInternal(null, job.getFunction(), new Object[0], job.getTimeout()); } catch (Exception ex) { - logEvent("error running " + job + ": " + ex.toString()); + logEvent("error running " + job + ": " + ex); } finally { releaseEvaluator(evaluator); } @@ -1949,7 +1952,7 @@ public final class Application implements IPathElement, Runnable { thisEvaluator.invokeInternal(null, job.getFunction(), new Object[0], job.getTimeout()); } catch (Exception ex) { - // gets logged in RequestEvaluator + logEvent("error running " + job + ": " + ex); } finally { releaseEvaluator(thisEvaluator); thisEvaluator = null;