-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #10350 - Support Java 21 virtual threads
* Introduced module `threadpool-virtual` for Java 21. * Updated virtual threads documentation to refer to Java 21. * Updated requirements that the releases should use Java 21, so that the documentation can properly render the virtual threads documentation. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
- Loading branch information
Showing
15 changed files
with
184 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ation/src/main/asciidoc/operations-guide/modules/module-threadpool-virtual.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
[[og-module-threadpool-virtual]] | ||
===== Module `threadpool-virtual` | ||
|
||
The `threadpool-virtual` module allows you to configure the server-wide thread pool, similarly to what you can do with the xref:og-module-threadpool[`threadpool`] Jetty module, but also specify to use virtual threads, introduced as an official feature since Java 21. | ||
|
||
CAUTION: Only use this module if you are using Java 21 or later. | ||
If you are using Java 19 or Java 20, use the xref:og-module-threadpool-virtual-preview[`threadpool-virtual-preview`] Jetty module instead. | ||
|
||
Refer to the xref:og-module-threadpool[`threadpool`] Jetty module for the general features provided by that Jetty module that also this Jetty module provides. | ||
|
||
The module properties to configure the thread pool are: | ||
|
||
---- | ||
include::{JETTY_HOME}/modules/threadpool-virtual.mod[tags=documentation] | ||
---- | ||
|
||
The specific properties to configure virtual threads are: | ||
|
||
`jetty.threadPool.virtual.namePrefix`:: | ||
The name prefix to use for the virtual thread names. | ||
|
||
`jetty.threadPool.virtual.inheritInheritableThreadLocals`:: | ||
Whether virtual threads inherit the values of `InheritableThreadLocal` variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
jetty-server/src/main/config/etc/jetty-threadpool-virtual.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd"> | ||
|
||
<Configure> | ||
<New id="threadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool"> | ||
<Set name="name" property="jetty.threadPool.namePrefix" /> | ||
<Set name="minThreads" type="int"><Property name="jetty.threadPool.minThreads" deprecated="threads.min" default="10"/></Set> | ||
<Set name="maxThreads" type="int"><Property name="jetty.threadPool.maxThreads" deprecated="threads.max" default="200"/></Set> | ||
<Set name="reservedThreads" type="int"><Property name="jetty.threadPool.reservedThreads" default="-1"/></Set> | ||
<Set name="idleTimeout" type="int"><Property name="jetty.threadPool.idleTimeout" deprecated="threads.timeout" default="60000"/></Set> | ||
<Set name="maxEvictCount" type="int"><Property name="jetty.threadPool.maxEvictCount" default="1"/></Set> | ||
<Set name="detailedDump" type="boolean"><Property name="jetty.threadPool.detailedDump" default="false"/></Set> | ||
<Get id="namePrefix" name="name" /> | ||
<Call class="java.lang.Thread" name="ofVirtual"> | ||
<Call class="java.lang.Thread$Builder" name="name"> | ||
<Arg> | ||
<Property name="jetty.threadPool.virtual.namePrefix"> | ||
<Default><Ref refid="namePrefix" />-virtual-</Default> | ||
</Property> | ||
</Arg> | ||
<Arg type="long">0</Arg> | ||
<Call class="java.lang.Thread$Builder" name="inheritInheritableThreadLocals"> | ||
<Arg type="boolean"><Property name="jetty.threadPool.virtual.inheritInheritableThreadLocals" default="false" /></Arg> | ||
<Call id="virtualThreadFactory" class="java.lang.Thread$Builder" name="factory" /> | ||
</Call> | ||
</Call> | ||
</Call> | ||
<Call name="setVirtualThreadsExecutor"> | ||
<Arg> | ||
<Call class="java.util.concurrent.Executors" name="newThreadPerTaskExecutor"> | ||
<Arg><Ref refid="virtualThreadFactory" /></Arg> | ||
</Call> | ||
</Arg> | ||
</Call> | ||
</New> | ||
|
||
<Call class="org.slf4j.LoggerFactory" name="getLogger"> | ||
<Arg>org.eclipse.jetty</Arg> | ||
<Call name="info"> | ||
<Arg>Virtual threads are enabled.</Arg> | ||
</Call> | ||
</Call> | ||
</Configure> |
2 changes: 1 addition & 1 deletion
2
jetty-server/src/main/config/modules/threadpool-virtual-preview.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
jetty-server/src/main/config/modules/threadpool-virtual.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[description] | ||
Enables and configures the Server ThreadPool with support for virtual threads in Java 21 or later. | ||
|
||
[depends] | ||
logging | ||
|
||
[provides] | ||
threadpool | ||
|
||
[xml] | ||
etc/jetty-threadpool-virtual.xml | ||
|
||
[ini-template] | ||
# tag::documentation[] | ||
## Platform threads name prefix. | ||
#jetty.threadPool.namePrefix=qtp<hashCode> | ||
|
||
## Minimum number of pooled threads. | ||
#jetty.threadPool.minThreads=10 | ||
|
||
## Maximum number of pooled threads. | ||
#jetty.threadPool.maxThreads=200 | ||
|
||
## Number of reserved threads (-1 for heuristic). | ||
#jetty.threadPool.reservedThreads=-1 | ||
|
||
## Thread idle timeout (in milliseconds). | ||
#jetty.threadPool.idleTimeout=60000 | ||
|
||
## The max number of idle threads that can be evicted in one idleTimeout period. | ||
#jetty.threadPool.maxEvictCount=1 | ||
|
||
## Whether to output a detailed dump. | ||
#jetty.threadPool.detailedDump=false | ||
|
||
## Virtual threads name prefix. | ||
#jetty.threadPool.virtual.namePrefix=qtp<hashCode>-virtual- | ||
|
||
## Whether virtual threads inherits the values of inheritable thread locals. | ||
#jetty.threadPool.virtual.inheritInheritableThreadLocals=true | ||
# end::documentation[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters