Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 95674 invoked from network); 4 Dec 2008 15:48:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Dec 2008 15:48:21 -0000 Received: (qmail 75310 invoked by uid 500); 4 Dec 2008 15:48:33 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 75295 invoked by uid 500); 4 Dec 2008 15:48:33 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 75286 invoked by uid 99); 4 Dec 2008 15:48:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Dec 2008 07:48:33 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Dec 2008 15:47:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2F9AC2388886; Thu, 4 Dec 2008 07:48:01 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r723362 - in /incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl: JobEventHandler.java TimedJobHandler.java Date: Thu, 04 Dec 2008 15:48:00 -0000 To: sling-commits@incubator.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081204154801.2F9AC2388886@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Thu Dec 4 07:48:00 2008 New Revision: 723362 URL: http://svn.apache.org/viewvc?rev=723362&view=rev Log: SLING-759 Avoid synching on jcr sessions. Use extra lock objects for this. Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=723362&r1=723361&r2=723362&view=diff ============================================================================== --- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java (original) +++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java Thu Dec 4 07:48:00 2008 @@ -140,6 +140,12 @@ public static ThreadPool JOB_THREAD_POOL; + /** Sync lock */ + private final Object writeLock = new Object(); + + /** Sync lock */ + private final Object backgroundLock = new Object(); + /** * Activate this component. * @param context @@ -546,7 +552,7 @@ */ private boolean executeJob(final EventInfo info, final BlockingQueue jobQueue) { boolean putback = false; - synchronized (this.backgroundSession) { + synchronized (this.backgroundLock) { try { this.backgroundSession.refresh(false); // check if the node still exists @@ -1029,7 +1035,7 @@ || job.getProperty(EventUtil.PROPERTY_JOB_PARALLEL) != null; EventInfo putback = null; // we have to use the same session for unlocking that we used for locking! - synchronized ( this.backgroundSession ) { + synchronized ( this.backgroundLock ) { try { this.backgroundSession.refresh(false); // check if the job has been cancelled @@ -1334,7 +1340,7 @@ */ public void cancelJob(String jobId) { if ( jobId != null ) { - synchronized ( this.writerSession ) { + synchronized ( this.writeLock ) { try { this.writerSession.refresh(false); } catch (RepositoryException e) { Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java?rev=723362&r1=723361&r2=723362&view=diff ============================================================================== --- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java (original) +++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java Thu Dec 4 07:48:00 2008 @@ -80,6 +80,9 @@ /** Unloaded events. */ protected SetunloadedEvents = new HashSet(); + /** Sync lock */ + private final Object writeLock = new Object(); + /** * @see org.apache.sling.event.impl.AbstractRepositoryEventHandler#startWriterSession() */ @@ -116,7 +119,7 @@ // write event and update path // if something went wrong we get the node path and reschedule - synchronized ( this.writerSession ) { + synchronized ( this.writeLock ) { info.nodePath = this.persistEvent(info.event, scheduleInfo); } if ( info.nodePath != null ) { @@ -146,7 +149,7 @@ this.ignoreException(e); } if ( info != null && this.running ) { - synchronized ( this.writerSession ) { + synchronized ( this.writeLock ) { ScheduleInfo scheduleInfo = null; try { scheduleInfo = new ScheduleInfo(info.event); @@ -743,7 +746,7 @@ * @see org.apache.sling.event.TimedEventStatusProvider#cancelTimedEvent(java.lang.String) */ public void cancelTimedEvent(String jobId) { - synchronized ( this.writerSession ) { + synchronized ( this.writeLock ) { try { // is there a node? final Item foundNode = this.writerSession.itemExists(jobId) ? this.writerSession.getItem(jobId) : null;