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 2013/04/23 11:03:35 UTC
svn commit: r1470855 - in /sling/trunk/bundles/extensions/event/src/main:
java/org/apache/sling/event/impl/jobs/config/
java/org/apache/sling/event/impl/jobs/queues/ resources/OSGI-INF/metatype/
Author: cziegeler
Date: Tue Apr 23 09:03:35 2013
New Revision: 1470855
URL: http://svn.apache.org/r1470855
Log:
SLING-2830 : Discontinue per job configurations for queue processing - make service ranking configurable through web console and always apply sorting
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.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
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.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/jobs/config/InternalQueueConfiguration.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java?rev=1470855&r1=1470854&r2=1470855&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/InternalQueueConfiguration.java Tue Apr 23 09:03:35 2013
@@ -61,10 +61,12 @@ import org.osgi.framework.Constants;
value=ConfigurationConstants.DEFAULT_PRIORITY,
options={@PropertyOption(name="NORM",value="Norm"),
@PropertyOption(name="MIN",value="Min"),
- @PropertyOption(name="MAX",value="Max")})
+ @PropertyOption(name="MAX",value="Max")}),
+ @Property(name=Constants.SERVICE_RANKING, intValue=0,
+ label="%queue.ranking.name", description="%queue.ranking.description")
})
public class InternalQueueConfiguration
- implements QueueConfiguration {
+ implements QueueConfiguration, Comparable<InternalQueueConfiguration> {
/** The name of the queue. */
private String name;
@@ -280,4 +282,15 @@ public class InternalQueueConfiguration
", pid=" + this.pid +
", isValid=" + this.isValid() + "}";
}
+
+ @Override
+ public int compareTo(final InternalQueueConfiguration other) {
+ if ( this.serviceRanking < other.serviceRanking ) {
+ return 1;
+ } else if ( this.serviceRanking > other.serviceRanking ) {
+ return -1;
+ }
+ return 0;
+ }
+
}
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java?rev=1470855&r1=1470854&r2=1470855&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/config/QueueConfigurationManager.java Tue Apr 23 09:03:35 2013
@@ -18,6 +18,10 @@
*/
package org.apache.sling.event.impl.jobs.config;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -87,13 +91,13 @@ public class QueueConfigurationManager {
if ( trackedConfigs == null || trackedConfigs.length == 0 ) {
configurations = new InternalQueueConfiguration[0];
} else {
- configurations = new InternalQueueConfiguration[trackedConfigs.length];
- int i = 0;
+ final List<InternalQueueConfiguration> configs = new ArrayList<InternalQueueConfiguration>();
for(final Object entry : trackedConfigs) {
final InternalQueueConfiguration config = (InternalQueueConfiguration)entry;
- configurations[i] = config;
- i++;
+ configs.add(config);
}
+ Collections.sort(configs);
+ configurations = configs.toArray(new InternalQueueConfiguration[configs.size()]);
}
this.orderedConfigs = configurations;
this.lastTrackerCount = count;
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=1470855&r1=1470854&r2=1470855&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 Tue Apr 23 09:03:35 2013
@@ -172,8 +172,12 @@ public abstract class AbstractJobQueue
// continue queue processing to stop the queue
this.put(new JobHandler(null, null));
- this.processsingJobsLists.clear();
- this.startedJobsLists.clear();
+ synchronized ( this.processsingJobsLists ) {
+ this.processsingJobsLists.clear();
+ }
+ synchronized ( this.startedJobsLists ) {
+ this.startedJobsLists.clear();
+ }
this.logger.info("Stopped job queue {}", this.queueName);
}
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=1470855&r1=1470854&r2=1470855&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 Tue Apr 23 09:03:35 2013
@@ -24,7 +24,7 @@ import org.apache.sling.commons.schedule
import org.apache.sling.event.impl.jobs.JobConsumerManager;
import org.apache.sling.event.impl.jobs.JobHandler;
import org.apache.sling.event.impl.jobs.config.InternalQueueConfiguration;
-import org.apache.sling.event.jobs.JobUtil;
+import org.apache.sling.event.jobs.Job;
import org.osgi.service.event.EventAdmin;
/**
@@ -119,8 +119,8 @@ public abstract class AbstractParallelJo
// we just sleep for the delay time - if none, we continue and retry
// this job again
long delay = this.configuration.getRetryDelayInMs();
- if ( info.getJob().getProperty(JobUtil.PROPERTY_JOB_RETRY_DELAY) != null ) {
- delay = info.getJob().getProperty(JobUtil.PROPERTY_JOB_RETRY_DELAY, Long.class);
+ if ( info.getJob().getProperty(Job.PROPERTY_JOB_RETRY_DELAY) != null ) {
+ delay = info.getJob().getProperty(Job.PROPERTY_JOB_RETRY_DELAY, Long.class);
}
if ( delay > 0 ) {
final Date fireDate = new Date();
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java?rev=1470855&r1=1470854&r2=1470855&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java Tue Apr 23 09:03:35 2013
@@ -27,7 +27,7 @@ import java.util.concurrent.LinkedBlocki
import org.apache.sling.event.impl.jobs.JobConsumerManager;
import org.apache.sling.event.impl.jobs.JobHandler;
import org.apache.sling.event.impl.jobs.config.InternalQueueConfiguration;
-import org.apache.sling.event.jobs.JobUtil;
+import org.apache.sling.event.jobs.Job;
import org.osgi.service.event.EventAdmin;
/**
@@ -143,8 +143,8 @@ public final class OrderedJobQueue exten
// we just sleep for the delay time - if none, we continue and retry
// this job again
long delay = this.configuration.getRetryDelayInMs();
- if ( info.getJob().getProperty(JobUtil.PROPERTY_JOB_RETRY_DELAY) != null ) {
- delay = info.getJob().getProperty(JobUtil.PROPERTY_JOB_RETRY_DELAY, Long.class);
+ if ( info.getJob().getProperty(Job.PROPERTY_JOB_RETRY_DELAY) != null ) {
+ delay = info.getJob().getProperty(Job.PROPERTY_JOB_RETRY_DELAY, Long.class);
}
if ( delay > 0 ) {
synchronized ( this.sleepLock ) {
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=1470855&r1=1470854&r2=1470855&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 Apr 23 09:03:35 2013
@@ -61,6 +61,9 @@ queue.maxparallel.name = Maximum Paralle
queue.maxparallel.description = The maximum number of parallel jobs started for this queue. \
A value of -1 is substituted with the number of available processors.
+queue.ranking.name = Ranking
+queue.ranking.description = Integer value defining the ranking of this queue configuration. \
+ If more than one queue matches a job topic, the one with the highest ranking is used.
#
# Job Event Handler