incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1141656 - in /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs: DefaultJobManager.java jcr/PersistenceHandler.java
Date Thu, 30 Jun 2011 18:35:00 GMT
Author: cziegeler
Date: Thu Jun 30 18:35:00 2011
New Revision: 1141656

URL: http://svn.apache.org/viewvc?rev=1141656&view=rev
Log:
SLING-2119 : Add a periodic sanity check to the internal job cache

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/jcr/PersistenceHandler.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=1141656&r1=1141655&r2=1141656&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
Thu Jun 30 18:35:00 2011
@@ -254,8 +254,6 @@ public class DefaultJobManager
         final boolean doSanityCheck = (schedulerRuns % 12 == 0);
         if ( doSanityCheck ) {
             logger.debug("cleanup: running sanity check");
-            final List<JobEvent> removedEvents = new ArrayList<JobEvent>();
-
             final Map<String, JobEvent> currentEvents;
             synchronized (this.allEvents) {
                 currentEvents = new HashMap<String, JobEvent>(this.allEvents);
@@ -268,19 +266,15 @@ public class DefaultJobManager
                         logger.debug("cleanup: Removing dead job {}", job);
                         this.allEvents.remove(entry.getKey());
                     }
-                    removedEvents.add(job);
-                }
-            }
-
-            for(final JobEvent removedJob : removedEvents) {
-                final String topic = (String)removedJob.event.getProperty(JobUtil.PROPERTY_JOB_TOPIC);
-                final List<JobEvent> l;
-                synchronized ( this.allEventsByTopic ) {
-                    l = this.allEventsByTopic.get(topic);
-                }
-                if ( l != null ) {
-                    synchronized ( l ) {
-                        l.remove(removedJob);
+                    final String topic = (String)job.event.getProperty(JobUtil.PROPERTY_JOB_TOPIC);
+                    final List<JobEvent> l;
+                    synchronized ( this.allEventsByTopic ) {
+                        l = this.allEventsByTopic.get(topic);
+                    }
+                    if ( l != null ) {
+                        synchronized ( l ) {
+                            l.remove(job);
+                        }
                     }
                 }
             }

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/jcr/PersistenceHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/jcr/PersistenceHandler.java?rev=1141656&r1=1141655&r2=1141656&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/jcr/PersistenceHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/jcr/PersistenceHandler.java
Thu Jun 30 18:35:00 2011
@@ -1337,17 +1337,21 @@ public class PersistenceHandler implemen
      */
     public boolean isAlive(final JCRJobEvent info) {
         final String path = this.getNodePath(info.uniqueId);
-        synchronized ( this.backgroundLock ) {
-            try {
-                if ( this.backgroundSession.itemExists(path) ) {
-                    final String finishedPath = path + '/' + JCRHelper.NODE_PROPERTY_FINISHED;
-                    if ( !this.backgroundSession.itemExists(finishedPath) ) {
-                        return true;
-                    }
+        Session s = null;
+        try {
+            s = this.environment.createAdminSession();
+            if ( s.itemExists(path) ) {
+                final String finishedPath = path + '/' + JCRHelper.NODE_PROPERTY_FINISHED;
+                if ( !s.itemExists(finishedPath) ) {
+                    return true;
                 }
-            } catch (final RepositoryException re) {
-                // there is nothing we can do
-                this.ignoreException(re);
+            }
+        } catch (final RepositoryException re) {
+            // there is nothing we can do
+            this.ignoreException(re);
+        } finally {
+            if ( s != null ) {
+                s.logout();
             }
         }
         return false;



Mime
View raw message