Skip to content

Commit 789806f

Browse files
authored
Add usage indicators for the bundled JDK (#40616)
This commit adds indications whether or not a distribution is from the bundled JDK, and whether or not we are using the bundled JDK.
1 parent a99435d commit 789806f

File tree

12 files changed

+107
-34
lines changed

12 files changed

+107
-34
lines changed

distribution/archives/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla
5454
into('config') {
5555
dirMode 0750
5656
fileMode 0660
57-
with configFiles(distributionType, oss)
57+
with configFiles(distributionType, oss, jdk)
5858
}
5959
into('bin') {
60-
with binFiles(distributionType, oss)
60+
with binFiles(distributionType, oss, jdk)
6161
}
6262
if (jdk) {
6363
into('jdk') {

distribution/build.gradle

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
321321
from project(':distribution').buildTransportModules
322322
}
323323

324-
configFiles = { distributionType, oss ->
324+
configFiles = { distributionType, oss, jdk ->
325325
copySpec {
326326
with copySpec {
327327
// main config files, processed with distribution specific substitutions
328328
from '../src/config'
329329
exclude 'log4j2.properties' // this is handled separately below
330-
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss))
330+
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss, jdk))
331331
}
332332
if (oss) {
333333
from project(':distribution').buildOssLog4jConfig
@@ -339,23 +339,23 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
339339
}
340340
}
341341

