[jbpm-commits] JBoss JBPM SVN: r6073 - in jbpm3/branches/jbpm-3.2-soa/modules/core/src/main: resources/org/jbpm and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 12 22:46:41 EST 2010


Author: alex.guizar at jboss.com
Date: 2010-01-12 22:46:40 -0500 (Tue, 12 Jan 2010)
New Revision: 6073

Modified:
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
Log:
JBPM-2691: make number of job retries configurable

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java	2010-01-12 16:33:43 UTC (rev 6072)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java	2010-01-13 03:46:40 UTC (rev 6073)
@@ -25,6 +25,7 @@
   protected JbpmConfiguration jbpmConfiguration;
   protected String name;
   protected int nbrOfThreads;
+  private   int retries = 1;
   protected int idleInterval;
   protected int maxIdleInterval;
   /** @deprecated this field was never used */
@@ -44,31 +45,33 @@
 
   public synchronized void start() {
     if (!isStarted) {
-      log.debug("starting thread group '" + name + "'...");
+      log.debug("starting job executor '" + name + '\'');
       for (int i = 0; i < nbrOfThreads; i++) {
         startThread();
       }
-      lockMonitorThread = new LockMonitorThread(getLockMonitorThreadName(), this);
+      lockMonitorThread =
+          new LockMonitorThread(getLockMonitorThreadName(), this);
       lockMonitorThread.start();
       isStarted = true;
     }
     else {
-      log.debug("ignoring start: thread group '" + name + "' is already started'");
+      log.debug("ignoring start: job executor '" + name + "' already started'");
     }
   }
 
   /**
-   * signals to all threads in this job executor to stop. Threads may be in the middle of processing
-   * a job and they will finish that first. Use {@link #stopAndJoin()} in case you want a method
-   * that blocks until all the threads are actually finished.
+   * signals to all threads in this job executor to stop. Threads may be in the
+   * middle of processing a job and they will finish that first. Use
+   * {@link #stopAndJoin()} in case you want a method that blocks until all the
+   * threads are actually finished.
    * 
-   * @return a list of the stopped threads. In case no threads were stopped an empty list will be
-   * returned.
+   * @return a list of the stopped threads. In case no threads were stopped an
+   * empty list will be returned.
    */
   public synchronized List stop() {
     List stoppedThreads;
     if (isStarted) {
-      log.debug("stopping thread group '" + name + "'...");
+      log.debug("stopping job executor '" + name + '\'');
       isStarted = false;
 
       stoppedThreads = new ArrayList(threads.size());
@@ -79,7 +82,7 @@
       if (lockMonitorThread != null) lockMonitorThread.deactivate();
     }
     else {
-      log.debug("ignoring stop: thread group '" + name + "' not started");
+      log.debug("ignoring stop: job executor '" + name + "' not started");
       stoppedThreads = Collections.EMPTY_LIST;
     }
     return stoppedThreads;
@@ -93,25 +96,21 @@
 
     if (lockMonitorThread != null) lockMonitorThread.join();
   }
-  
+
   public void ensureThreadsAreActive() {
-    List deadThreads = new ArrayList(); 
+    List deadThreads = new ArrayList();
     for (Iterator i = threads.values().iterator(); i.hasNext();) {
       Thread thread = (Thread) i.next();
-      if (!thread.isAlive()) {      
-        if(log.isDebugEnabled())
-        {
-    	  log.debug("detected dead thread '" + thread.getName() + "'");
-        }
+      if (!thread.isAlive()) {
         deadThreads.add(thread.getName());
         i.remove();
       }
     }
-    for (int i = 0; i<deadThreads.size(); i++) {
-        startThread((String)deadThreads.get(i));
+    for (int i = 0; i < deadThreads.size(); i++) {
+      startThread((String) deadThreads.get(i));
     }
   }
-  
+
   protected void startThread() {
     startThread(getNextThreadName());
   }
@@ -120,7 +119,7 @@
     Thread thread = createThread(threadName);
     threads.put(threadName, thread);
 
-    log.debug("starting new job executor thread '" + threadName + "'");
+    log.debug("starting new job executor thread '" + threadName + '\'');
     thread.start();
   }
 
@@ -139,9 +138,9 @@
   private String getThreadName(int index) {
     return name + ":" + getHostAddress() + ":" + index;
   }
-  
+
   private String getLockMonitorThreadName() {
-    return name + ':' + LockMonitorThread.DEFAULT_NAME + '@' + getHostAddress();     
+    return name + ':' + LockMonitorThread.DEFAULT_NAME + '@' + getHostAddress();
   }
 
   private static String getHostAddress() {
@@ -158,7 +157,7 @@
 
   protected synchronized Thread stopThread() {
     String threadName = getLastThreadName();
-    log.debug("removing job executor thread '" + threadName + "'");
+    log.debug("removing job executor thread '" + threadName + '\'');
 
     Thread thread = (Thread) threads.remove(threadName);
     if (thread instanceof JobExecutorThread) {
@@ -303,5 +302,13 @@
     this.nbrOfThreads = nbrOfThreads;
   }
 
+  public int getRetries() {
+    return retries;
+  }
+
+  public void setRetries(int retries) {
+    this.retries = retries;
+  }
+
   private static Log log = LogFactory.getLog(JobExecutor.class);
 }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java	2010-01-12 16:33:43 UTC (rev 6072)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java	2010-01-13 03:46:40 UTC (rev 6073)
@@ -132,10 +132,13 @@
           }
 
           Date lockTime = new Date();
+          int retries = jobExecutor.getRetries();
           for (Iterator i = jobsToLock.iterator(); i.hasNext();) {
             job = (Job) i.next();
             job.setLockOwner(lockOwner);
             job.setLockTime(lockTime);
+            // if job has not failed already
+            if (job.getException() == null) job.setRetries(retries);
           }
         }
       }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2010-01-12 16:33:43 UTC (rev 6072)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2010-01-13 03:46:40 UTC (rev 6073)
@@ -63,14 +63,15 @@
   <bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />
   
   <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor">
-    <field name="jbpmConfiguration"><ref bean="jbpmConfiguration" /></field>
-    <field name="name"><string value="JbpmJobExecutor" /></field>
-    <field name="nbrOfThreads"><int value="1" /></field>
-    <field name="idleInterval"><int value="5000" /></field>
-    <field name="maxIdleInterval"><int value="3600000" /></field> <!-- 1 hour -->
-    <field name="maxLockTime"><int value="600000" /></field> <!-- 10 minutes -->
-    <field name="lockMonitorInterval"><int value="60000" /></field> <!-- 1 minute -->
-    <field name="lockBufferTime"><int value="5000" /></field> <!-- 5 seconds -->
+    <property name="jbpmConfiguration"><ref bean="jbpmConfiguration" /></property>
+    <property name="name"><string value="JbpmJobExecutor" /></property>
+    <property name="nbrOfThreads"><int value="1" /></property>
+    <property name="retries"><int value="2" /></property>
+    <property name="idleInterval"><int value="5000" /></property>
+    <property name="maxIdleInterval"><int value="3600000" /><!-- 1 hour --></property>
+    <property name="maxLockTime"><int value="600000" /><!-- 10 minutes --></property>
+    <property name="lockMonitorInterval"><int value="60000" /><!-- 1 minute --></property>
+    <property name="lockBufferTime"><int value="5000" /><!-- 5 seconds --></property>
   </bean>
 
 </jbpm-configuration>



More information about the jbpm-commits mailing list