JBoss JBPM SVN: r6929 - jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-16 11:20:58 -0400 (Mon, 16 May 2011)
New Revision: 6929
Modified:
jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/async.xml
Log:
JBPM-3192
Clarify need for unique job executor name.
Modified: jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/async.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/async.xml 2011-05-16 14:00:01 UTC (rev 6928)
+++ jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/async.xml 2011-05-16 15:20:58 UTC (rev 6929)
@@ -251,7 +251,8 @@
</para>
<important>
<para>
- This name should be unique for each node in a cluster.
+ This name should be unique for each node, when more
+ than one jBPM instance is started on a single machine.
</para>
</important>
</listitem>
13 years
JBoss JBPM SVN: r6928 - in jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US: extras and 1 other directory.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-16 10:00:01 -0400 (Mon, 16 May 2011)
New Revision: 6928
Modified:
jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/async.xml
jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/extras/configuration_1.xmlt
Log:
Update documentation to match job executor changes. Add a section describing
job executor configuration variables.
Modified: jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/async.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/async.xml 2011-05-16 13:58:11 UTC (rev 6927)
+++ jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/async.xml 2011-05-16 14:00:01 UTC (rev 6928)
@@ -186,26 +186,23 @@
executor must execute the jobs. This is done in two phases.
<itemizedlist>
<listitem>
- <para>A job executor thread must acquire a job</para>
+ <para>The dispatcher thread must acquire a job</para>
</listitem>
<listitem>
- <para>The thread that acquired the job must execute it</para>
+ <para>An executor thread must execute the job</para>
</listitem>
</itemizedlist>
</para>
- <para>Acquiring a job and executing the job are done in 2 separate transactions. A thread
- acquires a job by putting its name into the owner field of the job. Each thread has a unique
- name based on IP address and sequence number. Hibernate's optimistic locking is enabled on
- <literal>Job</literal>-objects. So if 2 threads try to acquire a job concurrently, one of
- them will get a StaleObjectException and rollback. Only the first one will succeed. The
- thread that succeeds in acquiring a job is now responsible for executing it in a separate
- transaction.
+ <para>Acquiring a job and executing the job are done in 2 separate transactions. The
+ dispatcher thread acquires jobs from the database on behalf of all the executor threads
+ on this node. When the executor thread takes the job, it adds its name into the owner
+ field of the job. Each thread has a unique name based on IP address and sequence number.
</para>
<para>A thread could die between acquisition and execution of a job. To clean-up after
those situations, there is one lock-monitor thread per job executor that checks the lock times.
- The lock monitor thread will unlock any jobs that have been locked for more than 30 minutes,
+ The lock monitor thread will unlock any jobs that have been locked for more than 10 minutes,
so that they can be executed by another job executor thread.
</para>
@@ -230,6 +227,126 @@
<literal>READ_COMMITTED</literal> is not enough because it allows for Non-Repeatable reads to occur.
So <literal>REPEATABLE_READ</literal> is required if you configure more than one job executor thread.
</para>
+
+ <para>
+ Configuration properties related to the job executor are:
+ </para>
+
+ <variablelist>
+
+ <varlistentry>
+ <term><property>jbpmConfiguration</property></term>
+ <listitem>
+ <para>
+ The bean from which configuration is retrieved.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>name</property></term>
+ <listitem>
+ <para>
+ The name of this executor.
+ </para>
+ <important>
+ <para>
+ This name should be unique for each node in a cluster.
+ </para>
+ </important>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>nbrOfThreads</property></term>
+ <listitem>
+ <para>
+ The number of executor threads that are started.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>idleInterval</property></term>
+ <listitem>
+ <para>
+ The interval that the dispatcher thread will wait before
+ checking the job queue, if there are no jobs pending.
+ </para>
+ <note>
+ <para>
+ The dispatcher thread is automatically notifed when jobs
+ are added to the queue.
+ </para>
+ </note>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>retryInterval</property></term>
+ <listitem>
+ <para>
+ The interval that a job will wait between retries, if it
+ fails during execution.
+ </para>
+ <note>
+ <para>
+ The maximum number of retries is configured by
+ <property>jbpm.job.retries</property>.
+ </para>
+ </note>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>maxIdleInterval</property></term>
+ <listitem>
+ <para>
+ The maximum period for <property>idleInterval</property>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>historyMaxSize</property></term>
+ <listitem>
+ <para>
+ This property is deprecated, and has no affect.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>maxLockTime</property></term>
+ <listitem>
+ <para>
+ The macimum time that a job can be locked, before the
+ lock-monitor thread will unlock it.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>lockMonitorInterval</property></term>
+ <listitem>
+ <para>
+ The period for which the lock-monitor thread will sleep
+ between checking for locked jobs.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><property>lockBufferTime</property></term>
+ <listitem>
+ <para>
+ This property is deprecated, and has no affect.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
</section>
<section id="jbpmsbuiltinasynchronousmessaging">
Modified: jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/extras/configuration_1.xmlt
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/extras/configuration_1.xmlt 2011-05-16 13:58:11 UTC (rev 6927)
+++ jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/extras/configuration_1.xmlt 2011-05-16 14:00:01 UTC (rev 6928)
@@ -59,7 +59,8 @@
</field>
<field name='name'><string value='JbpmJobExecutor' /></field>
<field name='nbrOfThreads'><int value='1' /></field>
- <field name='idleInterval'><int value='5000' /></field>
+ <field name='idleInterval'><int value='60000' /></field>
+ <field name='retryInterval'><int value='4000' /></field>
<!-- 1 hour -->
<field name='maxIdleInterval'><int value='3600000' /></field>
<field name='historyMaxSize'><int value='20' /></field>
@@ -70,4 +71,4 @@
<!-- 5 seconds -->
<field name='lockBufferTime'><int value='5000' /></field>
</bean>
-</jbpm-configuration>
\ No newline at end of file
+</jbpm-configuration>
13 years
JBoss JBPM SVN: r6927 - jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-16 09:58:11 -0400 (Mon, 16 May 2011)
New Revision: 6927
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
Log:
Set the default RetryInterval to 4000ms, to go with the altered retry
behaviour.
>From kconner@.
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2011-05-16 13:56:34 UTC (rev 6926)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2011-05-16 13:58:11 UTC (rev 6927)
@@ -109,8 +109,8 @@
<int value="60000" />
</property>
<property name="retryInterval">
- <!-- 1 second -->
- <int value="1000" />
+ <!-- 4 seconds -->
+ <int value="4000" />
</property>
<property name="maxIdleInterval">
<!-- 1 hour -->
13 years
JBoss JBPM SVN: r6926 - in jbpm3/branches/jbpm-3.2-soa/core/src/main: java/org/jbpm/job/executor and 1 other directories.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-16 09:56:34 -0400 (Mon, 16 May 2011)
New Revision: 6926
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
Log:
Updates to the job executor fixes (revision 6918):
o increase the retry count when we unlock a job if an error has occurred.
Otherwise, we would decrease the value when we shouldn't
o remove the additional unlocking code, as the lock-monitor thread will
handle this for us
>From kconner@
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/db/JobSession.java 2011-05-16 09:20:03 UTC (rev 6925)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/db/JobSession.java 2011-05-16 13:56:34 UTC (rev 6926)
@@ -275,14 +275,4 @@
}
return session.createCriteria(Job.class).add(Restrictions.in("id", jobs)).list();
}
-
- public void releaseLockedJobs(final String lockOwner) {
- try {
- session.getNamedQuery("JobSession.releaseLockedJobs")
- .setString("lockOwner", lockOwner)
- .executeUpdate();
- } catch (HibernateException e) {
- throw new JbpmPersistenceException("could not release locked jobs by owner '" + lockOwner + "'", e);
- }
- }
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2011-05-16 09:20:03 UTC (rev 6925)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2011-05-16 13:56:34 UTC (rev 6926)
@@ -17,8 +17,6 @@
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.db.JobSession;
import org.jbpm.job.Job;
import edu.emory.mathcs.backport.java.util.concurrent.locks.Condition;
@@ -498,37 +496,10 @@
private void activateDispatcher() {
waitingExecutorLock.lock() ;
- try {
- if (!dispatcherActive) {
- unlockOurJobs() ;
- dispatcherActive = true ;
- }
- } finally {
- waitingExecutorLock.unlock() ;
- }
+ dispatcherActive = true ;
+ waitingExecutorLock.unlock() ;
}
- private void unlockOurJobs() {
- final JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
- try {
- final String lockOwner = getName();
- final JobSession jobSession = jbpmContext.getJobSession();
- jobSession.releaseLockedJobs(lockOwner);
- } catch (RuntimeException e) {
- jbpmContext.setRollbackOnly();
- if (log.isDebugEnabled()) log.debug("failed to release locked jobs", e);
- } catch (Error e) {
- jbpmContext.setRollbackOnly();
- throw e;
- } finally {
- try {
- jbpmContext.close();
- } catch (RuntimeException e) {
- if (log.isDebugEnabled()) log.debug("failed to release locked jobs", e);
- }
- }
- }
-
private void deactivateDispatcher() {
waitingExecutorLock.lock() ;
try {
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2011-05-16 09:20:03 UTC (rev 6925)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2011-05-16 13:56:34 UTC (rev 6926)
@@ -219,6 +219,10 @@
// unlock job
job.setLockOwner(null);
job.setLockTime(null);
+ if (job.getException() != null)
+ {
+ job.setRetries(job.getRetries()+1) ;
+ }
}
catch (RuntimeException e) {
jbpmContext.setRollbackOnly();
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2011-05-16 09:20:03 UTC (rev 6925)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2011-05-16 13:56:34 UTC (rev 6926)
@@ -401,16 +401,6 @@
]]>
</query>
- <query name="JobSession.releaseLockedJobs">
- <![CDATA[
- update org.jbpm.job.Job job
- set job.lockOwner = null, job.lockTime = null
- where (job.lockOwner = :lockOwner)
- and job.retries > 0
- and job.isSuspended = false
- ]]>
- </query>
-
<!-- related to Tasks -->
<!-- ########################### -->
13 years
JBoss JBPM SVN: r6925 - jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/ant.
by do-not-reply@jboss.org
Author: mputz
Date: 2011-05-16 05:20:03 -0400 (Mon, 16 May 2011)
New Revision: 6925
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/ant/DeployProcessTask.java
Log:
JBPM-3190: Initialize fileSets List to avoid NullPointerException
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/ant/DeployProcessTask.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/ant/DeployProcessTask.java 2011-05-13 15:33:15 UTC (rev 6924)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/ant/DeployProcessTask.java 2011-05-16 09:20:03 UTC (rev 6925)
@@ -46,7 +46,7 @@
private String jbpmCfg;
private File process;
- private List fileSets;
+ private List fileSets = new ArrayList();
private boolean failOnError = true;
public void execute() throws BuildException {
13 years
JBoss JBPM SVN: r6924 - jbpm3/tags.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-13 11:33:15 -0400 (Fri, 13 May 2011)
New Revision: 6924
Added:
jbpm3/tags/3.2.10.SP2/
Log:
Create 3.2.10.SP2 tag from 3.2.10.SP branch
13 years
JBoss JBPM SVN: r6923 - jbpm3/tags.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-13 11:32:19 -0400 (Fri, 13 May 2011)
New Revision: 6923
Removed:
jbpm3/tags/3.2.10.SP2/
Log:
Delete incorrect 3.2.10.SP2 tag
13 years
JBoss JBPM SVN: r6922 - in jbpm3/branches/3.2.10.SP: core and 12 other directories.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-13 11:31:36 -0400 (Fri, 13 May 2011)
New Revision: 6922
Modified:
jbpm3/branches/3.2.10.SP/core/pom.xml
jbpm3/branches/3.2.10.SP/db/pom.xml
jbpm3/branches/3.2.10.SP/distribution/pom.xml
jbpm3/branches/3.2.10.SP/distribution/src/main/resources/examples/module/pom.xml
jbpm3/branches/3.2.10.SP/distribution/src/main/resources/examples/pom.xml
jbpm3/branches/3.2.10.SP/enterprise-jee5/pom.xml
jbpm3/branches/3.2.10.SP/enterprise/pom.xml
jbpm3/branches/3.2.10.SP/examples/pom.xml
jbpm3/branches/3.2.10.SP/identity/pom.xml
jbpm3/branches/3.2.10.SP/pom.xml
jbpm3/branches/3.2.10.SP/simulation/pom.xml
jbpm3/branches/3.2.10.SP/soa-distribution/pom.xml
jbpm3/branches/3.2.10.SP/tomcat/pom.xml
jbpm3/branches/3.2.10.SP/userguide/pom.xml
Log:
Update version to 3.2.10.SP2
Modified: jbpm3/branches/3.2.10.SP/core/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/core/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/core/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<!-- Dependencies -->
Modified: jbpm3/branches/3.2.10.SP/db/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/db/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/db/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
<relativePath>../pom.xml</relativePath>
</parent>
Modified: jbpm3/branches/3.2.10.SP/distribution/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/distribution/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/distribution/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<!-- Properties -->
Modified: jbpm3/branches/3.2.10.SP/distribution/src/main/resources/examples/module/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/distribution/src/main/resources/examples/module/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/distribution/src/main/resources/examples/module/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<artifactId>jbpm-examples-dist</artifactId>
<groupId>org.jbpm.jbpm3</groupId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<build>
Modified: jbpm3/branches/3.2.10.SP/distribution/src/main/resources/examples/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/distribution/src/main/resources/examples/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/distribution/src/main/resources/examples/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -19,7 +19,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<modules>
Modified: jbpm3/branches/3.2.10.SP/enterprise/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/enterprise/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/enterprise/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<!-- Dependencies -->
Modified: jbpm3/branches/3.2.10.SP/enterprise-jee5/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/enterprise-jee5/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/enterprise-jee5/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -17,7 +17,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<properties>
Modified: jbpm3/branches/3.2.10.SP/examples/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/examples/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/examples/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<!-- Dependencies -->
Modified: jbpm3/branches/3.2.10.SP/identity/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/identity/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/identity/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<!-- Dependencies -->
Modified: jbpm3/branches/3.2.10.SP/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -13,7 +13,7 @@
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
<packaging>pom</packaging>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
<!-- Source Control Management -->
<scm>
Modified: jbpm3/branches/3.2.10.SP/simulation/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/simulation/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/simulation/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<!-- Profiles -->
Modified: jbpm3/branches/3.2.10.SP/soa-distribution/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/soa-distribution/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/soa-distribution/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -19,7 +19,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<properties>
Modified: jbpm3/branches/3.2.10.SP/tomcat/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/tomcat/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/tomcat/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -7,7 +7,7 @@
<parent>
<artifactId>jbpm</artifactId>
<groupId>org.jbpm.jbpm3</groupId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<properties>
Modified: jbpm3/branches/3.2.10.SP/userguide/pom.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/userguide/pom.xml 2011-05-13 15:11:53 UTC (rev 6921)
+++ jbpm3/branches/3.2.10.SP/userguide/pom.xml 2011-05-13 15:31:36 UTC (rev 6922)
@@ -18,7 +18,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm</artifactId>
- <version>3.2.10.SP1</version>
+ <version>3.2.10.SP2</version>
</parent>
<!-- Plugins -->
13 years
JBoss JBPM SVN: r6921 - jbpm3/tags.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-13 11:11:53 -0400 (Fri, 13 May 2011)
New Revision: 6921
Added:
jbpm3/tags/3.2.10.SP2/
Log:
Create 3.2.10.SP2 tag from 3.2.10.SP branch
13 years
JBoss JBPM SVN: r6920 - in jbpm3/branches/3.2.10.SP/core/src/main: java/org/jbpm/job/executor and 1 other directories.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2011-05-13 11:09:03 -0400 (Fri, 13 May 2011)
New Revision: 6920
Modified:
jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/DispatcherThread.java
jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/3.2.10.SP/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
Log:
Pull up revisions 6918, 6919 from jbpm-3.2-soa branch:
SOA-3007.
Fix problems with the split of the old JobExecutorThread(s) into the new
DispatcherThread + JobExecutorThread(s):
o the DispatcherThread busy-waits in a loop (and uses CPU)
o job processing could be deferred for an indeterminate time.
o crashing at certain points could leave jobs locked (not processed)
indefinitely
Fix by kconner@.
Modified: jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/db/JobSession.java 2011-05-13 15:04:52 UTC (rev 6919)
+++ jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/db/JobSession.java 2011-05-13 15:09:03 UTC (rev 6920)
@@ -275,4 +275,14 @@
}
return session.createCriteria(Job.class).add(Restrictions.in("id", jobs)).list();
}
+
+ public void releaseLockedJobs(final String lockOwner) {
+ try {
+ session.getNamedQuery("JobSession.releaseLockedJobs")
+ .setString("lockOwner", lockOwner)
+ .executeUpdate();
+ } catch (HibernateException e) {
+ throw new JbpmPersistenceException("could not release locked jobs by owner '" + lockOwner + "'", e);
+ }
+ }
}
Modified: jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/DispatcherThread.java
===================================================================
--- jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/DispatcherThread.java 2011-05-13 15:04:52 UTC (rev 6919)
+++ jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/DispatcherThread.java 2011-05-13 15:09:03 UTC (rev 6920)
@@ -52,40 +52,28 @@
}
public void run() {
- int retryInterval = jobExecutor.getRetryInterval();
while (active) {
- // acquire job; on exception, call returns null
- Job job = acquireJob();
- // submit job
- if (job != null) submitJob(job);
+ if (jobExecutor.waitForFreeExecutorThread()) {
+ // acquire job; on exception, call returns null
+ Job job = acquireJob();
+ // submit job
+ if (job != null) {
+ submitJob(job);
+ continue ;
+ }
+ }
// if still active, wait or sleep
if (active) {
try {
- if (job != null) {
- // reset the current retry interval
- retryInterval = jobExecutor.getRetryInterval();
- // wait for next due job
- long waitPeriod = getWaitPeriod(jobExecutor.getIdleInterval());
- if (waitPeriod > 0) {
- synchronized (jobExecutor) {
+ // wait for next due job
+ long waitPeriod = getWaitPeriod(jobExecutor.getIdleInterval());
+ if (waitPeriod > 0) {
+ synchronized (jobExecutor) {
+ if (active)
jobExecutor.wait(waitPeriod);
- }
}
}
- else {
- // sleep instead of waiting on jobExecutor
- // to prevent message/scheduler service from waking up this thread
- sleep(retryInterval);
- // after an exception, double the current retry interval
- // to avoid continuous failures during anomalous conditions
- retryInterval *= 2;
- // enforce maximum idle interval
- int maxIdleInterval = jobExecutor.getMaxIdleInterval();
- if (retryInterval > maxIdleInterval || retryInterval < 0) {
- retryInterval = maxIdleInterval;
- }
- }
}
catch (InterruptedException e) {
if (log.isDebugEnabled()) log.debug(getName() + " got interrupted");
@@ -144,12 +132,8 @@
}
private void submitJob(Job job) {
- try {
- jobExecutor.getQueue().put(job);
- }
- catch (InterruptedException e) {
+ if (!jobExecutor.submitJob(job)) {
unlockJob(job);
- if (log.isDebugEnabled()) log.debug(getName() + " got interrupted");
}
}
Modified: jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2011-05-13 15:04:52 UTC (rev 6919)
+++ jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2011-05-13 15:09:03 UTC (rev 6920)
@@ -9,6 +9,7 @@
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -16,9 +17,13 @@
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.db.JobSession;
+import org.jbpm.job.Job;
-import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
-import edu.emory.mathcs.backport.java.util.concurrent.SynchronousQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.Condition;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
public class JobExecutor implements Serializable {
@@ -39,7 +44,13 @@
protected int lockBufferTime;
private ThreadGroup threadGroup;
- private BlockingQueue queue = new SynchronousQueue();
+ private int waitingExecutorCount ;
+ private boolean waitingDispatcher ;
+ private boolean dispatcherActive ;
+ private Lock waitingExecutorLock = new ReentrantLock() ;
+ private Condition waitingExecutorCondition = waitingExecutorLock.newCondition() ;
+ private Condition waitingDispatcherCondition = waitingExecutorLock.newCondition() ;
+ private LinkedList dispatchedJobs = new LinkedList();
/** @deprecated call {@link #getThreads()} instead */
protected Map threads;
@@ -56,6 +67,8 @@
if (!isStarted) {
log.info("starting " + name);
+ activateDispatcher() ;
+
// create thread group
threadGroup = new ThreadGroup(name) {
public void uncaughtException(Thread thread, Throwable throwable) {
@@ -119,6 +132,8 @@
}
}
+ deactivateDispatcher() ;
+
// return deactivated threads
return deactivatedThreads;
}
@@ -158,10 +173,6 @@
return threadGroup;
}
- BlockingQueue getQueue() {
- return queue;
- }
-
private String getThreadName(int index) {
return name + '@' + getHostAddress() + ":Executor-" + index;
}
@@ -418,5 +429,116 @@
this.nbrOfThreads = nbrOfThreads;
}
+ private boolean hasFreeExecutor() {
+ waitingExecutorLock.lock() ;
+ try {
+ return (waitingExecutorCount > dispatchedJobs.size()) ;
+ } finally {
+ waitingExecutorLock.unlock() ;
+ }
+ }
+ // return false when interrupted
+ boolean waitForFreeExecutorThread() {
+ waitingExecutorLock.lock() ;
+ try {
+ waitingDispatcher = true ;
+ if (dispatcherActive) {
+ if (hasFreeExecutor()) {
+ return true ;
+ } else {
+ waitingDispatcherCondition.await() ;
+ return hasFreeExecutor() ;
+ }
+ }
+ } catch (final InterruptedException ie) {
+ } finally {
+ waitingDispatcher = false ;
+ waitingExecutorLock.unlock() ;
+ }
+ return false ;
+ }
+
+ // return null when interrupted
+ Job getJob() {
+ waitingExecutorLock.lock() ;
+ try {
+ waitingExecutorCount++ ;
+ if (dispatcherActive) {
+ if (waitingDispatcher && hasFreeExecutor()) {
+ waitingDispatcherCondition.signal() ;
+ }
+ if (dispatchedJobs.isEmpty()) {
+ waitingExecutorCondition.await() ;
+ }
+ if (dispatchedJobs.size() > 0) {
+ return (Job)dispatchedJobs.remove() ;
+ }
+ }
+ } catch (final InterruptedException ie) {
+ } finally {
+ waitingExecutorCount-- ;
+ waitingExecutorLock.unlock() ;
+ }
+ return null ;
+ }
+
+ boolean submitJob(final Job job) {
+ waitingExecutorLock.lock() ;
+ try {
+ if (hasFreeExecutor()) {
+ dispatchedJobs.add(job) ;
+ waitingExecutorCondition.signal() ;
+ return true ;
+ }
+ } finally {
+ waitingExecutorLock.unlock() ;
+ }
+ return false ;
+ }
+
+ private void activateDispatcher() {
+ waitingExecutorLock.lock() ;
+ try {
+ if (!dispatcherActive) {
+ unlockOurJobs() ;
+ dispatcherActive = true ;
+ }
+ } finally {
+ waitingExecutorLock.unlock() ;
+ }
+ }
+
+ private void unlockOurJobs() {
+ final JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
+ try {
+ final String lockOwner = getName();
+ final JobSession jobSession = jbpmContext.getJobSession();
+ jobSession.releaseLockedJobs(lockOwner);
+ } catch (RuntimeException e) {
+ jbpmContext.setRollbackOnly();
+ if (log.isDebugEnabled()) log.debug("failed to release locked jobs", e);
+ } catch (Error e) {
+ jbpmContext.setRollbackOnly();
+ throw e;
+ } finally {
+ try {
+ jbpmContext.close();
+ } catch (RuntimeException e) {
+ if (log.isDebugEnabled()) log.debug("failed to release locked jobs", e);
+ }
+ }
+ }
+
+ private void deactivateDispatcher() {
+ waitingExecutorLock.lock() ;
+ try {
+ dispatcherActive = false ;
+ waitingDispatcherCondition.signal() ;
+ waitingExecutorCondition.signalAll() ;
+ } finally {
+ waitingExecutorLock.unlock() ;
+ }
+ }
+
private static Log log = LogFactory.getLog(JobExecutor.class);
}
Modified: jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2011-05-13 15:04:52 UTC (rev 6919)
+++ jbpm3/branches/3.2.10.SP/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2011-05-13 15:09:03 UTC (rev 6920)
@@ -7,6 +7,7 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -23,6 +24,7 @@
private final JobExecutor jobExecutor;
private volatile boolean active = true;
+ private Random random = new Random() ;
public JobExecutorThread(String name, JobExecutor jobExecutor) {
super(jobExecutor.getThreadGroup(), name);
@@ -42,7 +44,7 @@
public void run() {
while (active) {
// take on next job
- Job job = acquireJob();
+ Job job = jobExecutor.getJob();
// if an exception occurs, acquireJob() returns null
if (job != null) {
try {
@@ -126,16 +128,6 @@
return jobs;
}
- private Job acquireJob() {
- try {
- return (Job) jobExecutor.getQueue().take();
- }
- catch (InterruptedException e) {
- if (log.isDebugEnabled()) log.debug(getName() + " got interrupted");
- return null;
- }
- }
-
protected void executeJob(Job job) throws Exception {
JbpmContext jbpmContext = jobExecutor.getJbpmConfiguration().createJbpmContext();
try {
@@ -192,10 +184,9 @@
// unlock job so it can be dispatched again
job.setLockOwner(null);
job.setLockTime(null);
- // notify job executor
- synchronized (jobExecutor) {
- jobExecutor.notify();
- }
+ int waitPeriod = jobExecutor.getRetryInterval() / 2;
+ waitPeriod += random.nextInt(waitPeriod) ;
+ job.setDueDate(new Date(System.currentTimeMillis() + waitPeriod)) ;
}
catch (RuntimeException e) {
jbpmContext.setRollbackOnly();
@@ -213,6 +204,10 @@
log.warn("failed to save exception for " + job, e);
}
}
+ // notify job executor
+ synchronized (jobExecutor) {
+ jobExecutor.notify();
+ }
}
private void unlockJob(Job job) {
@@ -224,10 +219,6 @@
// unlock job
job.setLockOwner(null);
job.setLockTime(null);
- // notify job executor
- synchronized (jobExecutor) {
- jobExecutor.notify();
- }
}
catch (RuntimeException e) {
jbpmContext.setRollbackOnly();
@@ -246,6 +237,10 @@
log.warn("failed to unlock " + job, e);
}
}
+ // notify job executor
+ synchronized (jobExecutor) {
+ jobExecutor.notify();
+ }
}
/** @deprecated responsibility moved to DispatcherThread */
Modified: jbpm3/branches/3.2.10.SP/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
===================================================================
--- jbpm3/branches/3.2.10.SP/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2011-05-13 15:04:52 UTC (rev 6919)
+++ jbpm3/branches/3.2.10.SP/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2011-05-13 15:09:03 UTC (rev 6920)
@@ -401,6 +401,16 @@
]]>
</query>
+ <query name="JobSession.releaseLockedJobs">
+ <![CDATA[
+ update org.jbpm.job.Job job
+ set job.lockOwner = null, job.lockTime = null
+ where (job.lockOwner = :lockOwner)
+ and job.retries > 0
+ and job.isSuspended = false
+ ]]>
+ </query>
+
<!-- related to Tasks -->
<!-- ########################### -->
13 years