Author: cziegeler
Date: Tue Jul 21 09:01:27 2009
New Revision: 796193
URL: http://svn.apache.org/viewvc?rev=796193&view=rev
Log:
SLING-1058 : Notify waiting job if finish processing fails and change defaults
for the thread pool.
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
sling/trunk/bundles/extensions/event/src/main/resources/OSGI-INF/metatype/metatype.properties
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java?rev=796193&r1=796192&r2=796193&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java
(original)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/EventingThreadPool.java
Tue Jul 21 09:01:27 2009
@@ -46,8 +46,8 @@
private static final String PROPERTY_MAX_POOL_SIZE = "maxPoolSize";
private static final String PROPERTY_QUEUEL_SIZE = "queueSize";
- private static final int DEFAULT_MIN_POOL_SIZE = 20; // this is sufficient
for all threads + approx 10 job queues
- private static final int DEFAULT_MAX_POOL_SIZE = 30;
+ private static final int DEFAULT_MIN_POOL_SIZE = 35; // this is sufficient
for all threads + approx 25 job queues
+ private static final int DEFAULT_MAX_POOL_SIZE = 50;
private static final int DEFAULT_QUEUE_SIZE = -1; // infinite
/**
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=796193&r1=796192&r2=796193&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
Tue Jul 21 09:01:27 2009
@@ -212,7 +212,9 @@
}
}
this.componentContext = null;
- JOB_THREAD_POOL = null;
+ if ( JOB_THREAD_POOL == this.threadPool ) {
+ JOB_THREAD_POOL = null;
+ }
}
/**
@@ -1139,6 +1141,7 @@
synchronized ( this.backgroundLock ) {
// we might get here asnyc while this service has already been
shutdown!
if ( this.backgroundSession == null ) {
+ checkForNotify(job, null);
// we can only return false here
return false;
}
@@ -1146,6 +1149,7 @@
this.backgroundSession.refresh(false);
// check if the job has been cancelled
if ( !this.backgroundSession.itemExists(eventNodePath) ) {
+ checkForNotify(job, null);
return true;
}
final Node eventNode = (Node)
this.backgroundSession.getItem(eventNodePath);
@@ -1222,14 +1226,7 @@
// if this is an own job queue, we simply signal the queue
to continue
// it will pick up the event and either reschedule or wait
if ( job.getProperty(EventUtil.PROPERTY_JOB_QUEUE_NAME) !=
null ) {
- // we know the queue exists
- final JobBlockingQueue jobQueue;
- synchronized ( this.jobQueues ) {
- jobQueue =
this.jobQueues.get(job.getProperty(EventUtil.PROPERTY_JOB_QUEUE_NAME));
- }
- synchronized ( jobQueue.getLock()) {
- jobQueue.notifyFinish(info);
- }
+ checkForNotify(job, info);
} else {
// delay rescheduling?
@@ -1248,16 +1245,7 @@
} else {
// if this is an own job queue, we simply signal the queue
to continue
// it will pick up the event and continue with the next
event
- if ( job.getProperty(EventUtil.PROPERTY_JOB_QUEUE_NAME) !=
null ) {
- // we know the queue exists
- final JobBlockingQueue jobQueue;
- synchronized ( this.jobQueues ) {
- jobQueue =
this.jobQueues.get(job.getProperty(EventUtil.PROPERTY_JOB_QUEUE_NAME));
- }
- synchronized ( jobQueue.getLock()) {
- jobQueue.notifyFinish(null);
- }
- }
+ checkForNotify(job, null);
}
} catch (RepositoryException re) {
this.logger.error("Unable to create new session.", re);
@@ -1294,6 +1282,19 @@
return reschedule;
}
+ private void checkForNotify(final Event job, final EventInfo info) {
+ if ( job.getProperty(EventUtil.PROPERTY_JOB_QUEUE_NAME) != null ) {
+ // we know the queue exists
+ final JobBlockingQueue jobQueue;
+ synchronized ( this.jobQueues ) {
+ jobQueue =
this.jobQueues.get(job.getProperty(EventUtil.PROPERTY_JOB_QUEUE_NAME));
+ }
+ synchronized ( jobQueue.getLock()) {
+ jobQueue.notifyFinish(info);
+ }
+ }
+ }
+
/**
* Search for job nodes
* @param topic The job topic
Modified:
sling/trunk/bundles/extensions/event/src/main/resources/OSGI-INF/metatype/metatype.properties
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=796193&r1=796192&r2=796193&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++
sling/trunk/bundles/extensions/event/src/main/resources/OSGI-INF/metatype/metatype.properties
Tue Jul 21 09:01:27 2009
@@ -87,7 +87,7 @@
maxPoolSize.name = Max Pool Size
maxPoolSize.description = The maximum pool size. The maximum pool size should
be higher than \
- the minimum pool size.
+ or equal to the minimum pool size.
queueSize.name = Queue Size
queueSize.description = The maximum size of the thread queue if the pool is
exhausted.