incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r673376 - in /incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl: QuartzJobExecutor.java QuartzScheduler.java
Date Wed, 02 Jul 2008 12:28:28 GMT
Author: cziegeler
Date: Wed Jul  2 05:28:27 2008
New Revision: 673376

URL: http://svn.apache.org/viewvc?rev=673376&view=rev
Log:
SLING-561 - use the same object for detecting if a job is run in parallel.

Modified:
    incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
    incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java

Modified: incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java?rev=673376&r1=673375&r2=673376&view=diff
==============================================================================
--- incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
(original)
+++ incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzJobExecutor.java
Wed Jul  2 05:28:27 2008
@@ -40,18 +40,17 @@
 
         final JobDataMap data = context.getJobDetail().getJobDataMap();
 
-        final Boolean canRunConcurrentlyB = ((Boolean) data.get(QuartzScheduler.DATA_MAP_RUN_CONCURRENT));
-        final boolean canRunConcurrently = ((canRunConcurrentlyB == null) ? true : canRunConcurrentlyB.booleanValue());
+        final QuartzScheduler.ConcurrentHandler concurrentHandler
+             = (QuartzScheduler.ConcurrentHandler)data.get(QuartzScheduler.DATA_MAP_CONCURRENT_HANDLER);
+        final boolean canRunConcurrently = (concurrentHandler == null ? true : concurrentHandler.runConcurrently);
 
         if (!canRunConcurrently) {
-            Boolean isRunning = (Boolean) data.get(QuartzScheduler.DATA_MAP_KEY_ISRUNNING);
-            if (Boolean.TRUE.equals(isRunning)) {
+            if ( concurrentHandler.isRunning ) {
                 return;
             }
+            concurrentHandler.isRunning = true;
         }
 
-        this.setup(data);
-
         final Object job = data.get(QuartzScheduler.DATA_MAP_OBJECT);
         final Logger logger = (Logger)data.get(QuartzScheduler.DATA_MAP_LOGGER);
 
@@ -77,19 +76,12 @@
             // there is nothing we can do here, so we just log
             logger.error("Exception during job execution of " + job + " : " + t.getMessage(),
t);
         } finally {
-
-            this.release(data);
+            if (!canRunConcurrently) {
+                concurrentHandler.isRunning = false;
+            }
         }
     }
 
-    protected void setup(JobDataMap data) throws JobExecutionException {
-        data.put(QuartzScheduler.DATA_MAP_KEY_ISRUNNING, Boolean.TRUE);
-    }
-
-    protected void release(JobDataMap data) {
-        data.put(QuartzScheduler.DATA_MAP_KEY_ISRUNNING, Boolean.FALSE);
-    }
-
     public static final class JobContextImpl implements JobContext {
 
         protected final Map<String, Serializable> configuration;

Modified: incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java?rev=673376&r1=673375&r2=673376&view=diff
==============================================================================
--- incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java
(original)
+++ incubator/sling/trunk/commons/scheduler/src/main/java/org/apache/sling/commons/scheduler/impl/QuartzScheduler.java
Wed Jul  2 05:28:27 2008
@@ -68,18 +68,15 @@
     /** Map key for the job name */
     static final String DATA_MAP_NAME = "QuartzJobScheduler.JobName";
 
-    /** Map key for the concurrent run property */
-    static final String DATA_MAP_RUN_CONCURRENT = "QuartzJobScheduler.RunConcurrently";
-
-    /** Map key for the run status */
-    static final String DATA_MAP_KEY_ISRUNNING = "QuartzJobExecutor.isRunning";
-
     /** Map key for the configuration. */
     static final String DATA_MAP_CONFIGURATION = "QuartzJobScheduler.Configuration";
 
     /** Map key for the logger. */
     static final String DATA_MAP_LOGGER = "QuartzJobScheduler.Logger";
 
+    /** Map key for the concurrent handler */
+    static final String DATA_MAP_CONCURRENT_HANDLER = "QuartzJobExecutor.ConcurrentHandler";
+
     protected org.quartz.Scheduler scheduler;
 
     protected final List<Object[]> registeredJobs = new ArrayList<Object[]>();
@@ -215,7 +212,9 @@
         jobDataMap.put(DATA_MAP_OBJECT, job);
 
         jobDataMap.put(DATA_MAP_NAME, jobName);
-        jobDataMap.put(DATA_MAP_RUN_CONCURRENT, (concurent? Boolean.TRUE: Boolean.FALSE));
+        final ConcurrentHandler handler = new ConcurrentHandler();
+        handler.runConcurrently = concurent;
+        jobDataMap.put(DATA_MAP_CONCURRENT_HANDLER, handler);
         jobDataMap.put(DATA_MAP_LOGGER, this.logger);
         if ( config != null ) {
             jobDataMap.put(DATA_MAP_CONFIGURATION, config);
@@ -465,4 +464,10 @@
         }
     }
 
+    protected static final class ConcurrentHandler {
+
+        public boolean runConcurrently;
+
+        public boolean isRunning = false;
+    }
 }



Mime
View raw message