forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Java 17 support and Java runtime docs. (apache#12839)
* Improved Java 17 support and Java runtime docs. 1) Add a "Java runtime" doc page with information about supported Java versions, garbage collection, and strong encapsulation.. 2) Update asm and equalsverifier to versions that support Java 17. 3) Add additional "--add-opens" lines to surefire configuration, so tests can pass successfully under Java 17. 4) Switch openjdk15 tests to openjdk17. 5) Update FrameFile to specifically mention Java runtime incompatibility as the cause of not being able to use Memory.map. 6) Update SegmentLoadDropHandler to log an error for Errors too, not just Exceptions. This is important because an IllegalAccessError is encountered when the correct "--add-opens" line is not provided, which would otherwise be silently ignored. 7) Update example configs to use druid.indexer.runner.javaOptsArray instead of druid.indexer.runner.javaOpts. (The latter is deprecated.) * Adjustments. * Use run-java in more places. * Add run-java. * Update .gitignore. * Exclude hadoop-client-api. Brought in when building on Java 17. * Swap one more usage of java. * Fix the run-java script. * Fix flag. * Include link to Temurin. * Spelling. * Update examples/bin/run-java Co-authored-by: Xavier Léauté <[email protected]> Co-authored-by: Xavier Léauté <[email protected]>
- Loading branch information
Showing
32 changed files
with
319 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ README | |
.pmdruleset.xml | ||
.java-version | ||
integration-tests/gen-scripts/ | ||
bin/ | ||
/bin/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
id: java | ||
title: "Java runtime" | ||
--- | ||
|
||
<!-- | ||
~ 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. | ||
--> | ||
|
||
Apache Druid is written in Java and requires a Java runtime. This page provides details about obtaining and configuring | ||
a Java runtime for Druid. | ||
|
||
## Selecting a Java runtime | ||
|
||
Druid fully supports Java 8 and 11. The project team recommends Java 11. The project team does not recommend running | ||
with Java 17, because certain Druid functionality is not currently compatible with Java 17. | ||
|
||
The project team recommends using an OpenJDK-based Java distribution. There are many free and actively-supported | ||
distributions available, including | ||
[Amazon Corretto](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/what-is-corretto-11.html), | ||
[Azul Zulu](https://www.azul.com/downloads/?version=java-11-lts&package=jdk), and | ||
[Eclipse Temurin](https://adoptium.net/temurin/releases?version=11). | ||
The project team does not recommend any specific distribution over any other. | ||
|
||
Druid relies on the environment variables `JAVA_HOME` or `DRUID_JAVA_HOME` to find Java on the machine. You can set | ||
`DRUID_JAVA_HOME` if there is more than one instance of Java. To verify Java requirements for your environment, run the | ||
`bin/verify-java` script. | ||
|
||
## Garbage collection | ||
|
||
In general, the project team recommends using the G1 collector with default settings. This is the default collector in | ||
Java 11. To enable G1 on Java 8, use `-XX:+UseG1GC`. There is no harm in explicitly specifying this on Java 11 as well. | ||
|
||
Garbage collector selection and tuning is a form of sport in the Java community. There may be situations where adjusting | ||
garbage collection configuration improves or worsens performance. The project team's guidance is that most people do | ||
not need to stray away from G1 with default settings. | ||
|
||
## Strong encapsulation | ||
|
||
Java 9 and beyond (including Java 11) include the capability for | ||
[strong encapsulation](https://dev.java/learn/strong-encapsulation-\(of-jdk-internals\)/) of internal JDK APIs. Druid | ||
uses certain internal JDK APIs for functionality- and performance-related reasons. In Java 11, this leads to log | ||
messages like the following: | ||
|
||
``` | ||
WARNING: An illegal reflective access operation has occurred | ||
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations | ||
WARNING: All illegal access operations will be denied in a future release | ||
``` | ||
|
||
These warning messages are harmless, and can be ignored. However, you can avoid them entirely if you wish by adding the | ||
following Java command line parameters. These parameters are not part of the default configurations that ship with | ||
Druid, because Java 8 does not recognize these parameters and fails to start up if they are provided. | ||
|
||
To do this, add the following lines to your `jvm.config` files: | ||
|
||
``` | ||
--add-exports=java.base/jdk.internal.perf=ALL-UNNAMED | ||
--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED | ||
--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED | ||
--add-opens=java.base/java.lang=ALL-UNNAMED | ||
--add-opens=java.base/java.io=ALL-UNNAMED | ||
--add-opens=java.base/java.nio=ALL-UNNAMED | ||
--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED | ||
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED | ||
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED | ||
``` | ||
|
||
Additionally, tasks run by [MiddleManagers](../design/architecture.md) execute in separate JVMs. The command line for | ||
these JVMs is given by `druid.indexer.runner.javaOptsArray` or `druid.indexer.runner.javaOpts` in | ||
`middleManager/runtime.properties`. Java command line parameters for tasks must be specified here. For example, use | ||
a line like the following: | ||
|
||
``` | ||
druid.indexer.runner.javaOptsArray=["-server","-Xms1g","-Xmx1g","-XX:MaxDirectMemorySize=1g","-Duser.timezone=UTC","-Dfile.encoding=UTF-8","-XX:+ExitOnOutOfMemoryError","-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager","--add-exports=java.base/jdk.internal.perf=ALL-UNNAMED","--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED","--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED","--add-opens=java.base/java.lang=ALL-UNNAMED","--add-opens=java.base/java.io=ALL-UNNAMED","--add-opens=java.base/java.nio=ALL-UNNAMED","--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED","--add-opens=java.base/sun.nio.ch=ALL-UNNAMED","--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED"] | ||
``` | ||
|
||
The `Xms`, `Xmx`, and `MaxDirectMemorySize` parameters in the line above are merely an example. You may use different | ||
values in your specific environment. |
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
Oops, something went wrong.