[cxf] branch master updated: [CXF-8306]be able to configure http-undertow worker|threadpool name

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[cxf] branch master updated: [CXF-8306]be able to configure http-undertow worker|threadpool name

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

ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new b87a6ab  [CXF-8306]be able to configure http-undertow worker|threadpool name
b87a6ab is described below

commit b87a6ab32f0975bcae554bc2215efdca69aa0213
Author: Freeman Fang <[hidden email]>
AuthorDate: Tue Jun 23 12:16:25 2020 -0400

    [CXF-8306]be able to configure http-undertow worker|threadpool name
---
 .../cxf/transport/http_undertow/ThreadingParameters.java  | 15 +++++++++++++++
 .../transport/http_undertow/UndertowHTTPServerEngine.java |  5 +++++
 .../blueprint/UndertowHTTPServerEngineFactoryHolder.java  |  3 +++
 .../osgi/HTTPUndertowTransportActivator.java              |  2 ++
 .../UndertowHTTPServerEngineBeanDefinitionParser.java     |  3 +++
 .../http_undertow/spring/UndertowSpringTypesFactory.java  |  1 +
 .../resources/schemas/configuration/http-undertow.xsd     |  5 +++++
 7 files changed, 34 insertions(+)

diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/ThreadingParameters.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/ThreadingParameters.java
index 995c845..8f41878 100644
--- a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/ThreadingParameters.java
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/ThreadingParameters.java
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.transport.http_undertow;
 
+import org.apache.cxf.common.util.StringUtils;
+
 public class ThreadingParameters {
     /**
      * Specify the number of I/O threads to create for the worker.  If not specified, a default will be chosen.
@@ -39,6 +41,7 @@ public class ThreadingParameters {
     private boolean workerIOThreadsSet;
     private boolean minThreadsSet;
     private boolean maxThreadsSet;
+    private String workerIOName;
 
     public void setWorkerIOThreads(int number) {
         workerIOThreadsSet = true;
@@ -54,6 +57,10 @@ public class ThreadingParameters {
         maxThreadsSet = true;
         maxThreads = number;
     }
+    
+    public void setWorkerIOName(String workerIOName) {
+        this.workerIOName = workerIOName;
+    }
 
     public int getWorkerIOThreads() {
         return workerIOThreads;
@@ -66,6 +73,10 @@ public class ThreadingParameters {
     public int getMaxThreads() {
         return maxThreads;
     }
+    
+    public String getWorkerIOName() {
+        return workerIOName;
+    }
 
     public boolean isWorkerIOThreadsSet() {
         return workerIOThreadsSet;
@@ -80,5 +91,9 @@ public class ThreadingParameters {
     public boolean isMaxThreadsSet() {
         return maxThreadsSet;
     }
+    
+    public boolean isWorkerIONameSet() {
+        return !StringUtils.isEmpty(this.workerIOName);
+    }
 
 }
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngine.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngine.java
index c697f9d..76b4f77 100644
--- a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngine.java
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngine.java
@@ -245,7 +245,12 @@ public class UndertowHTTPServerEngine implements ServerEngine {
                 builder = builder.setWorkerOption(Options.WORKER_TASK_MAX_THREADS,
                               this.threadingParameters.getMaxThreads());
             }
+            if (this.threadingParameters.isWorkerIONameSet()) {
+                builder = builder.setWorkerOption(Options.WORKER_NAME,
+                              this.threadingParameters.getWorkerIOName());
+            }
         }
+        
         return builder;
     }
 
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowHTTPServerEngineFactoryHolder.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowHTTPServerEngineFactoryHolder.java
index 612dd51..2d73cb6 100644
--- a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowHTTPServerEngineFactoryHolder.java
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/blueprint/UndertowHTTPServerEngineFactoryHolder.java
@@ -91,6 +91,9 @@ public class UndertowHTTPServerEngineFactoryHolder {
                     if (threads.getThreadingParameters().getMinThreads() != null) {
                         rThreads.setMinThreads(threads.getThreadingParameters().getMinThreads());
                     }
+                    if (threads.getThreadingParameters().getWorkerIOName() != null) {
+                        rThreads.setWorkerIOName(threads.getThreadingParameters().getWorkerIOName());
+                    }
                     rThreads.setWorkerIOThreads(threads.getThreadingParameters().getWorkerIOThreads());
                     threadingParametersMap.put(id, rThreads);
                 }
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/osgi/HTTPUndertowTransportActivator.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/osgi/HTTPUndertowTransportActivator.java
index c041abb..a11f21c 100644
--- a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/osgi/HTTPUndertowTransportActivator.java
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/osgi/HTTPUndertowTransportActivator.java
@@ -161,6 +161,8 @@ public class HTTPUndertowTransportActivator
                     p.setMaxThreads(Integer.parseInt(v));
                 } else if ("workerIOThreads".equals(k)) {
                     p.setWorkerIOThreads(Integer.parseInt(v));
+                } else if ("workerIOName".equals(k)) {
+                    p.setWorkerIOName(v);
                 }
             }
         }
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineBeanDefinitionParser.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineBeanDefinitionParser.java
index 24f41f6..5d0ad70 100644
--- a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineBeanDefinitionParser.java
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowHTTPServerEngineBeanDefinitionParser.java
@@ -224,6 +224,9 @@ public class UndertowHTTPServerEngineBeanDefinitionParser extends AbstractBeanDe
         if (paramtype.getWorkerIOThreads() != null) {
             params.setWorkerIOThreads(paramtype.getWorkerIOThreads());
         }
+        if (paramtype.getWorkerIOName() != null) {
+            params.setWorkerIOName(paramtype.getWorkerIOName());
+        }
 
         return params;
     }
diff --git a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowSpringTypesFactory.java b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowSpringTypesFactory.java
index 081eeab..5502737 100644
--- a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowSpringTypesFactory.java
+++ b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/spring/UndertowSpringTypesFactory.java
@@ -62,6 +62,7 @@ public final class UndertowSpringTypesFactory {
         ThreadingParameters params = new ThreadingParameters();
         params.setMaxThreads(paramtype.getMaxThreads());
         params.setMinThreads(paramtype.getMinThreads());
+        params.setWorkerIOName(paramtype.getWorkerIOName());
         params.setWorkerIOThreads(paramtype.getWorkerIOThreads());
         return params;
     }
diff --git a/rt/transports/http-undertow/src/main/resources/schemas/configuration/http-undertow.xsd b/rt/transports/http-undertow/src/main/resources/schemas/configuration/http-undertow.xsd
index d6b677f..9625750 100644
--- a/rt/transports/http-undertow/src/main/resources/schemas/configuration/http-undertow.xsd
+++ b/rt/transports/http-undertow/src/main/resources/schemas/configuration/http-undertow.xsd
@@ -57,6 +57,11 @@
              <xs:documentation>Specify the number of I/O threads to create for the worker.  If not specified, a default will be chosen. One IO thread per CPU core is a reasonable default.</xs:documentation>
           </xs:annotation>
        </xs:attribute>
+       <xs:attribute name="workerIOName" type="xs:string">
+       <xs:annotation>
+             <xs:documentation>Specify the name for the worker.  If not specified, the default "XNIO-1" will be chosen.</xs:documentation>
+          </xs:annotation>
+       </xs:attribute>
     </xs:complexType>
     
     <xs:complexType name="ThreadingParametersIdentifiedType">