incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1045248 - in /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs: DefaultJobManager.java queues/AbstractJobQueue.java
Date Mon, 13 Dec 2010 17:32:29 GMT
Author: cziegeler
Date: Mon Dec 13 17:32:29 2010
New Revision: 1045248

URL: http://svn.apache.org/viewvc?rev=1045248&view=rev
Log:
Shorten clean up interval for queues

Modified:
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java?rev=1045248&r1=1045247&r2=1045248&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
Mon Dec 13 17:32:29 2010
@@ -80,9 +80,7 @@ import org.slf4j.LoggerFactory;
     @Service(value=EventHandler.class)
 })
 @Properties({
-    @Property(name="scheduler.period", longValue=300,
-            label="%jobscheduler.period.name",
-            description="%jobscheduler.period.description"),
+    @Property(name="scheduler.period", longValue=60, propertyPrivate=true),
     @Property(name="scheduler.concurrent", boolValue=false, propertyPrivate=true),
     @Property(name=ConfigurationConstants.PROP_PRIORITY,
             value=ConfigurationConstants.DEFAULT_PRIORITY,
@@ -148,6 +146,9 @@ public class DefaultJobManager
 
     private boolean enabled = DEFAULT_ENABLED;
 
+    /** We count the scheduler runs. */
+    private long schedulerRuns;
+
     /**
      * Activate this component.
      * @param props Configuration properties
@@ -212,6 +213,10 @@ public class DefaultJobManager
      * @see java.lang.Runnable#run()
      */
     private void cleanup() {
+        this.schedulerRuns++;
+        // we only do a full clean up on every fifth run
+        final boolean doFullCleanUp = (schedulerRuns % 5 == 0);
+
         // check for idle queue
         // we synchronize to avoid creating a queue which is about to be removed during cleanup
         synchronized ( queuesLock ) {
@@ -220,17 +225,19 @@ public class DefaultJobManager
                 final Map.Entry<String, AbstractJobQueue> current = i.next();
                 // clean up
                 final AbstractJobQueue jbq = current.getValue();
-                jbq.cleanUp();
-                if ( jbq.isMarkedForRemoval() ) {
-                    // close
-                    jbq.close();
-                    // copy statistics
-                    this.baseStatistics.add(jbq);
-                    // remove
-                    i.remove();
-                } else {
-                    // mark to be removed during next cycle
-                    jbq.markForRemoval();
+                jbq.checkForUnprocessedJobs();
+                if ( doFullCleanUp ) {
+                    if ( jbq.isMarkedForRemoval() ) {
+                        // close
+                        jbq.close();
+                        // copy statistics
+                        this.baseStatistics.add(jbq);
+                        // remove
+                        i.remove();
+                    } else {
+                        // mark to be removed during next cycle
+                        jbq.markForRemoval();
+                    }
                 }
             }
         }

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java?rev=1045248&r1=1045247&r2=1045248&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java
Mon Dec 13 17:32:29 2010
@@ -178,9 +178,9 @@ public abstract class AbstractJobQueue
     }
 
     /**
-     * Periodically cleanup.
+     * Periodically check for started jobs without an ack.
      */
-    public void cleanUp() {
+    public void checkForUnprocessedJobs() {
         if ( this.running ) {
             // check for jobs that were started but never got an aknowledge
             final long tooOld = System.currentTimeMillis() - DEFAULT_WAIT_FOR_ACK_IN_MS;



Mime
View raw message