jsedding commented on code in PR #43:
URL: 
https://github.com/apache/sling-org-apache-sling-event/pull/43#discussion_r2084954355


##########
src/main/java/org/apache/sling/event/impl/jobs/queues/JobQueueImpl.java:
##########
@@ -252,6 +252,10 @@ public Statistics getStatistics() {
      * This method might be called concurrently, therefore we use a guard
      */
     public void startJobs() {
+        if (!services.configuration.isJobProcessingEnabled()) {
+            logger.debug("Job processing is disabled, skipping job starts for 
queue {}", queueName);
+            return;
+        }

Review Comment:
   Once we return here, is `startJobs()` ever called again? I.e. once the 
condition is switched back on (e.g. during startup), will job starting really 
be resumed?



##########
src/test/java/org/apache/sling/event/impl/jobs/JobQueueImplTest.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.event.impl.jobs;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;

Review Comment:
   In Sling, we normally try to avoid star imports.



##########
src/main/java/org/apache/sling/event/impl/jobs/queues/JobQueueImpl.java:
##########
@@ -736,6 +748,19 @@ public boolean stopJob(final JobImpl job) {
         return handler != null;
     }
 
+    /**
+     * Stop all currently running jobs in this queue
+     */
+    public void stopAllJobs() {
+        logger.debug("Stopping all running jobs in queue {}", queueName);
+        synchronized ( this.processingJobsLists ) {
+            for (final JobHandler handler : this.processingJobsLists.values()) 
{
+                handler.stop();
+            }
+        }

Review Comment:
   Should `this.processingJobsList` be cleared after all handlers are stopped? 
I don't know 🙂 



##########
src/main/java/org/apache/sling/event/impl/jobs/config/JobManagerConfiguration.java:
##########
@@ -199,6 +202,50 @@ static JobManagerConfiguration 
newForTest(ResourceResolverFactory resourceResolv
     /** The topology capabilities. */
     private volatile TopologyCapabilities topologyCapabilities;
 
+    /** The condition that determines if job processing is enabled. */
+    @Reference(
+        target = 
"(osgi.condition.id=org.apache.sling.event.jobs.processing.enabled)",
+        cardinality = ReferenceCardinality.OPTIONAL,
+        policy = ReferencePolicy.DYNAMIC,
+        policyOption = ReferencePolicyOption.GREEDY
+    )
+    private volatile Condition jobProcessingEnabledCondition;

Review Comment:
   Does this call the bind/unbind methods? Or do you need to move the 
`@Reference` to the bind method?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to