You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:26:31 UTC

[sling-org-apache-sling-commons-threads] annotated tag org.apache.sling.commons.threads-3.2.4 created (now f873f10)

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

rombert pushed a change to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git.


      at f873f10  (tag)
 tagging e6dae18df7a549a78bfd476115a45861f9f6e783 (commit)
      by Carsten Ziegeler
      on Wed Dec 30 14:53:42 2015 +0000

- Log -----------------------------------------------------------------
org.apache.sling.commons.threads-3.2.4
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new cdf4581  Add new threads module for providing thread pools.
     new c3a54e0  Set svn:ignore
     new 6569a93  Use thread pool to create new threads instead of directly instantiating threads.
     new a216040  Create own thread pool for eventing.
     new 5dfc716  Use thread pooling for scheduler as well. Create own pool for eventing.
     new f8c7fb7  Use jvm default thread factory and always provide priority and daemon settings.
     new a5761c4  Use thread pool configuration object to be extensible.
     new b9020b0  Move licence and notice to top level dir.
     new e413af3  Add incubator disclaimer.
     new 1597daa  Add notice files.
     new 3020eb2  Write first element in pom in one line (to avoid problems with the maven release plugin) and minor pom fixes.
     new 2c687bd  Update notice files.
     new 4c666b9  SLING-417: Move sling/threads to commons/threads
     new 8d1f9f1  SLING-417: Move threads to commons.
     new 23e3268  Eclude maven-eclipse.xml generated by the maven eclipse plugin.
     new 5fa8b5a  SLING-442: Clean up exports, imports, dependencies and used plugins.
     new f7b228d  SLING-479 Fix @scr.tags:   - normalize metadata attribute settings to "no"   - ensure proper metadata and ds attributes are set   - create metatype.properties files where required   - fix metatype.properties files
     new b8442a7  SLING-483: Add excludes for javadocs (WiP)
     new f31810f  SLING-495 - NOTICE files generated using mknotice script
     new 7a30ca2  SLING-495 - NOTICE files updated according to changes in revision 662927
     new fc95c64  SLING-495 - NOTICE files regenerated with revision 663097 changes
     new 601db57  Use released version of parent pom.
     new e4986f9  [maven-release-plugin] prepare release org.apache.sling.commons.threads-2.0.0-incubator
     new 7097543  [maven-release-plugin] prepare for next development iteration
     new bac4721  Fix reference to parent pom.
     new 88286dd  SLING-521: Restore more notice files.
     new dc0cc02  SLING-521: Separate between notice files for bin and src dists.
     new 82242fd  SLING-521: Separate between notice files for bin and src dists.
     new 64c2458  SLING-521: Separate between notice files for bin and src dists.
     new b29c28c  Change copyright year to 2008.
     new 88db633  Update to released versions.
     new 3aaff93  [maven-release-plugin] prepare release org.apache.sling.commons.threads-2.0.2-incubator
     new c5e1a11  [maven-release-plugin] prepare for next development iteration
     new bac3bfb  Use latest snapshots again to make project buildable.
     new 0720836  Use released parent pom where possible.
     new bb289e6  SLING-555 : Update all poms to use the latest parent pom; update parent pom to include the incubator repo for plugins and use latest plugins.
     new daee250  SLING-758 : Correctly evaluate block policy and use the correct handler.
     new 194ca0d  Add more logging to easier detect pool problems.
     new 21e9144  SLING-808 : Increase version to 5-incubator-SNAPSHOT
     new 3ad9b97  Update notice files to include 2009 in copyright statement.
     new 58081a1  SLING-829 Cosmetics to the bundle/project names
     new 3a9b17c  SLING-865 : Move to bundles
     new ae528ef  SLING-865 : Adjust reactor pom and svn information in each module.
     new 6807294  SLING-865 : Adjust path to parent pom and add profiles for samples and contrib
     new 7807d1c  Use release parent pom
     new 03fc7dc  [maven-release-plugin] prepare release org.apache.sling.commons.threads-2.0.4-incubator
     new a28c935  [maven-release-plugin] prepare for next development iteration
     new 4ca55b3  Use next dev version of parent pom
     new bed1b63  Set parent pom to released version.
     new 6ad9afb  Move Sling to new TLP location
     new 10df9b4  SLING-1011 : Remove disclaimer file.
     new ae744d2  SLING-1011 : Adjust svn location
     new 97b3488  SLING-1011 : Remove disclaimer from readme's, adjust links to webite, fix versions in poms.
     new 97733b6  SLING-1033 Upgrade to Sling parent POM 6 (and ensure web app has the leglize stuff, too)
     new ca64268  SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries
     new 3423042  SLING-1244 : Redesign thread pool management
     new 1be56f6  [maven-release-plugin] prepare release org.apache.sling.commons.threads-3.0.0
     new d87e5e7  [maven-release-plugin] prepare for next development iteration
     new b56bac2  Add some more debug information.
     new 60be200  Fix typo
     new c65358b  Use released parent pom.
     new 8145a6d  SLING-1699 : New default configuration is created on each startup
     new 7ec685e  Update notice files
     new f0b3a2a  [maven-release-plugin] prepare release org.apache.sling.commons.threads-3.0.2
     new 77bf590  [maven-release-plugin] prepare for next development iteration
     new 33781d0  SLING-1819 : Unused custom thread pool is never removed
     new 540bc62  SLING-1820 : Display current pool statistics in web console
     new b92d2c5  SLING-1821 :  Custom thread pools should get an optional label
     new 6d5d355  Add a web console label
     new 9499566  SLING-1833 : Remove direct dependency to web console by using new configuration printer support
     new 358040b  Prepare for release.
     new b6b8506  [maven-release-plugin] prepare release org.apache.sling.commons.threads-3.1.0
     new 327ebb0  [maven-release-plugin] prepare for next development iteration
     new 8046561  updating all modules to parent 10-SNAPSHOT in anticipation of emma additions to parent
     new c36972c  Update to recent snapshots
     new 0e4133b  Use latest releases.
     new 8ac6fdc  SLING-2150 : Update plugins to use the latest available versions
     new abc3e4c  Update to recent snapshot
     new c88d147  Using latest released parent pom
     new e281787  SLING-2187 - adding new module to contain our custom notice file; adding remote-resources plugin configuration to parent pom and removing all existing appended-resources NOTICE files
     new b7d45cc  temporarily using snapshots during release vote
     new 558c2bb  using latest releases
     new 22cbbc7  SLING-2480 : Add config for maven-sling-plugin to m2e configuration
     new bbd4453  Update to latest parent pom
     new ec3dff0  Use released versions
     new 6a7b2e4  Typo
     new 540daa4  SLING-2540 : Allow the ThreadPool to process Callable/Runnable and return a Future. Apply patch from Timothee Maret
     new 66cfaea  SLING-2563 - auto generate label based on a stack trace
     new 606bc12  SLING-2564 - adding JMX monitoring of Sling Thread Pools
     new b2e73ea  SLING-2535 wrapped the reference counter in a dedicated synchronised block to ensure that all access to the counter is safe. I think this will be safer than calling from within synchronised blocks as it doesnt rely on the caller remembering the methods need to be single threaded.
     new 9243258  SLING-2535 Undid my previous commit and put the synchronisation one layer further out as orriginally suggested. Synchronising in incUsage and decUsage is too risky from a deadlock point of view. Added Javadoc to warn about thread safety on the methods.
     new 6bb1173  Use latest releases and update to new parent pom
     new 6befbeb  Update to latest parent pom and use latest releases in launchpad
     new 5b61798  Correct reactor pom and update to parent pom 16
     new decafa3  SLING-2858 - Maven build fails after upgrading to parent 16: No annotation processors found in classpath
     new 77ccb6c  Update to latest parent pom
     new 95583d2  Update to parent pom 18
     new 5528320  [maven-release-plugin] prepare release org.apache.sling.commons.threads-3.2.0
     new 9e861b7  [maven-release-plugin] prepare for next development iteration
     new 394a1f9  Update to parent pom v19
     new a05956b  Updated to parent version 20
     new d71bd12  Update to Sling Parent POM 22 with baselining enabled
     new c7898cf  SLING-4698 - Set parent.relativePath to empty for all modules
     new 1a311ec  Update to Sling Parent 23
     new fadad3a  set parent version to 24 and add empty relativePath where missing
     new ae7b37d  Update the main reactor to parent 25
     new 4f0f0ad  SLING-5332 - Move Commons Threads to package-info.java based exports
     new 133b6f7  SLING-5333 - Commons Threads exported interfaces/classes should be @ProviderType
     new 6c5554b  SLING-4676 - Clean up threads or refresh threads when put back into the pool
     new 75dab72  [maven-release-plugin] prepare release org.apache.sling.commons.threads-3.2.2
     new 6bf50b3  [maven-release-plugin] prepare for next development iteration
     new db21f6f  SLING-5343 - Meaningful thread names
     new 683f952  SLING-5343 - Meaningful thread names
     new 70b7d25  SLING-5343 - Meaningful thread names
     new df522dd  SLING-5354 - Thread Pool max-thread-age config not taken into account
     new 6935268  SLING-5343 - Meaningful thread names
     new ed87469  SLING-5354 - Thread Pool max-thread-age config not taken into account
     new a419119  [maven-release-plugin] prepare release org.apache.sling.commons.threads-3.2.4
     new e6dae18  [maven-release-plugin] copy for tag org.apache.sling.commons.threads-3.2.4

