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 2008/12/04 16:48:00 UTC
svn commit: r723362 - in
/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl:
JobEventHandler.java TimedJobHandler.java
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<EventInfo> 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 Set<String>unloadedEvents = new HashSet<String>();
+ /** 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;