342-
binFiles = { distributionType, oss ->
342+
binFiles = { distributionType, oss, jdk ->
343343
copySpec {
344344
// non-windows files, for all distributions
345345
with copySpec {
346346
from '../src/bin'
347347
exclude '*.exe'
348348
exclude '*.bat'
349349
eachFile { it.setMode(0755) }
350-
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss))
350+
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss, jdk))
351351
}
352352
// windows files, only for zip
353353
if (distributionType == 'zip') {
354354
with copySpec {
355355
from '../src/bin'
356356
include '*.bat'
357357
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
358-
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss))
358+
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss, jdk))
359359
}
360360
with copySpec {
361361
from '../src/bin'
@@ -452,7 +452,7 @@ task run(type: RunTask) {
452452
* </dl>
453453
*/
454454
subprojects {
455-
ext.expansionsForDistribution = { distributionType, oss ->
455+
ext.expansionsForDistribution = { distributionType, oss, jdk ->
456456
final String defaultHeapSize = "1g"
457457
final String packagingPathData = "path.data: /var/lib/elasticsearch"
458458
final String pathLogs = "/var/log/elasticsearch"
@@ -545,6 +545,10 @@ subprojects {
545545
'zip': 'zip'
546546
],
547547

548+
'es.bundled_jdk': [
549+
'def': jdk ? 'true' : 'false'
550+
],
551+
548552
'license.name': [
549553
'deb': oss ? 'ASL-2.0' : 'Elastic-License'
550554
],

distribution/packages/build.gradle

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ buildscript {
6161
}
6262
}
6363

64-
void addProcessFilesTask(String type, boolean oss) {
65-
String packagingFiles = "build/packaging/${ oss ? 'oss-' : ''}${type}"
64+
void addProcessFilesTask(String type, boolean oss, boolean jdk) {
65+
String packagingFiles = "build/packaging/${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}"
6666

67-
String taskName = "process${oss ? 'Oss' : ''}${type.capitalize()}Files"
67+
String taskName = "process${oss ? 'Oss' : ''}${jdk ? '' : 'NoJdk'}${type.capitalize()}Files"
6868
task(taskName, type: Copy) {
6969
into packagingFiles
7070

7171
with copySpec {
7272
from 'src/common'
7373
from "src/${type}"
74-
MavenFilteringHack.filter(it, expansionsForDistribution(type, oss))
74+
MavenFilteringHack.filter(it, expansionsForDistribution(type, oss, jdk))
7575
}
7676

7777
into('etc/elasticsearch') {
78-
with configFiles(type, oss)
78+
with configFiles(type, oss, jdk)
7979
}
80-
MavenFilteringHack.filter(it, expansionsForDistribution(type, oss))
80+
MavenFilteringHack.filter(it, expansionsForDistribution(type, oss, jdk))
8181

8282
doLast {
8383
// create empty dirs, we set the permissions when configuring the packages
@@ -91,17 +91,21 @@ void addProcessFilesTask(String type, boolean oss) {
9191
}
9292
}
9393
}
94-
addProcessFilesTask('deb', true)
95-
addProcessFilesTask('deb', false)
96-
addProcessFilesTask('rpm', true)
97-
addProcessFilesTask('rpm', false)
94+
addProcessFilesTask('deb', true, true)
95+
addProcessFilesTask('deb', true, false)
96+
addProcessFilesTask('deb', false, true)
97+
addProcessFilesTask('deb', false, false)
98+
addProcessFilesTask('rpm', true, true)
99+
addProcessFilesTask('rpm', true, false)
100+
addProcessFilesTask('rpm', false, true)
101+
addProcessFilesTask('rpm', false, false)
98102

99103
// Common configuration that is package dependent. This can't go in ospackage
100104
// since we have different templated files that need to be consumed, but the structure
101105
// is the same
102106
Closure commonPackageConfig(String type, boolean oss, boolean jdk) {
103107
return {
104-
dependsOn "process${oss ? 'Oss' : ''}${type.capitalize()}Files"
108+
dependsOn "process${oss ? 'Oss' : ''}${jdk ? '' : 'NoJdk'}${type.capitalize()}Files"
105109
packageName "elasticsearch${oss ? '-oss' : ''}"
106110
arch (type == 'deb' ? 'amd64' : 'X86_64')
107111
// Follow elasticsearch's file naming convention
@@ -110,7 +114,7 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk) {
110114

111115
String prefix = "${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}"
112116
destinationDir = file("${prefix}/build/distributions")
113-
String packagingFiles = "build/packaging/${oss ? 'oss-' : ''}${type}"
117+
String packagingFiles = "build/packaging/${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}"
114118

115119
String scripts = "${packagingFiles}/scripts"
116120
preInstall file("${scripts}/preinst")
@@ -125,7 +129,7 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk) {
125129
// specify it again explicitly for copying common files
126130
into('/usr/share/elasticsearch') {
127131
into('bin') {
128-
with binFiles(type, oss)
132+
with binFiles(type, oss, jdk)
129133
}
130134
from(rootProject.projectDir) {
131135
include 'README.textile'
@@ -202,7 +206,7 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk) {
202206
createDirectoryEntry true
203207
fileType CONFIG | NOREPLACE
204208
}
205-
String envFile = expansionsForDistribution(type, false)['path.env']
209+
String envFile = expansionsForDistribution(type, oss, jdk)['path.env']
206210
configurationFile envFile
207211
into(new File(envFile).getParent()) {
208212
fileType CONFIG | NOREPLACE

distribution/src/bin/elasticsearch

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null;
2929
-Des.path.conf="$ES_PATH_CONF" \
3030
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
3131
-Des.distribution.type="$ES_DISTRIBUTION_TYPE" \
32+
-Des.bundled_jdk="$ES_BUNDLED_JDK" \
3233
-cp "$ES_CLASSPATH" \
3334
org.elasticsearch.bootstrap.Elasticsearch \
3435
"$@"
@@ -40,6 +41,7 @@ else
4041
-Des.path.conf="$ES_PATH_CONF" \
4142
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
4243
-Des.distribution.type="$ES_DISTRIBUTION_TYPE" \
44+
-Des.bundled_jdk="$ES_BUNDLED_JDK" \
4345
-cp "$ES_CLASSPATH" \
4446
org.elasticsearch.bootstrap.Elasticsearch \
4547
"$@" \

distribution/src/bin/elasticsearch-env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ ES_PATH_CONF=`cd "$ES_PATH_CONF"; pwd`
8282

8383
ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor}
8484
ES_DISTRIBUTION_TYPE=${es.distribution.type}
85+
ES_BUNDLED_JDK=${es.bundled_jdk}
8586

8687
if [ -z "$ES_TMPDIR" ]; then
8788
ES_TMPDIR=`"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.TempDirectory`

distribution/src/bin/elasticsearch-env.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ for %%I in ("%ES_PATH_CONF%..") do set ES_PATH_CONF=%%~dpfI
2727

2828
set ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor}
2929
set ES_DISTRIBUTION_TYPE=${es.distribution.type}
30+
set ES_BUNDLED_JDK=${es.bundled_jdk}
3031

3132
cd /d "%ES_HOME%"
3233

distribution/src/bin/elasticsearch-service.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ if "%JVM_SS%" == "" (
167167
goto:eof
168168
)
169169

170-
set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%";-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%";-Des.distribution.type="%ES_DISTRIBUTION_TYPE%"
170+
set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%";-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%";-Des.distribution.type="%ES_DISTRIBUTION_TYPE%";-Des.bundled_jdk="%ES_BUNDLED_JDK%"
171171

172172
if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
173173
if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0

distribution/src/bin/elasticsearch.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if "%MAYBE_JVM_OPTIONS_PARSER_FAILED%" == "jvm_options_parser_failed" (
5050
exit /b 1
5151
)
5252

53-
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!
53+
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" -Des.bundled_jd="%ES_BUNDLED_JDK%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!
5454

5555
endlocal
5656
endlocal

docs/reference/cluster/stats.asciidoc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ Will return, for example:
155155
"max_uptime_in_millis": 13737,
156156
"versions": [
157157
{
158-
"version": "1.8.0_74",
159-
"vm_name": "Java HotSpot(TM) 64-Bit Server VM",
160-
"vm_version": "25.74-b02",
158+
"version": "12",
159+
"vm_name": "OpenJDK 64-Bit Server VM",
160+
"vm_version": "12+33",
161161
"vm_vendor": "Oracle Corporation",
162+
"bundled_jdk": true,
163+
"using_bundled_jdk": true,
162164
"count": 1
163165
}
164166
],
@@ -200,6 +202,7 @@ Will return, for example:
200202
// TESTRESPONSE[s/"plugins": \[[^\]]*\]/"plugins": $body.$_path/]
201203
// TESTRESPONSE[s/"network_types": \{[^\}]*\}/"network_types": $body.$_path/]
202204
// TESTRESPONSE[s/"discovery_types": \{[^\}]*\}/"discovery_types": $body.$_path/]
205+
// TESTRESPONSE[s/: true|false/: $body.$_path/]
203206
// TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
204207
// TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
205208
// These replacements do a few things:

server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ static final class Fields {
502502
static final String VM_NAME = "vm_name";
503503
static final String VM_VERSION = "vm_version";
504504
static final String VM_VENDOR = "vm_vendor";
505+
static final String BUNDLED_JDK = "bundled_jdk";
506+
static final String USING_BUNDLED_JDK = "using_bundled_jdk";
505507
static final String COUNT = "count";
506508
static final String THREADS = "threads";
507509
static final String MAX_UPTIME = "max_uptime";
@@ -524,6 +526,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params)
524526
builder.field(Fields.VM_NAME, v.key.vmName);
525527
builder.field(Fields.VM_VERSION, v.key.vmVersion);
526528
builder.field(Fields.VM_VENDOR, v.key.vmVendor);
529+
builder.field(Fields.BUNDLED_JDK, v.key.bundledJdk);
530+
builder.field(Fields.USING_BUNDLED_JDK, v.key.usingBundledJdk);
527531
builder.field(Fields.COUNT, v.value);
528532
builder.endObject();
529533
}
@@ -543,12 +547,16 @@ public static class JvmVersion {
543547
String vmName;
544548
String vmVersion;
545549
String vmVendor;
550+
boolean bundledJdk;
551+
Boolean usingBundledJdk;
546552

547553
JvmVersion(JvmInfo jvmInfo) {
548554
version = jvmInfo.version();
549555
vmName = jvmInfo.getVmName();
550556
vmVersion = jvmInfo.getVmVersion();
551557
vmVendor = jvmInfo.getVmVendor();
558+
bundledJdk = jvmInfo.getBundledJdk();
559+
usingBundledJdk = jvmInfo.getUsingBundledJdk();
552560
}
553561

554562
@Override

0 commit comments

Comments
 (0)