The 119 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.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-commons-threads] 01/09: [maven-release-plugin] prepare for next development iteration

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit 6bf50b31a73adce389f52b34d65feb8ba537d761
Author: Julian Sedding <js...@apache.org>
AuthorDate: Thu Nov 26 16:45:13 2015 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1716741 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index ee7baf0..d0f87e6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
 
     <artifactId>org.apache.sling.commons.threads</artifactId>
     <packaging>bundle</packaging>
-    <version>3.2.2</version>
+    <version>3.2.3-SNAPSHOT</version>
 
     <name>Apache Sling Thread Support</name>
     <description>
@@ -37,9 +37,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.threads-3.2.2</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.threads-3.2.2</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.threads-3.2.2</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/threads</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-threads] 07/09: SLING-5354 - Thread Pool max-thread-age config not taken into account

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit ed874691f349bf3a17b874cff62084def1c01e44
Author: Julian Sedding <js...@apache.org>
AuthorDate: Mon Dec 7 10:13:26 2015 +0000

    SLING-5354 - Thread Pool max-thread-age config not taken into account
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1718289 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
index 120c8da..cb77b2a 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
@@ -99,7 +99,7 @@ public class DefaultThreadPoolManager
             config.setQueueSize((Integer)props.get(ModifiableThreadPoolConfig.PROPERTY_QUEUE_SIZE));
         }
         if ( props.get(ModifiableThreadPoolConfig.PROPERTY_MAX_THREAD_AGE) != null ) {
-            config.setQueueSize((Integer)props.get(ModifiableThreadPoolConfig.PROPERTY_MAX_THREAD_AGE));
+            config.setMaxThreadAge((Long) props.get(ModifiableThreadPoolConfig.PROPERTY_MAX_THREAD_AGE));
         }
         if ( props.get(ModifiableThreadPoolConfig.PROPERTY_KEEP_ALIVE_TIME) != null ) {
             config.setKeepAliveTime((Long)props.get(ModifiableThreadPoolConfig.PROPERTY_KEEP_ALIVE_TIME));

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-threads] 08/09: [maven-release-plugin] prepare release org.apache.sling.commons.threads-3.2.4

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit a419119c4ad0ece42b2e8cf1a46e7c9e8d35f292
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Dec 30 14:53:28 2015 +0000

    [maven-release-plugin] prepare release org.apache.sling.commons.threads-3.2.4
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1722342 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index d0f87e6..efc01ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
 
     <artifactId>org.apache.sling.commons.threads</artifactId>
     <packaging>bundle</packaging>
