incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1045050 - in /sling/trunk/bundles/extensions/event: ./ src/main/java/org/apache/sling/event/impl/jobs/ src/main/java/org/apache/sling/event/impl/jobs/console/ src/main/java/org/apache/sling/event/jobs/ src/main/resources/OSGI-INF/metatype/
Date Mon, 13 Dec 2010 10:02:21 GMT
Author: cziegeler
Date: Mon Dec 13 10:02:21 2010
New Revision: 1045050

URL: http://svn.apache.org/viewvc?rev=1045050&view=rev
Log:
SLING-1896 : Provide a configuration option to disable/enable all event processing

Modified:
    sling/trunk/bundles/extensions/event/pom.xml
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.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/jobs/JobManager.java
    sling/trunk/bundles/extensions/event/src/main/resources/OSGI-INF/metatype/metatype.properties

Modified: sling/trunk/bundles/extensions/event/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/pom.xml?rev=1045050&r1=1045049&r2=1045050&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/pom.xml (original)
+++ sling/trunk/bundles/extensions/event/pom.xml Mon Dec 13 10:02:21 2010
@@ -29,7 +29,7 @@
 
     <artifactId>org.apache.sling.event</artifactId>
     <packaging>bundle</packaging>
-    <version>3.0.0-SNAPSHOT</version>
+    <version>2.4.3-SNAPSHOT</version>
 
     <name>Apache Sling Event Support</name>
     <description>

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java?rev=1045050&r1=1045049&r2=1045050&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
Mon Dec 13 10:02:21 2010
@@ -141,6 +141,13 @@ public class DefaultJobManager
     /** Statistics per topic. */
     private final ConcurrentMap<String, TopicStatistics> topicStatistics = new ConcurrentHashMap<String,
TopicStatistics>();
 
+    private static final boolean DEFAULT_ENABLED = true;
+
+    @Property(boolValue=DEFAULT_ENABLED)
+    private static final String PROP_ENABLED = "jobmanager.enabled";
+
+    private boolean enabled = DEFAULT_ENABLED;
+
     /**
      * Activate this component.
      * @param props Configuration properties
@@ -174,6 +181,14 @@ public class DefaultJobManager
             queueProps.put(ConfigurationConstants.PROP_MAX_PARALLEL, 2);
         }
         this.mainConfiguration = InternalQueueConfiguration.fromConfiguration(queueProps);
+
+        final boolean oldEnabled = this.enabled;
+        this.enabled = OsgiUtil.toBoolean(props.get(PROP_ENABLED), DEFAULT_ENABLED);
+
+        // if we have been disabled before and now get enabled, restart to get processing
going
+        if ( this.enabled != oldEnabled && this.enabled ) {
+            this.restart();
+        }
     }
 
     /**
@@ -226,6 +241,13 @@ public class DefaultJobManager
      * @param event The job event
      */
     public void process(final JobEvent event) {
+        // are we disabled?
+        if ( !this.enabled ) {
+            if ( logger.isDebugEnabled() ) {
+                logger.debug("Job manager is disabled. Ignoring job {}", EventUtil.toString(event.event));
+            }
+            return;
+        }
         // get the queue configuration
         InternalQueueConfiguration config = configManager.getQueueConfiguration(event);
 
@@ -715,4 +737,11 @@ public class DefaultJobManager
             job.restart();
         }
     }
+
+    /**
+     * @see org.apache.sling.event.jobs.JobManager#isJobProcessingEnabled()
+     */
+    public boolean isJobProcessingEnabled() {
+        return this.enabled;
+    }
 }

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=1045050&r1=1045049&r2=1045050&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
Mon Dec 13 10:02:21 2010
@@ -175,7 +175,9 @@ public class WebConsolePlugin extends Ht
                    " document.forms['eventingcmd'].submit();" +
                    "} </script>");
 
-        pw.printf("<p class='statline ui-state-highlight'>Apache Sling Eventing%s%n</p>",
msg != null ? " : " + msg : "");
+        pw.printf("<p class='statline ui-state-highlight'>Apache Sling Eventing%s%s%n</p>",
+                this.jobManager.isJobProcessingEnabled() ? "" : " (JOB PROCESSING IS DISABLED!)",
+                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 Eventing:
Overall Statistics</span>");
         this.printForm(pw, null, "Restart!", "restart");
@@ -373,6 +375,10 @@ public class WebConsolePlugin extends Ht
         pw.println("Apache Sling Eventing");
         pw.println("---------------------");
 
+        if (!jobManager.isJobProcessingEnabled()) {
+            pw.println("JOB PROCESSING IS DISABLED!");
+            pw.println();
+        }
         Statistics s = this.jobManager.getStatistics();
         pw.println("Overall Statistics");
         pw.printf("Start Time : %s%n", formatDate(s.getStartTime()));

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=1045050&r1=1045049&r2=1045050&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
Mon Dec 13 10:02:21 2010
@@ -110,4 +110,10 @@ public interface JobManager {
      * The job manager should only be restarted if really necessary!
      */
     void restart();
+
+    /**
+     * Is job processing enabled?
+     * It is possible to completly turn off job processing.
+     */
+    boolean isJobProcessingEnabled();
 }

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=1045050&r1=1045049&r2=1045050&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
Mon Dec 13 10:02:21 2010
@@ -104,6 +104,10 @@ jobscheduler.period.name = Cleanup Inter
 jobscheduler.period.description = Interval in seconds in which unused \
  queues are stopped. The default value is 5 minutes (300 seconds).
 
+jobmanager.enabled.name = Job Processing Enabled
+jobmanager.enabled.description = This flag controls wheter the job processing \
+ is running or is completly turned off. Turning off job processing will stop \
+ all job processing and the jobs are queued up.
 
 #
 # Persistence Handler



Mime
View raw message