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 2014/10/16 12:03:46 UTC
svn commit: r1632263 - in /sling/trunk/bundles/extensions/event/src:
main/java/org/apache/sling/event/impl/jobs/
main/java/org/apache/sling/event/impl/jobs/config/
main/java/org/apache/sling/event/impl/jobs/console/
main/java/org/apache/sling/event/imp...
Author: cziegeler
Date: Thu Oct 16 10:03:45 2014
New Revision: 1632263
URL: http://svn.apache.org/r1632263
Log:
SLING-4053 : Deprecate queue types IGNORE and DROP
Removed:
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/OutdatedMainQueueTest.java
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
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/console/WebConsolePlugin.java
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/QueueManager.java
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/topology/UpgradeTask.java
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobManager.java
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java?rev=1632263&r1=1632262&r2=1632263&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java Thu Oct 16 10:03:45 2014
@@ -66,7 +66,6 @@ import org.apache.sling.event.jobs.JobUt
import org.apache.sling.event.jobs.JobsIterator;
import org.apache.sling.event.jobs.NotificationConstants;
import org.apache.sling.event.jobs.Queue;
-import org.apache.sling.event.jobs.QueueConfiguration;
import org.apache.sling.event.jobs.ScheduledJobInfo;
import org.apache.sling.event.jobs.Statistics;
import org.apache.sling.event.jobs.TopicStatistics;
@@ -211,8 +210,8 @@ public class JobManagerImpl
*/
@Override
public void restart() {
- // TODO reset statistics
- // TODO reload queues?
+ // nothing to do as this is deprecated, let's log a warning
+ logger.warn("Deprecated JobManager.restart() is called.");
}
/**
@@ -893,46 +892,38 @@ public class JobManagerImpl
final Map<String, Object> jobProperties,
final List<String> errors) {
final QueueInfo info = this.queueManager.getQueueInfo(jobTopic);
- if ( info.queueConfiguration.getType() == QueueConfiguration.Type.DROP ) {
- if ( logger.isDebugEnabled() ) {
- logger.debug("Dropping job due to configuration of queue {} : {}", info.queueName, Utility.toString(jobTopic, jobName, jobProperties));
- }
- NotificationUtility.sendNotification(this.eventAdmin, NotificationConstants.TOPIC_JOB_CANCELLED, jobTopic, jobName, jobProperties, null);
+ // check for unique jobs
+ if ( jobName != null && !this.lock(jobTopic, jobName) ) {
+ logger.debug("Discarding duplicate job {}", Utility.toString(jobTopic, jobName, jobProperties));
+ return null;
} else {
- // check for unique jobs
- if ( jobName != null && !this.lock(jobTopic, jobName) ) {
- logger.debug("Discarding duplicate job {}", Utility.toString(jobTopic, jobName, jobProperties));
- return null;
- } else {
- if ( info.queueConfiguration.getType() != QueueConfiguration.Type.IGNORE ) {
- final TopologyCapabilities caps = this.topologyCapabilities;
- info.targetId = (caps == null ? null : caps.detectTarget(jobTopic, jobProperties, info));
- }
- if ( logger.isDebugEnabled() ) {
- if ( info.targetId != null ) {
- logger.debug("Persisting job {} into queue {}, target={}", new Object[] {Utility.toString(jobTopic, jobName, jobProperties), info.queueName, info.targetId});
- } else {
- logger.debug("Persisting job {} into queue {}", Utility.toString(jobTopic, jobName, jobProperties), info.queueName);
- }
- }
- final ResourceResolver resolver = this.configuration.createResourceResolver();
- try {
- final JobImpl job = this.writeJob(resolver,
- jobTopic,
- jobName,
- jobProperties,
- info);
- return job;
- } catch (final PersistenceException re ) {
- // something went wrong, so let's log it
- this.logger.error("Exception during persisting new job '" + Utility.toString(jobTopic, jobName, jobProperties) + "'", re);
- } finally {
- resolver.close();
- }
- if ( errors != null ) {
- errors.add("Unable to persist new job.");
+ final TopologyCapabilities caps = this.topologyCapabilities;
+ info.targetId = (caps == null ? null : caps.detectTarget(jobTopic, jobProperties, info));
+
+ if ( logger.isDebugEnabled() ) {
+ if ( info.targetId != null ) {
+ logger.debug("Persisting job {} into queue {}, target={}", new Object[] {Utility.toString(jobTopic, jobName, jobProperties), info.queueName, info.targetId});
+ } else {
+ logger.debug("Persisting job {} into queue {}", Utility.toString(jobTopic, jobName, jobProperties), info.queueName);
}
}
+ final ResourceResolver resolver = this.configuration.createResourceResolver();
+ try {
+ final JobImpl job = this.writeJob(resolver,
+ jobTopic,
+ jobName,
+ jobProperties,
+ info);
+ return job;
+ } catch (final PersistenceException re ) {
+ // something went wrong, so let's log it
+ this.logger.error("Exception during persisting new job '" + Utility.toString(jobTopic, jobName, jobProperties) + "'", re);
+ } finally {
+ resolver.close();
+ }
+ if ( errors != null ) {
+ errors.add("Unable to persist new job.");
+ }
}
return null;
}
@@ -1001,19 +992,10 @@ public class JobManagerImpl
final InternalQueueConfiguration config = queueInfo.queueConfiguration;
// Sanity check if queue configuration has changed
- if ( config.getType() == QueueConfiguration.Type.DROP ) {
- if ( logger.isDebugEnabled() ) {
- logger.debug("Dropping job due to configuration of queue {} : {}", queueInfo.queueName, Utility.toString(job));
- }
- this.finishJob(job, Job.JobState.DROPPED, false, -1); // DROP means complete removal
- } else {
- String targetId = null;
- if ( config.getType() != QueueConfiguration.Type.IGNORE ) {
- final TopologyCapabilities caps = this.topologyCapabilities;
- targetId = (caps == null ? null : caps.detectTarget(job.getTopic(), job.getProperties(), queueInfo));
- }
- this.maintenanceTask.reassignJob(job, targetId);
- }
+ String targetId = null;
+ final TopologyCapabilities caps = this.topologyCapabilities;
+ targetId = (caps == null ? null : caps.detectTarget(job.getTopic(), job.getProperties(), queueInfo));
+ this.maintenanceTask.reassignJob(job, targetId);
}
/**
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=1632263&r1=1632262&r2=1632263&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 Thu Oct 16 10:03:45 2014
@@ -35,6 +35,8 @@ import org.apache.sling.event.impl.suppo
import org.apache.sling.event.jobs.JobUtil;
import org.apache.sling.event.jobs.QueueConfiguration;
import org.osgi.framework.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Component(metatype=true,
name="org.apache.sling.event.jobs.QueueConfiguration",
@@ -114,6 +116,9 @@ import org.osgi.framework.Constants;
public class InternalQueueConfiguration
implements QueueConfiguration, Comparable<InternalQueueConfiguration> {
+ /** Logger. */
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
/** The name of the queue. */
private String name;
@@ -224,6 +229,7 @@ public class InternalQueueConfiguration
}
}
if ( type == Type.IGNORE || type == Type.DROP ) {
+ logger.warn("Queue is using deprecated queue type. Ignoring queue {} with type {}", name, type);
return false;
}
return true;
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java?rev=1632263&r1=1632262&r2=1632263&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/console/WebConsolePlugin.java Thu Oct 16 10:03:45 2014
@@ -154,8 +154,6 @@ public class WebConsolePlugin extends Ht
}
} else if ( "test".equals(cmd) ) {
this.startTestJob();
- } else if ( "restart".equals(cmd) ) {
- this.jobManager.restart();
} else if ( "dropall".equals(cmd) ) {
final Queue q = this.getQueue(req);
if ( q != null ) {
@@ -193,9 +191,6 @@ public class WebConsolePlugin extends Ht
"</form>");
pw.println("<script type='text/javascript'>");
pw.println("function eventingsubmit(action, queue) {" +
- " if ( action == 'restart' ) {" +
- " if ( !confirm('Do you really want to restart the job handling?') ) { return; }" +
- " }" +
" document.forms['eventingcmd'].action.value = action;" +
" document.forms['eventingcmd'].queue.value = queue;" +
" document.forms['eventingcmd'].submit();" +
@@ -205,7 +200,6 @@ public class WebConsolePlugin extends Ht
msg != null ? " : " + msg : "");
pw.println("<div class='ui-widget-header ui-corner-top buttonGroup'>");
pw.println("<span style='float: left; margin-left: 1em'>Apache Sling Job Handling: Overall Statistics</span>");
- this.printForm(pw, null, "Restart!", "restart");
this.printForm(pw, null, "Reset Stats", "reset");
pw.println("</div>");
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/QueueManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/QueueManager.java?rev=1632263&r1=1632262&r2=1632263&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/QueueManager.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/QueueManager.java Thu Oct 16 10:03:45 2014
@@ -137,7 +137,7 @@ public class QueueManager
*/
private void maintain() {
this.schedulerRuns++;
- logger.debug("Job manager maintenance: Starting #{}", this.schedulerRuns);
+ logger.debug("Queue manager maintenance: Starting #{}", this.schedulerRuns);
// check for unprocessed jobs first
logger.debug("Checking for unprocessed jobs...");
@@ -168,7 +168,7 @@ public class QueueManager
}
}
}
- logger.debug("Job manager maintenance: Finished #{}", this.schedulerRuns);
+ logger.debug("Queue manager maintenance: Finished #{}", this.schedulerRuns);
}
/**
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/topology/UpgradeTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/topology/UpgradeTask.java?rev=1632263&r1=1632262&r2=1632263&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/topology/UpgradeTask.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/topology/UpgradeTask.java Thu Oct 16 10:03:45 2014
@@ -36,7 +36,6 @@ import org.apache.sling.event.impl.jobs.
import org.apache.sling.event.impl.support.Environment;
import org.apache.sling.event.impl.support.ResourceHelper;
import org.apache.sling.event.jobs.Job;
-import org.apache.sling.event.jobs.QueueConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -163,19 +162,11 @@ public class UpgradeTask {
if ( potentialTargets != null && potentialTargets.size() > 0 ) {
final QueueInfo info = queueManager.getQueueInfo(topic);
logger.debug("Found queue {} for {}", info.queueConfiguration, topic);
- // if queue is configured to drop, we drop
- if ( info.queueConfiguration.getType() == QueueConfiguration.Type.DROP) {
- resolver.delete(jobResource);
- resolver.commit();
- return;
- }
- if ( info.queueConfiguration.getType() != QueueConfiguration.Type.IGNORE ) {
- targetId = caps.detectTarget(topic, vm, info);
- if ( targetId != null ) {
- properties.put(Job.PROPERTY_JOB_QUEUE_NAME, info.queueName);
- properties.put(Job.PROPERTY_JOB_TARGET_INSTANCE, targetId);
- properties.put(Job.PROPERTY_JOB_RETRIES, info.queueConfiguration.getMaxRetries());
- }
+ targetId = caps.detectTarget(topic, vm, info);
+ if ( targetId != null ) {
+ properties.put(Job.PROPERTY_JOB_QUEUE_NAME, info.queueName);
+ properties.put(Job.PROPERTY_JOB_TARGET_INSTANCE, targetId);
+ properties.put(Job.PROPERTY_JOB_RETRIES, info.queueConfiguration.getMaxRetries());
}
}
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobManager.java?rev=1632263&r1=1632262&r2=1632263&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobManager.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/JobManager.java Thu Oct 16 10:03:45 2014
@@ -77,7 +77,9 @@ public interface JobManager {
* Restart the job manager.
* This method restarts the job manager and all queues - currently processed jobs will be finished.
* The job manager should only be restarted if really necessary!
+ * @deprecated This method does nothing
*/
+ @Deprecated
void restart();
/**