You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by jo...@apache.org on 2022/01/03 15:08:19 UTC

[sling-org-apache-sling-event-dea] branch improvement/SLING-11025-use-dedicated-threadpool created (now 1d1262e)

This is an automated email from the ASF dual-hosted git repository.

joerghoh pushed a change to branch improvement/SLING-11025-use-dedicated-threadpool
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-event-dea.git.


      at 1d1262e  SLING-11025 use a dedicated thread pool

This branch includes the following new commits:

     new 1d1262e  SLING-11025 use a dedicated thread pool

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[sling-org-apache-sling-event-dea] 01/01: SLING-11025 use a dedicated thread pool

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joerghoh pushed a commit to branch improvement/SLING-11025-use-dedicated-threadpool
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-event-dea.git

commit 1d1262eee27567d896e4ffbd3253296dfc9974e6
Author: Joerg Hoh <jh...@adobe.com>
AuthorDate: Mon Jan 3 16:08:00 2022 +0100

    SLING-11025 use a dedicated thread pool
---
 .../apache/sling/event/dea/impl/DistributedEventReceiver.java    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/event/dea/impl/DistributedEventReceiver.java b/src/main/java/org/apache/sling/event/dea/impl/DistributedEventReceiver.java
index 9d5e71b..6fe6302 100644
--- a/src/main/java/org/apache/sling/event/dea/impl/DistributedEventReceiver.java
+++ b/src/main/java/org/apache/sling/event/dea/impl/DistributedEventReceiver.java
@@ -87,7 +87,7 @@ public class DistributedEventReceiver
     /** The cleanup period. */
     private final int cleanupPeriod;
 
-    /** Resolver used for writing. */
+    /** Resolver used for writing; needs to be refreshed before used */
     private volatile ResourceResolver writerResolver;
 
     /** Is the background task still running? */
@@ -126,6 +126,7 @@ public class DistributedEventReceiver
                 // schedule this service every 30 minutes
                 props.put("scheduler.period", 1800L);
                 props.put("scheduler.concurrent", Boolean.FALSE);
+                props.put("scheduler.threadpool", "org-apache-sling-event-dea");
 
                 final ServiceRegistration<?> reg =
                         bundleContext.registerService(new String[] {EventHandler.class.getName(),
@@ -135,6 +136,10 @@ public class DistributedEventReceiver
 
                 DistributedEventReceiver.this.serviceRegistration = reg;
 
+                /**
+                 * The writerResolver is a long running resource resolver, which is refreshed before it is used.
+                 * We also cannot use try-with-resource here, because writerResolver needs to be global due to this.
+                 */
                 try {
                     writerResolver = resourceResolverFactory.getServiceResourceResolver(null);
                     ResourceUtil.getOrCreateResource(writerResolver,
@@ -148,7 +153,7 @@ public class DistributedEventReceiver
                     running = false;
                 }
                 try {
-                    processWriteQueue();
+                    processWriteQueue(); // this will block until stop() is invoked
                 } catch (final Throwable t) { //NOSONAR
                     logger.error("Writer thread stopped with exception: " + t.getMessage(), t);
                     running = false;