Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 67899 invoked from network); 9 Sep 2004 01:47:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 9 Sep 2004 01:47:35 -0000 Received: (qmail 46013 invoked by uid 500); 9 Sep 2004 01:47:35 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 45865 invoked by uid 500); 9 Sep 2004 01:47:34 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 45853 invoked by uid 99); 9 Sep 2004 01:47:33 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 08 Sep 2004 18:47:33 -0700 Received: (qmail 67819 invoked by uid 65534); 9 Sep 2004 01:47:32 -0000 Date: 9 Sep 2004 01:47:32 -0000 Message-ID: <20040909014732.67815.qmail@minotaur.apache.org> From: vgritsenko@apache.org To: cvs@cocoon.apache.org Subject: svn commit: rev 43558 - in cocoon/branches/BRANCH_2_1_X: . src/blocks/cron/java/org/apache/cocoon/components/cron X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: vgritsenko Date: Wed Sep 8 18:47:31 2004 New Revision: 43558 Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java cocoon/branches/BRANCH_2_1_X/status.xml Log: Fix memory leak (release pipelines), fix typo tiggers -> triggers. Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobExecutor.java Wed Sep 8 18:47:31 2004 @@ -24,14 +24,12 @@ import org.apache.cocoon.Processor; import org.apache.cocoon.components.CocoonComponentManager; import org.apache.cocoon.environment.background.BackgroundEnvironment; -import org.apache.cocoon.util.NullOutputStream; import org.quartz.Job; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; -import java.io.OutputStream; import java.net.MalformedURLException; import java.util.Map; @@ -45,12 +43,9 @@ */ public class QuartzJobExecutor implements Job { - /** Shared instance (no state, as it does nothing) */ - static final OutputStream NULL_OUTPUT = new NullOutputStream(); - /* (non-Javadoc) - * @see org.quartz.Job#execute(org.quartz.JobExecutionContext) - */ + * @see org.quartz.Job#execute(org.quartz.JobExecutionContext) + */ public void execute(final JobExecutionContext context) throws JobExecutionException { final JobDataMap data = context.getJobDetail().getJobDataMap(); @@ -97,6 +92,7 @@ throw new JobExecutionException(e); } + Object key = CocoonComponentManager.startProcessing(env); CocoonComponentManager.enterEnvironment(env, new WrapperComponentManager(manager), processor); boolean release = false; try { @@ -136,10 +132,12 @@ data.put(QuartzJobScheduler.DATA_MAP_KEY_ISRUNNING, Boolean.FALSE); CocoonComponentManager.leaveEnvironment(); - manager.release(processor); + CocoonComponentManager.endProcessing(env, key); + if (release) { manager.release(job); } + manager.release(processor); } } } Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobScheduler.java Wed Sep 8 18:47:31 2004 @@ -47,8 +47,8 @@ import org.quartz.SimpleTrigger; import org.quartz.Trigger; import org.quartz.impl.DirectSchedulerFactory; -import org.quartz.impl.jdbcjobstore.JobStoreSupport; import org.quartz.impl.jdbcjobstore.InvalidConfigurationException; +import org.quartz.impl.jdbcjobstore.JobStoreSupport; import org.quartz.simpl.RAMJobStore; import org.quartz.spi.JobStore; import org.quartz.utils.ConnectionProvider; @@ -333,7 +333,6 @@ if (getLogger().isDebugEnabled() && (triggers.length == 0)) { getLogger().debug("no triggers configured at startup"); } - } /* (non-Javadoc) @@ -666,32 +665,32 @@ } /** - * Create the tiggers + * Create the triggers * - * @param tiggers array of tigger configuration elements + * @param triggers array of trigger configuration elements * * @throws ConfigurationException thrown in case of configuration failures */ - private void createTriggers(final Configuration[] tiggers) + private void createTriggers(final Configuration[] triggers) throws ConfigurationException { - for (int i = 0; i < tiggers.length; i++) { - String cron = tiggers[i].getChild("cron").getValue(null); + for (int i = 0; i < triggers.length; i++) { + String cron = triggers[i].getChild("cron").getValue(null); if (null == cron) { - final String seconds = tiggers[i].getChild("seconds").getValue("0"); - final String minutes = tiggers[i].getChild("minutes").getValue("*"); - final String hours = tiggers[i].getChild("hours").getValue("*"); - final String days = tiggers[i].getChild("days").getValue("*"); - final String months = tiggers[i].getChild("months").getValue("*"); - final String weekdays = tiggers[i].getChild("weekdays").getValue("?"); - final String years = tiggers[i].getChild("years").getValue("*"); + final String seconds = triggers[i].getChild("seconds").getValue("0"); + final String minutes = triggers[i].getChild("minutes").getValue("*"); + final String hours = triggers[i].getChild("hours").getValue("*"); + final String days = triggers[i].getChild("days").getValue("*"); + final String months = triggers[i].getChild("months").getValue("*"); + final String weekdays = triggers[i].getChild("weekdays").getValue("?"); + final String years = triggers[i].getChild("years").getValue("*"); cron = seconds + " " + minutes + " " + hours + " " + days + " " + months + " " + weekdays + " " + years; } try { - addJob(tiggers[i].getAttribute("name"), tiggers[i].getAttribute("target"), cron, - tiggers[i].getAttributeAsBoolean("concurrent-runs", true)); + addJob(triggers[i].getAttribute("name"), triggers[i].getAttribute("target"), cron, + triggers[i].getAttributeAsBoolean("concurrent-runs", true)); } catch (final CascadingException ce) { throw new ConfigurationException("failed adding trigger to scheduler", ce); } Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/TestCronJob.java Wed Sep 8 18:47:31 2004 @@ -28,7 +28,6 @@ import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceResolver; - /** * A simple test CronJob which also calls a pipeline internally. * @@ -78,27 +77,29 @@ SourceResolver resolver = null; Source src = null; try { - resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE); - src = resolver.resolveURI("cocoon://" + pipeline); - InputStream is = src.getInputStream(); - - InputStreamReader reader = new InputStreamReader(is); - StringBuffer sb = new StringBuffer(); - char[] b = new char[8192]; - int n; + resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE); + src = resolver.resolveURI("cocoon://" + this.pipeline); - while((n = reader.read(b)) > 0) { - sb.append(b, 0, n); + InputStreamReader r = new InputStreamReader(src.getInputStream()); + try { + StringBuffer sb = new StringBuffer(); + char[] b = new char[8192]; + int n; + + while((n = r.read(b)) > 0) { + sb.append(b, 0, n); + } + + getLogger().info("CronJob " + name + " called pipeline " + pipeline + + " and received following content:\n" + sb.toString()); + } finally { + r.close(); } - reader.close(); - - getLogger().info("Cronjob " + name + " called pipeline " + pipeline + - " and received following content:\n" + sb.toString() ); } catch(Exception e) { throw new CascadingRuntimeException("CronJob " + name + " raised an exception", e); } finally { - if ( resolver != null ) { + if (resolver != null) { resolver.release(src); this.manager.release(resolver); resolver = null; @@ -114,7 +115,6 @@ getLogger().info("CronJob " + name + " finished at " + new Date() + " with message '" + m_msg + "' and sleep timeout of " + m_sleep + "ms"); - } /* (non-Javadoc) Modified: cocoon/branches/BRANCH_2_1_X/status.xml ============================================================================== --- cocoon/branches/BRANCH_2_1_X/status.xml (original) +++ cocoon/branches/BRANCH_2_1_X/status.xml Wed Sep 8 18:47:31 2004 @@ -204,6 +204,9 @@ + + Cron block: Fixed memory leak, QuartzJobExecutor was not releasing pipelines. + Updated jexl to 1.0, lucene to 1.4.1