[jbpm-commits] JBoss JBPM SVN: r2968 - in jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src: main/java/org/jbpm/svc and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Nov 17 19:17:53 EST 2008
Author: alex.guizar at jboss.com
Date: 2008-11-17 19:17:53 -0500 (Mon, 17 Nov 2008)
New Revision: 2968
Modified:
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/main/java/org/jbpm/svc/Services.java
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/AllDbTests.java
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java
Log:
applied JBPM-1072 changes to soa branch
Modified: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-11-17 23:03:50 UTC (rev 2967)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-11-18 00:17:53 UTC (rev 2968)
@@ -4,6 +4,7 @@
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -11,7 +12,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Hibernate;
-import org.hibernate.StaleStateException;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.db.JobSession;
@@ -94,60 +94,69 @@
currentIdleInterval = currentIdleInterval*2;
}
}
- } catch (Throwable t) {
- t.printStackTrace();
+ } catch (Exception e) {
+ // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
+ e.printStackTrace();
} finally {
log.info(getName()+" leaves cyberspace");
}
}
protected Collection acquireJobs() {
- Collection acquiredJobs = null;
+ Collection acquiredJobs;
synchronized (jobExecutor) {
Collection jobsToLock = new ArrayList();
log.debug("acquiring jobs for execution...");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
- try {
- JobSession jobSession = jbpmContext.getJobSession();
- log.debug("querying for acquirable job...");
- Job job = jobSession.getFirstAcquirableJob(getName());
- if (job!=null) {
- if (job.isExclusive()) {
- log.debug("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
- List otherExclusiveJobs = jobSession.findExclusiveJobs(getName(), job.getProcessInstance());
- jobsToLock.addAll(otherExclusiveJobs);
- log.debug("trying to obtain a process-instance exclusive locks for '"+otherExclusiveJobs+"'");
- } else {
- log.debug("trying to obtain a lock for '"+job+"'");
- jobsToLock.add(job);
- }
-
- Iterator iter = jobsToLock.iterator();
- while (iter.hasNext()) {
- job = (Job) iter.next();
- job.setLockOwner(getName());
- job.setLockTime(new Date());
- // jbpmContext.getSession().update(job);
- }
-
- // HACKY HACK : this is a workaround for a hibernate problem that is fixed in hibernate 3.2.1
- if (job instanceof Timer) {
- Hibernate.initialize(((Timer)job).getGraphElement());
- }
-
+ JobSession jobSession = jbpmContext.getJobSession();
+ log.debug("querying for acquirable job...");
+ Job job = jobSession.getFirstAcquirableJob(getName());
+ if (job!=null) {
+ if (job.isExclusive()) {
+ log.debug("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
+ List otherExclusiveJobs = jobSession.findExclusiveJobs(getName(), job.getProcessInstance());
+ jobsToLock.addAll(otherExclusiveJobs);
+ log.debug("trying to obtain a process-instance exclusive locks for '"+otherExclusiveJobs+"'");
} else {
- log.debug("no acquirable jobs in job table");
+ log.debug("trying to obtain a lock for '"+job+"'");
+ jobsToLock.add(job);
}
- } finally {
+ Iterator iter = jobsToLock.iterator();
+ while (iter.hasNext()) {
+ job = (Job) iter.next();
+ job.setLockOwner(getName());
+ job.setLockTime(new Date());
+ // jbpmContext.getSession().update(job);
+ }
+
+ // HACKY HACK : this is a workaround for a hibernate problem that is fixed in hibernate 3.2.1
+ if (job instanceof Timer) {
+ Hibernate.initialize(((Timer)job).getGraphElement());
+ }
+ } else {
+ log.debug("no acquirable jobs in job table");
+ }
+ } finally {
+ try {
jbpmContext.close();
+ acquiredJobs = jobsToLock;
+ log.debug("obtained lock on jobs: "+acquiredJobs);
}
- acquiredJobs = jobsToLock;
- log.debug("obtained locks on following jobs: "+acquiredJobs);
-
- } catch (StaleStateException e) {
- log.debug("couldn't acquire lock on job(s): "+jobsToLock);
+ catch (JbpmPersistenceException e) {
+ // if this is a stale object exception, the jbpm configuration has control over the logging
+ if ("org.hibernate.StaleObjectStateException".equals(e.getCause().getClass().getName())) {
+ log.info("problem committing job acquisition transaction: optimistic locking failed");
+ StaleObjectLogConfigurer.staleObjectExceptionsLog.error("problem committing job acquisition transaction: optimistic locking failed", e);
+ } else {
+ // TODO run() will log this exception, log it here too?
+ log.error("problem committing job acquisition transaction", e);
+ throw e;
+ }
+ acquiredJobs = Collections.EMPTY_LIST;
+ log.debug("couldn't obtain lock on jobs: "+jobsToLock);
+ }
}
}
return acquiredJobs;
@@ -188,12 +197,10 @@
log.info("problem committing job execution transaction: optimistic locking failed");
StaleObjectLogConfigurer.staleObjectExceptionsLog.error("problem committing job execution transaction: optimistic locking failed", e);
} else {
+ // TODO run() will log this exception, log it here too?
log.error("problem committing job execution transaction", e);
+ throw e;
}
- } catch (RuntimeException e) {
- log.error("problem committing job execution transaction", e);
-
- throw e;
}
}
}
Modified: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/main/java/org/jbpm/svc/Services.java
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/main/java/org/jbpm/svc/Services.java 2008-11-17 23:03:50 UTC (rev 2967)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/main/java/org/jbpm/svc/Services.java 2008-11-18 00:17:53 UTC (rev 2968)
@@ -30,7 +30,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.StaleObjectStateException;
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.graph.exe.ProcessInstance;
@@ -214,7 +213,7 @@
public void close() {
if (services!=null) {
Map closeExceptions = new HashMap();
- Throwable firstException = null;
+ Exception firstException = null;
Iterator iter = serviceNames.iterator();
while (iter.hasNext()) {
String serviceName = (String) iter.next();
@@ -231,6 +230,10 @@
} else {
log.error("problem closing service '"+serviceName+"'", e);
}
+ closeExceptions.put(serviceName, e);
+ if (firstException==null) {
+ firstException = e;
+ }
} catch (Exception e) {
// NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
log.error("problem closing service '"+serviceName+"'", e);
@@ -241,8 +244,12 @@
}
}
}
- if (! closeExceptions.isEmpty()) {
- throw new JbpmException("problem closing services "+closeExceptions, firstException);
+ if (!closeExceptions.isEmpty()) {
+ if (firstException instanceof JbpmException) {
+ throw (JbpmException) firstException;
+ } else {
+ throw new JbpmException("problem closing services: "+closeExceptions, firstException);
+ }
}
}
}
Modified: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/AllDbTests.java
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/AllDbTests.java 2008-11-17 23:03:50 UTC (rev 2967)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/AllDbTests.java 2008-11-18 00:17:53 UTC (rev 2968)
@@ -37,6 +37,7 @@
import org.jbpm.graph.log.GraphLogDbTests;
import org.jbpm.graph.node.GraphNodeDbTests;
import org.jbpm.jcr.JcrDbTests;
+import org.jbpm.job.executor.JobExecutorTests;
import org.jbpm.jpdl.el.JpdlElDbTests;
import org.jbpm.jpdl.exe.JpdlExeDbTests;
import org.jbpm.jpdl.par.JpdlParDbTests;
@@ -75,6 +76,7 @@
suite.addTest(PersistenceDbTests.suite());
suite.addTest(ScenarioDbTests.suite());
suite.addTest(SchedulerExeDbTests.suite());
+ suite.addTest(JobExecutorTests.suite());
suite.addTest(TaskMgmtDefDbTests.suite());
suite.addTest(TaskMgmtExeDbTests.suite());
suite.addTest(TaskMgmtLogDbTests.suite());
Modified: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java 2008-11-17 23:03:50 UTC (rev 2967)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java 2008-11-18 00:17:53 UTC (rev 2968)
@@ -26,8 +26,6 @@
import java.util.List;
import java.util.Set;
-import junit.framework.AssertionFailedError;
-
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.Node;
@@ -82,7 +80,7 @@
assertEquals(processDefinition.getNode("one"), processInstance.getRootToken().getNode());
assertEquals(1, getNbrOfJobsAvailable());
- processJobs(5000);
+ processJobs(30000);
assertEquals(0, getNbrOfJobsAvailable());
More information about the jbpm-commits
mailing list