incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1488653 - in /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs: JobManagerImpl.java queues/AbstractJobQueue.java queues/AbstractParallelJobQueue.java
Date Sun, 02 Jun 2013 09:24:07 GMT
Author: cziegeler
Date: Sun Jun  2 09:24:06 2013
New Revision: 1488653

URL: http://svn.apache.org/r1488653
Log:
SLING-2896 :  Job might be executed twice if a topology event occurs 

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

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java?rev=1488653&r1=1488652&r2=1488653&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
Sun Jun  2 09:24:06 2013
@@ -386,10 +386,7 @@ public class JobManagerImpl
             // update mbeans
             ((QueuesMBeanImpl)queuesMBean).sendEvent(new QueueStatusEvent(null, queue));
         } else {
-            if ( !queue.getName().contains("<outdated>") ) {
-                // notify queue
-                queue.rename(queue.getName() + "<outdated>(" + queue.hashCode() + ")");
-            }
+            queue.outdate();
             // readd with new name
             this.queues.put(queue.getName(), queue);
             // update mbeans

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=1488653&r1=1488652&r2=1488653&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
Sun Jun  2 09:24:06 2013
@@ -103,6 +103,9 @@ public abstract class AbstractJobQueue
     /** Async counter. */
     private final AtomicInteger asyncCounter = new AtomicInteger();
 
+    /** Flag for outdated. */
+    private final AtomicBoolean isOutdated = new AtomicBoolean(false);
+
     /**
      * Start this queue
      * @param name The queue name
@@ -655,11 +658,22 @@ public abstract class AbstractJobQueue
     }
 
     /**
-     * Rename this queue.
+     * Is the queue outdated?
      */
-    public void rename(final String name) {
-        this.logger.info("Queue reconfiguration: old queue {} is renamed to {}.", this.queueName,
name);
-        this.queueName = name;
+    protected boolean isOutdated() {
+        return this.isOutdated.get();
+    }
+
+    /**
+     * Outdate this queue.
+     */
+    public void outdate() {
+        if ( !this.isOutdated() ) {
+            this.isOutdated.set(true);
+            final String name = this.getName() + "<outdated>(" + this.hashCode() +
")";
+            this.logger.info("Outdating queue {}, renaming to {}.", this.queueName, name);
+            this.queueName = name;
+        }
     }
 
     /**

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=1488653&r1=1488652&r2=1488653&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
Sun Jun  2 09:24:06 2013
@@ -58,6 +58,11 @@ public abstract class AbstractParallelJo
         // acquire a slot
         this.acquireSlot();
 
+        // check if we got outdated in the meantime
+        if ( this.isOutdated() ) {
+            this.freeSlot();
+            return null;
+        }
         if ( !this.executeJob(processInfo) ) {
             this.freeSlot();
         }



Mime
View raw message