incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r948363 - in /sling/trunk/bundles/extensions/event/src: main/java/org/apache/sling/event/JobStatusProvider.java main/java/org/apache/sling/event/impl/JobEventHandler.java test/java/org/apache/sling/event/impl/JobEventHandlerTest.java
Date Wed, 26 May 2010 08:04:57 GMT
Author: cziegeler
Date: Wed May 26 08:04:57 2010
New Revision: 948363

URL: http://svn.apache.org/viewvc?rev=948363&view=rev
Log:
SLING-1467 :  Cancelling a job does not work

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

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java?rev=948363&r1=948362&r2=948363&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/JobStatusProvider.java
Wed May 26 08:04:57 2010
@@ -85,10 +85,31 @@ public interface JobStatusProvider {
      * Cancel this job.
      * Cancelling a job might fail if the job is currently in processing.
      * @param jobId The unique identifer as found in the property {@link #PROPERTY_EVENT_ID}.
+     * @deprecated Use {@link #removeJob(String)} instead.
+     */
+    @Deprecated
+    void cancelJob(String jobId);
+
+    /**
+     * Cancel this job.
+     * Cancelling a job might fail if the job is currently in processing.
+     * This method can be used if the topic and the provided job id is known.
+     * @param topic The job topic as put into the property {@link EventUtil#PROPERTY_JOB_TOPIC}.
+     * @param jobId The unique identifer as put into the property {@link EventUtil#PROPERTY_JOB_ID}.
+     * @deprecated Use {@link #removeJob(String, String)} instead.
+     */
+    @Deprecated
+    void cancelJob(String topic, String jobId);
+
+    /**
+     * Cancel this job.
+     * Cancelling a job might fail if the job is currently in processing.
+     * @param jobId The unique identifer as found in the property {@link #PROPERTY_EVENT_ID}.
      * @return <code>true</code> if the job could be cancelled or does not exist
anymore.
      *         <code>false</code> otherwise.
+     * @since 2.4.0
      */
-    boolean cancelJob(String jobId);
+    boolean removeJob(String jobId);
 
     /**
      * Cancel this job.
@@ -98,8 +119,9 @@ public interface JobStatusProvider {
      * @param jobId The unique identifer as put into the property {@link EventUtil#PROPERTY_JOB_ID}.
      * @return <code>true</code> if the job could be cancelled or does not exist
anymore.
      *         <code>false</code> otherwise.
+     * @since 2.4.0
      */
-    boolean cancelJob(String topic, String jobId);
+    boolean removeJob(String topic, String jobId);
 
     /**
      * Wake up the named job queue.

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=948363&r1=948362&r2=948363&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
Wed May 26 08:04:57 2010
@@ -1628,11 +1628,25 @@ public class JobEventHandler
     /**
      * @see org.apache.sling.event.JobStatusProvider#cancelJob(java.lang.String, java.lang.String)
      */
-    public boolean cancelJob(String topic, String jobId) {
+    public void cancelJob(String topic, String jobId) {
+        this.removeJob(topic, jobId);
+    }
+
+    /**
+     * @see org.apache.sling.event.JobStatusProvider#cancelJob(java.lang.String)
+     */
+    public void cancelJob(String jobId) {
+        this.removeJob(jobId);
+    }
+
+    /**
+     * @see org.apache.sling.event.JobStatusProvider#removeJob(java.lang.String, java.lang.String)
+     */
+    public boolean removeJob(String topic, String jobId) {
         if ( jobId != null && topic != null ) {
             try {
                 final String uniqueJobId = this.getWriterRootNode().getPath() + '/' + JobUtil.getUniquePath(topic,
jobId);
-                return this.cancelJob(uniqueJobId);
+                return this.removeJob(uniqueJobId);
             } catch (RepositoryException e) {
                 // this only happens if getPath() throws which really should not happen
                 this.ignoreException(e);
@@ -1642,9 +1656,9 @@ public class JobEventHandler
     }
 
     /**
-     * @see org.apache.sling.event.JobStatusProvider#cancelJob(java.lang.String)
+     * @see org.apache.sling.event.JobStatusProvider#removeJob(java.lang.String)
      */
-    public boolean cancelJob(String jobId) {
+    public boolean removeJob(String jobId) {
         if ( jobId != null ) {
             synchronized ( this.backgroundLock ) {
                 try {

Modified: sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/JobEventHandlerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/JobEventHandlerTest.java?rev=948363&r1=948362&r2=948363&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/JobEventHandlerTest.java
(original)
+++ sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/JobEventHandlerTest.java
Wed May 26 08:04:57 2010
@@ -176,14 +176,14 @@ public class JobEventHandlerTest extends
         assertEquals(1, jeh.getAllJobs("sling/test").size());
         cb.block();
         // job is currently sleeping, therefore cancel fails
-        assertFalse(jeh.cancelJob("sling/test", "myid"));
+        assertFalse(jeh.removeJob("sling/test", "myid"));
         try {
             Thread.sleep(800);
         } catch (InterruptedException e) {
             // ignore
         }
         // the job is now in the queue again
-        assertTrue(jeh.cancelJob("sling/test", "myid"));
+        assertTrue(jeh.removeJob("sling/test", "myid"));
         assertEquals(0, jeh.getAllJobs("sling/test").size());
     }
 



Mime
View raw message