-    <version>3.2.3-SNAPSHOT</version>
+    <version>3.2.4</version>
 
     <name>Apache Sling Thread Support</name>
     <description>
@@ -37,9 +37,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/threads</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.threads-3.2.4</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.threads-3.2.4</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.threads-3.2.4</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-threads] 04/09: SLING-5343 - Meaningful thread names

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit 70b7d251b5a89da39cee5128cb7fb14475fe984e
Author: Julian Sedding <js...@apache.org>
AuthorDate: Tue Dec 1 14:55:29 2015 +0000

    SLING-5343 - Meaningful thread names
    
    - add missing license header
    
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1717441 13f79535-47bb-0310-9956-ffa450edef68
---
 .../commons/threads/impl/ExtendedThreadFactoryTest.java  | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java b/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
index 7240d2d..7ebd5f0 100644
--- a/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
+++ b/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
@@ -1,3 +1,19 @@
+/*
+ * 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.commons.threads.impl;
 
 import org.apache.sling.commons.threads.ThreadPoolConfig;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-threads] 09/09: [maven-release-plugin] copy for tag org.apache.sling.commons.threads-3.2.4

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit e6dae18df7a549a78bfd476115a45861f9f6e783
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Dec 30 14:53:42 2015 +0000

    [maven-release-plugin] copy for tag org.apache.sling.commons.threads-3.2.4
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.threads-3.2.4@1722343 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-threads] 02/09: SLING-5343 - Meaningful thread names

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit db21f6fba23a3f9637ba4f1ac70711d59018b618
Author: Julian Sedding <js...@apache.org>
AuthorDate: Tue Dec 1 13:14:37 2015 +0000

    SLING-5343 - Meaningful thread names
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1717424 13f79535-47bb-0310-9956-ffa450edef68
---
 .../commons/threads/impl/DefaultThreadPool.java    |  7 ++-
 .../threads/impl/ExtendedThreadFactory.java        | 64 ++++++++++++++++------
 .../threads/impl/ExtendedThreadFactoryTest.java    | 47 ++++++++++++++++
 3 files changed, 100 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
index 4f5a1a2..e822bb8 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
@@ -91,7 +91,12 @@ public class DefaultThreadPool
         }
 
         // Set priority and daemon flag
-        final ExtendedThreadFactory threadFactory = new ExtendedThreadFactory(delegateThreadFactory, this.configuration.getPriority(), this.configuration.isDaemon());
+        final ExtendedThreadFactory threadFactory = new ExtendedThreadFactory(
+                delegateThreadFactory,
+                this.name,
+                this.configuration.getPriority(),
+                this.configuration.isDaemon()
+        );
 
         // Keep alive time
         if (this.configuration.getKeepAliveTime() < 0) {
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java b/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
index 87bb6a1..c587d20 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
@@ -17,6 +17,7 @@
 package org.apache.sling.commons.threads.impl;
 
 import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.sling.commons.threads.ThreadPoolConfig;
 
@@ -28,40 +29,55 @@ import org.apache.sling.commons.threads.ThreadPoolConfig;
  */
 public final class ExtendedThreadFactory implements ThreadFactory {
 
-    /** The daemon mode */
-    private final boolean isDaemon;
+    /** Template for thread names, for use with String#format() */
+    private static final String THREAD_NAME_TEMPLATE = "Sling - %s #%d";
+
+    /** The real factory. */
+    private final ThreadFactory factory;
+
+    /** The name of the thread pool */
+    private final String name;
 
     /** The priority of newly created Threads */
     private final int priority;
 
-    /** The real factory. */
-    private final ThreadFactory factory;
+    /** The daemon mode */
+    private final boolean isDaemon;
+
+    /** Thread counter for use in thread name */
+    private final AtomicInteger threadCounter;
 
     /**
      * Create a new wrapper for a thread factory handling the
      *
+     * @param name The name of the thread pool.
      * @param priority A non null value.
      * @param isDaemon Whether new {@link Thread}s should run as daemons.
      */
     public ExtendedThreadFactory(final ThreadFactory factory,
-                                final ThreadPoolConfig.ThreadPriority priority,
-                                final boolean isDaemon) {
+                                 final String name,
+                                 final ThreadPoolConfig.ThreadPriority priority,
+                                 final boolean isDaemon) {
+        this.factory = factory;
+        this.name = stripPrefixes(name, "Apache Sling ", "Sling ");
+        this.priority = convertPriority(priority);
         this.isDaemon = isDaemon;
-        if ( priority == null ) {
+        this.threadCounter = new AtomicInteger(1);
+    }
+
+    private int convertPriority(final ThreadPoolConfig.ThreadPriority priority) {
+        if (priority == null) {
             throw new IllegalStateException("Prioriy must not be null.");
         }
-        switch ( priority ) {
-            case NORM : this.priority = Thread.NORM_PRIORITY;
-                        break;
-            case MIN  : this.priority = Thread.MIN_PRIORITY;
-                        break;
-            case MAX  : this.priority = Thread.MAX_PRIORITY;
-                        break;
+        switch (priority) {
+            case MIN  :
+                return Thread.MIN_PRIORITY;
+            case MAX  :
+                return Thread.MAX_PRIORITY;
+            case NORM :
             default: // this can never happen
-                        this.priority = Thread.NORM_PRIORITY;
-                        break;
+                return Thread.NORM_PRIORITY;
         }
-        this.factory = factory;
     }
 
     /**
@@ -70,9 +86,23 @@ public final class ExtendedThreadFactory implements ThreadFactory {
      */
     public Thread newThread( final Runnable command ) {
         final Thread thread = this.factory.newThread(command);
+        thread.setName(nextThreadName());
         thread.setPriority( this.priority );
         thread.setDaemon( this.isDaemon );
 
         return thread;
     }
+
+    private String nextThreadName() {
+        return String.format(THREAD_NAME_TEMPLATE, this.name, this.threadCounter.getAndIncrement());
+    }
+
+    private static String stripPrefixes(final String name, final String... prefixes) {
+        for (final String prefix : prefixes) {
+            if (name.startsWith(prefix)) {
+                return name.substring(prefix.length());
+            }
+        }
+        return name;
+    }
 }
diff --git a/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java b/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
new file mode 100644
index 0000000..ecdc03b
--- /dev/null
+++ b/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
@@ -0,0 +1,47 @@
+package org.apache.sling.commons.threads.impl;
+
+import org.apache.sling.commons.threads.ThreadPoolConfig;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.Executors;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExtendedThreadFactoryTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ExtendedThreadFactoryTest.class);
+
+    @Test
+    public void informativeThreadNames() {
+        final ExtendedThreadFactory tf = createExtendedThreadFactory("Test Pool");
+        assertEquals("Thread name", "Sling - Test Pool #1", tf.newThread(null).getName());
+        assertEquals("Thread name", "Sling - Test Pool #2", tf.newThread(null).getName());
+    }
+
+    @Test
+    public void shouldStripSlingPrefixFromThreadNames() {
+        final Thread thread = getFirstThreadFromNamedPool("Sling Test Pool");
+        assertEquals("Thread name", "Sling - Test Pool #1", thread.getName());
+    }
+
+    @Test
+    public void shouldStripApacheSlingPrefixFromThreadNames() {
+        final Thread thread = getFirstThreadFromNamedPool("Apache Sling Test Pool");
+        assertEquals("Thread name", "Sling - Test Pool #1", thread.getName());
+    }
+
+    private Thread getFirstThreadFromNamedPool(final String poolName) {
+        return createExtendedThreadFactory(poolName).newThread(null);
+    }
+
+    private ExtendedThreadFactory createExtendedThreadFactory(final String poolName) {
+        return new ExtendedThreadFactory(
+                Executors.defaultThreadFactory(),
+                poolName,
+                ThreadPoolConfig.ThreadPriority.NORM,
+                false
+        );
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-threads] 05/09: SLING-5354 - Thread Pool max-thread-age config not taken into account

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit df522dde59130347c4b605c22cb83b10d3cb705f
Author: Julian Sedding <js...@apache.org>
AuthorDate: Mon Dec 7 09:40:26 2015 +0000

    SLING-5354 - Thread Pool max-thread-age config not taken into account
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1718266 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/commons/threads/impl/DefaultThreadPoolManager.java    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
index 024b2e6..120c8da 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
@@ -98,6 +98,9 @@ public class DefaultThreadPoolManager
         if ( props.get(ModifiableThreadPoolConfig.PROPERTY_QUEUE_SIZE) != null ) {
             config.setQueueSize((Integer)props.get(ModifiableThreadPoolConfig.PROPERTY_QUEUE_SIZE));
         }
+        if ( props.get(ModifiableThreadPoolConfig.PROPERTY_MAX_THREAD_AGE) != null ) {
+            config.setQueueSize((Integer)props.get(ModifiableThreadPoolConfig.PROPERTY_MAX_THREAD_AGE));
+        }
         if ( props.get(ModifiableThreadPoolConfig.PROPERTY_KEEP_ALIVE_TIME) != null ) {
             config.setKeepAliveTime((Long)props.get(ModifiableThreadPoolConfig.PROPERTY_KEEP_ALIVE_TIME));
         }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-threads] 03/09: SLING-5343 - Meaningful thread names

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit 683f952c98e958d477c92624dd4557e1f36cdd5f
Author: Julian Sedding <js...@apache.org>
AuthorDate: Tue Dec 1 14:38:54 2015 +0000

    SLING-5343 - Meaningful thread names
    
    - additional tests for ExtendedThreadFactory
    
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1717440 13f79535-47bb-0310-9956-ffa450edef68
---
 .../threads/impl/ExtendedThreadFactoryTest.java    | 53 +++++++++++++++-------
 1 file changed, 37 insertions(+), 16 deletions(-)

