You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/04/22 18:04:50 UTC

svn commit: r1470600 - in /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event: impl/jobs/deprecated/ impl/jobs/queues/ jobs/

Author: cziegeler
Date: Mon Apr 22 16:04:49 2013
New Revision: 1470600

URL: http://svn.apache.org/r1470600
Log:
Handle retry delay

Modified:
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/deprecated/EventAdminBridge.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/Job.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobUtil.java

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/deprecated/EventAdminBridge.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/deprecated/EventAdminBridge.java?rev=1470600&r1=1470599&r2=1470600&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/deprecated/EventAdminBridge.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/deprecated/EventAdminBridge.java Mon Apr 22 16:04:49 2013
@@ -128,7 +128,6 @@ public class EventAdminBridge
         JobUtil.PROPERTY_JOB_PARALLEL,
         JobUtil.PROPERTY_JOB_RUN_LOCAL,
         JobUtil.PROPERTY_JOB_RETRIES,
-        JobUtil.PROPERTY_JOB_RETRY_DELAY,
         JobUtil.PROPERTY_JOB_QUEUE_NAME,
         JobUtil.PROPERTY_JOB_QUEUE_ORDERED,
         JobUtil.PROPERTY_JOB_PRIORITY

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java?rev=1470600&r1=1470599&r2=1470600&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractParallelJobQueue.java Mon Apr 22 16:04:49 2013
@@ -24,6 +24,7 @@ import org.apache.sling.commons.schedule
 import org.apache.sling.event.impl.jobs.JobConsumerManager;
 import org.apache.sling.event.impl.jobs.JobHandler;
 import org.apache.sling.event.impl.jobs.config.InternalQueueConfiguration;
+import org.apache.sling.event.jobs.JobUtil;
 import org.osgi.service.event.EventAdmin;
 
 /**
@@ -117,7 +118,10 @@ public abstract class AbstractParallelJo
     protected JobHandler reschedule(final JobHandler info) {
         // we just sleep for the delay time - if none, we continue and retry
         // this job again
-        final long delay = this.configuration.getRetryDelayInMs();
+        long delay = this.configuration.getRetryDelayInMs();
+        if ( info.getJob().getProperty(JobUtil.PROPERTY_JOB_RETRY_DELAY) != null ) {
+            delay = info.getJob().getProperty(JobUtil.PROPERTY_JOB_RETRY_DELAY, Long.class);
+        }
         if ( delay > 0 ) {
             final Date fireDate = new Date();
             fireDate.setTime(System.currentTimeMillis() + delay);

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java?rev=1470600&r1=1470599&r2=1470600&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java Mon Apr 22 16:04:49 2013
@@ -27,6 +27,7 @@ import java.util.concurrent.LinkedBlocki
 import org.apache.sling.event.impl.jobs.JobConsumerManager;
 import org.apache.sling.event.impl.jobs.JobHandler;
 import org.apache.sling.event.impl.jobs.config.InternalQueueConfiguration;
+import org.apache.sling.event.jobs.JobUtil;
 import org.osgi.service.event.EventAdmin;
 
 /**
@@ -141,7 +142,10 @@ public final class OrderedJobQueue exten
     protected JobHandler reschedule(final JobHandler info) {
         // we just sleep for the delay time - if none, we continue and retry
         // this job again
-        final long delay = this.configuration.getRetryDelayInMs();
+        long delay = this.configuration.getRetryDelayInMs();
+        if ( info.getJob().getProperty(JobUtil.PROPERTY_JOB_RETRY_DELAY) != null ) {
+            delay = info.getJob().getProperty(JobUtil.PROPERTY_JOB_RETRY_DELAY, Long.class);
+        }
         if ( delay > 0 ) {
             synchronized ( this.sleepLock ) {
                 this.sleepLock.sleepingSince = System.currentTimeMillis();

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/Job.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/Job.java?rev=1470600&r1=1470599&r2=1470600&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/Job.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/Job.java Mon Apr 22 16:04:49 2013
@@ -103,6 +103,14 @@ public interface Job {
     String PROPERTY_JOB_STARTED_TIME = "event.job.started.time";
 
     /**
+     * The property to set a retry delay. Value is of type Long and specifies milliseconds.
+     * This property can be used to override the retry delay from the queue configuration.
+     * But it should only be used very rarely as the queue configuration should be the one
+     * in charge.
+     */
+    String PROPERTY_JOB_RETRY_DELAY = "event.job.retrydelay";
+
+    /**
      * The job topic.
      * @return The job topic
      */

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobUtil.java?rev=1470600&r1=1470599&r2=1470600&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobUtil.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobUtil.java Mon Apr 22 16:04:49 2013
@@ -87,8 +87,8 @@ public abstract class JobUtil {
     public static final String PROPERTY_JOB_RETRIES = "event.job.retries";
 
     /**
-     * This property is not supported anymore
-     * @deprecated
+     * The property to set a retry delay. Value is of type Long and specifies milliseconds.
+     * @deprecated - Use the new {@link Job} interface instead.
      */
     @Deprecated
     public static final String PROPERTY_JOB_RETRY_DELAY = "event.job.retrydelay";