incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r907725 - /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
Date Mon, 08 Feb 2010 17:00:00 GMT
Author: cziegeler
Date: Mon Feb  8 17:00:00 2010
New Revision: 907725

URL: http://svn.apache.org/viewvc?rev=907725&view=rev
Log:
SLING-1358 : Number of parallel threads is wrongly calculated

Modified:
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=907725&r1=907724&r2=907725&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
Mon Feb  8 17:00:00 2010
@@ -170,7 +170,7 @@
     private final Object backgroundLock = new Object();
 
     /** Number of parallel jobs for the main queue. */
-    private long parallelJobCount;
+    private volatile long parallelJobCount;
 
     /** Number of jobs to load from the repository on startup in one go. */
     private long maxLoadJobs;
@@ -749,14 +749,12 @@
                                 process = true;
                             }
                         }
-
-                    } else {
-                        // check number of parallel jobs for main queue
-                        if ( jobQueue == null && this.parallelJobCount >= this.maximumParallelJobs
) {
-                            logger.debug("Rescheduling job {} - maximum parallel job count
of {} reached!", info.event, this.maximumParallelJobs);
-                            process = false;
-                            wait = true;
-                        }
+                    }
+                    // check number of parallel jobs for main queue
+                    if ( process && jobQueue == null && this.parallelJobCount
>= this.maximumParallelJobs ) {
+                        logger.debug("Rescheduling job {} - maximum parallel job count of
{} reached!", info.event, this.maximumParallelJobs);
+                        process = false;
+                        wait = true;
                     }
                     if ( process ) {
                         boolean unlock = true;
@@ -999,7 +997,7 @@
         logger.debug("Starting job {}", event);
         boolean unlock = true;
         try {
-            if ( isMainQueue && parallelProcessing ) {
+            if ( isMainQueue ) {
                 this.parallelJobCount++;
             }
             final String nodePath = eventNode.getPath();
@@ -1028,7 +1026,7 @@
             this.logger.error("Exception during job processing.", re);
         } finally {
             if ( unlock ) {
-                if ( isMainQueue && parallelProcessing ) {
+                if ( isMainQueue ) {
                     this.parallelJobCount--;
                 }
                 if ( !parallelProcessing ) {
@@ -1350,11 +1348,11 @@
                         synchronized ( this.processingMap ) {
                             this.processingMap.put(jobTopic, Boolean.FALSE);
                         }
-                    } else {
-                        if ( job.getProperty(EventUtil.PROPERTY_JOB_QUEUE_NAME) == null )
{
-                            this.parallelJobCount--;
-                        }
                     }
+                    if ( job.getProperty(EventUtil.PROPERTY_JOB_QUEUE_NAME) == null ) {
+                        this.parallelJobCount--;
+                    }
+
                     if ( unlock ) {
                         synchronized ( this.deletedJobs ) {
                             this.deletedJobs.add(eventNodePath);



Mime
View raw message