diff --git a/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java b/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
index ecdc03b..7240d2d 100644
--- a/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
+++ b/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
@@ -2,46 +2,67 @@ package org.apache.sling.commons.threads.impl;
 
 import org.apache.sling.commons.threads.ThreadPoolConfig;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.util.concurrent.Executors;
 
+import static org.apache.sling.commons.threads.ThreadPoolConfig.ThreadPriority.MAX;
+import static org.apache.sling.commons.threads.ThreadPoolConfig.ThreadPriority.MIN;
+import static org.apache.sling.commons.threads.ThreadPoolConfig.ThreadPriority.NORM;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 public class ExtendedThreadFactoryTest {
 
-    private static final Logger LOG = LoggerFactory.getLogger(ExtendedThreadFactoryTest.class);
-
     @Test
     public void informativeThreadNames() {
-        final ExtendedThreadFactory tf = createExtendedThreadFactory("Test Pool");
+        final ExtendedThreadFactory tf = factory("Test Pool");
         assertEquals("Thread name", "Sling - Test Pool #1", tf.newThread(null).getName());
         assertEquals("Thread name", "Sling - Test Pool #2", tf.newThread(null).getName());
     }
 
     @Test
     public void shouldStripSlingPrefixFromThreadNames() {
-        final Thread thread = getFirstThreadFromNamedPool("Sling Test Pool");
+        final Thread thread = thread("Sling Test Pool");
         assertEquals("Thread name", "Sling - Test Pool #1", thread.getName());
     }
 
     @Test
     public void shouldStripApacheSlingPrefixFromThreadNames() {
-        final Thread thread = getFirstThreadFromNamedPool("Apache Sling Test Pool");
+        final Thread thread = thread("Apache Sling Test Pool");
         assertEquals("Thread name", "Sling - Test Pool #1", thread.getName());
     }
 
-    private Thread getFirstThreadFromNamedPool(final String poolName) {
-        return createExtendedThreadFactory(poolName).newThread(null);
+    @Test
+    public void shouldSetCorrectPriority() {
+        assertEquals("Thread min priority", Thread.MIN_PRIORITY, thread("Pool", MIN, false).getPriority());
+        assertEquals("Thread normnal priority", Thread.NORM_PRIORITY, thread("Pool", NORM, false).getPriority());
+        assertEquals("Thread max priority", Thread.MAX_PRIORITY, thread("Pool", MAX, false).getPriority());
+    }
+
+    @Test
+    public void shouldSetDaemonStatusCorrectly() {
+        assertFalse("Non-daemon thread", thread("Pool", NORM, false).isDaemon());
+        assertTrue("Daemon thread", thread("Pool", NORM, true).isDaemon());
+    }
+
+    private Thread thread(final String poolName) {
+        return factory(poolName).newThread(null);
+    }
+
+    private Thread thread(final String poolName,
+                          final ThreadPoolConfig.ThreadPriority priority,
+                          final boolean isDaemon) {
+        return factory(poolName, priority, isDaemon).newThread(null);
+    }
+
+    private ExtendedThreadFactory factory(final String poolName) {
+        return factory(poolName, NORM, false);
     }
 
-    private ExtendedThreadFactory createExtendedThreadFactory(final String poolName) {
-        return new ExtendedThreadFactory(
-                Executors.defaultThreadFactory(),
-                poolName,
-                ThreadPoolConfig.ThreadPriority.NORM,
-                false
-        );
+    private ExtendedThreadFactory factory(final String poolName,
+                                          final ThreadPoolConfig.ThreadPriority priority,
+                                          final boolean isDaemon) {
+        return new ExtendedThreadFactory(Executors.defaultThreadFactory(), poolName, priority, isDaemon);
     }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-threads] 06/09: SLING-5343 - Meaningful thread names

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

rombert pushed a commit to annotated tag org.apache.sling.commons.threads-3.2.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git

commit 6935268684b0586bbfd55c1568492c1482cf994a
Author: Julian Sedding <js...@apache.org>
AuthorDate: Mon Dec 7 09:53:29 2015 +0000

    SLING-5343 - Meaningful thread names
    
    - change thread name format due to mailing list discussions
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/threads@1718272 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/commons/threads/impl/ExtendedThreadFactory.java      | 10 ++++++++--
 .../sling/commons/threads/impl/ExtendedThreadFactoryTest.java  |  8 ++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java b/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
index c587d20..15dfedd 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.commons.threads.impl;
 
+import java.util.Locale;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -30,7 +31,7 @@ import org.apache.sling.commons.threads.ThreadPoolConfig;
 public final class ExtendedThreadFactory implements ThreadFactory {
 
     /** Template for thread names, for use with String#format() */
-    private static final String THREAD_NAME_TEMPLATE = "Sling - %s #%d";
+    private static final String THREAD_NAME_TEMPLATE = "sling-%s-%d";
 
     /** The real factory. */
     private final ThreadFactory factory;
@@ -59,12 +60,17 @@ public final class ExtendedThreadFactory implements ThreadFactory {
                                  final ThreadPoolConfig.ThreadPriority priority,
                                  final boolean isDaemon) {
         this.factory = factory;
-        this.name = stripPrefixes(name, "Apache Sling ", "Sling ");
+        this.name = normalizeName(name);
         this.priority = convertPriority(priority);
         this.isDaemon = isDaemon;
         this.threadCounter = new AtomicInteger(1);
     }
 
+    private String normalizeName(final String name) {
+        final String n = name.toLowerCase(Locale.ENGLISH).replaceAll("\\s+", "-");
+        return stripPrefixes(n, "apache-sling-", "sling-");
+    }
+
     private int convertPriority(final ThreadPoolConfig.ThreadPriority priority) {
         if (priority == null) {
             throw new IllegalStateException("Prioriy must not be null.");
diff --git a/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java b/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
index 7ebd5f0..4c80d93 100644
--- a/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
+++ b/src/test/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactoryTest.java
@@ -33,20 +33,20 @@ public class ExtendedThreadFactoryTest {
     @Test
     public void informativeThreadNames() {
         final ExtendedThreadFactory tf = factory("Test Pool");
-        assertEquals("Thread name", "Sling - Test Pool #1", tf.newThread(null).getName());
-        assertEquals("Thread name", "Sling - Test Pool #2", tf.newThread(null).getName());
+        assertEquals("Thread name", "sling-test-pool-1", tf.newThread(null).getName());
+        assertEquals("Thread name", "sling-test-pool-2", tf.newThread(null).getName());
     }
 
     @Test
     public void shouldStripSlingPrefixFromThreadNames() {
         final Thread thread = thread("Sling Test Pool");
-        assertEquals("Thread name", "Sling - Test Pool #1", thread.getName());
+        assertEquals("Thread name", "sling-test-pool-1", thread.getName());
     }
 
     @Test
     public void shouldStripApacheSlingPrefixFromThreadNames() {
         final Thread thread = thread("Apache Sling Test Pool");
-        assertEquals("Thread name", "Sling - Test Pool #1", thread.getName());
+        assertEquals("Thread name", "sling-test-pool-1", thread.getName());
     }
 
     @Test

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.