Skip to content

Commit 2d372cd

Browse files
Merge remote-tracking branch 'elastic/master' into 20398
2 parents b7b0635 + 6f2b7dc commit 2d372cd

File tree

940 files changed

+35393
-12135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

940 files changed

+35393
-12135
lines changed

Vagrantfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ Vagrant.configure(2) do |config|
115115
'opensuse-42'.tap do |box|
116116
config.vm.define box, define_opts do |config|
117117
config.vm.box = 'elastic/opensuse-42-x86_64'
118+
119+
# https://github.com/elastic/elasticsearch/issues/30295
120+
config.vm.provider 'virtualbox' do |vbox|
121+
vbox.customize ['storagectl', :id, '--name', 'SATA Controller', '--hostiocache', 'on']
122+
end
118123
suse_common config, box
119124
end
120125
end

benchmarks/build.gradle

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@
1717
* under the License.
1818
*/
1919

20-
buildscript {
21-
repositories {
22-
maven {
23-
url 'https://plugins.gradle.org/m2/'
24-
}
25-
}
26-
dependencies {
27-
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
28-
}
29-
}
30-
3120
apply plugin: 'elasticsearch.build'
3221

3322
// order of this section matters, see: https://github.com/johnrengelman/shadow/issues/336
@@ -81,10 +70,6 @@ thirdPartyAudit.excludes = [
8170
'org.openjdk.jmh.util.Utils'
8271
]
8372

84-
shadowJar {
85-
classifier = 'benchmarks'
86-
}
87-
8873
runShadow {
8974
executable = new File(project.runtimeJavaHome, 'bin/java')
9075
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.elasticsearch.benchmark.indices.breaker;
20+
21+
import org.openjdk.jmh.annotations.Benchmark;
22+
import org.openjdk.jmh.annotations.BenchmarkMode;
23+
import org.openjdk.jmh.annotations.Fork;
24+
import org.openjdk.jmh.annotations.Measurement;
25+
import org.openjdk.jmh.annotations.Mode;
26+
import org.openjdk.jmh.annotations.OutputTimeUnit;
27+
import org.openjdk.jmh.annotations.Param;
28+
import org.openjdk.jmh.annotations.Scope;
29+
import org.openjdk.jmh.annotations.State;
30+
import org.openjdk.jmh.annotations.Threads;
31+
import org.openjdk.jmh.annotations.Warmup;
32+
import org.openjdk.jmh.infra.Blackhole;
33+
34+
import java.lang.management.ManagementFactory;
35+
import java.lang.management.MemoryMXBean;
36+
import java.util.concurrent.TimeUnit;
37+
38+
@Fork(3)
39+
@Warmup(iterations = 10)
40+
@Measurement(iterations = 10)
41+
@BenchmarkMode(Mode.AverageTime)
42+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
43+
@State(Scope.Benchmark)
44+
@SuppressWarnings("unused") //invoked by benchmarking framework
45+
public class MemoryStatsBenchmark {
46+
private static final MemoryMXBean MEMORY_MX_BEAN = ManagementFactory.getMemoryMXBean();
47+
48+
@Param({"0", "16", "256", "4096"})
49+
private int tokens;
50+
51+
@Benchmark
52+
public void baseline() {
53+
Blackhole.consumeCPU(tokens);
54+
}
55+
56+
@Benchmark
57+
@Threads(1)
58+
public long getMemoryStats_01() {
59+
Blackhole.consumeCPU(tokens);
60+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
61+
}
62+
63+
@Benchmark
64+
@Threads(2)
65+
public long getMemoryStats_02() {
66+
Blackhole.consumeCPU(tokens);
67+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
68+
}
69+
70+
@Benchmark
71+
@Threads(4)
72+
public long getMemoryStats_04() {
73+
Blackhole.consumeCPU(tokens);
74+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
75+
}
76+
77+
@Benchmark
78+
@Threads(8)
79+
public long getMemoryStats_08() {
80+
Blackhole.consumeCPU(tokens);
81+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
82+
}
83+
84+
@Benchmark
85+
@Threads(16)
86+
public long getMemoryStats_16() {
87+
Blackhole.consumeCPU(tokens);
88+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
89+
}
90+
91+
@Benchmark
92+
@Threads(32)
93+
public long getMemoryStats_32() {
94+
Blackhole.consumeCPU(tokens);
95+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
96+
}
97+
98+
@Benchmark
99+
@Threads(64)
100+
public long getMemoryStats_64() {
101+
Blackhole.consumeCPU(tokens);
102+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
103+
}
104+
}
105+

build.gradle

Lines changed: 78 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
20+
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
2121
import org.apache.tools.ant.taskdefs.condition.Os
2222
import org.apache.tools.ant.filters.ReplaceTokens
2323
import org.elasticsearch.gradle.BuildPlugin
@@ -125,7 +125,10 @@ Map<String, String> buildMetadataMap = buildMetadataValue.tokenize(';').collectE
125125
allprojects {
126126
project.ext {
127127
// for ide hacks...
128-
isEclipse = System.getProperty("eclipse.launcher") != null || gradle.startParameter.taskNames.contains('eclipse') || gradle.startParameter.taskNames.contains('cleanEclipse')
128+
isEclipse = System.getProperty("eclipse.launcher") != null || // Detects gradle launched from Eclipse's IDE
129+
System.getProperty("eclipse.application") != null || // Detects gradle launched from the Eclipse compiler server
130+
gradle.startParameter.taskNames.contains('eclipse') || // Detects gradle launched from the command line to do eclipse stuff
131+
gradle.startParameter.taskNames.contains('cleanEclipse')
129132
isIdea = System.getProperty("idea.active") != null || gradle.startParameter.taskNames.contains('idea') || gradle.startParameter.taskNames.contains('cleanIdea')
130133

131134
// for BWC testing
@@ -170,8 +173,8 @@ task verifyVersions {
170173
* the enabled state of every bwc task. It should be set back to true
171174
* after the backport of the backcompat code is complete.
172175
*/
173-
final boolean bwc_tests_enabled = false
174-
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/29538" /* place a PR link here when committing bwc changes */
176+
final boolean bwc_tests_enabled = true
177+
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
175178
if (bwc_tests_enabled == false) {
176179
if (bwc_tests_disabled_issue.isEmpty()) {
177180
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
@@ -219,7 +222,7 @@ subprojects {
219222
"org.elasticsearch.gradle:build-tools:${version}": ':build-tools',
220223
"org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
221224
"org.elasticsearch:elasticsearch:${version}": ':server',
222-
"org.elasticsearch:elasticsearch-cli:${version}": ':libs:cli',
225+
"org.elasticsearch:elasticsearch-cli:${version}": ':libs:elasticsearch-cli',
223226
"org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
224227
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
225228
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
@@ -300,18 +303,55 @@ subprojects {
300303
if (project.plugins.hasPlugin(BuildPlugin)) {
301304
String artifactsHost = VersionProperties.elasticsearch.isSnapshot() ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
302305
Closure sortClosure = { a, b -> b.group <=> a.group }
303-
Closure depJavadocClosure = { dep ->
304-
if (dep.group != null && dep.group.startsWith('org.elasticsearch')) {
305-
Project upstreamProject = dependencyToProject(dep)
306-
if (upstreamProject != null) {
307-
project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
308-
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
309-
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
306+
Closure depJavadocClosure = { shadowed, dep ->
307+
if (dep.group == null || false == dep.group.startsWith('org.elasticsearch')) {
308+
return
309+
}
310+
Project upstreamProject = dependencyToProject(dep)
311+
if (upstreamProject == null) {
312+
return
313+
}
314+
if (shadowed) {
315+
/*
316+
* Include the source of shadowed upstream projects so we don't
317+
* have to publish their javadoc.
318+
*/
319+
project.evaluationDependsOn(upstreamProject.path)
320+
project.javadoc.source += upstreamProject.javadoc.source
321+
/*
322+
* Do not add those projects to the javadoc classpath because
323+
* we are going to resolve them with their source instead.
324+
*/
325+
project.javadoc.classpath = project.javadoc.classpath.filter { f ->
326+
false == upstreamProject.configurations.archives.artifacts.files.files.contains(f)
310327
}
328+
/*
329+
* Instead we need the upstream project's javadoc classpath so
330+
* we don't barf on the classes that it references.
331+
*/
332+
project.javadoc.classpath += upstreamProject.javadoc.classpath
333+
} else {
334+
// Link to non-shadowed dependant projects
335+
project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
336+
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
337+
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
311338
}
312339
}
313-
project.configurations.compile.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
314-
project.configurations.compileOnly.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
340+
boolean hasShadow = project.plugins.hasPlugin(ShadowPlugin)
341+
project.configurations.compile.dependencies
342+
.findAll()
343+
.toSorted(sortClosure)
344+
.each({ c -> depJavadocClosure(hasShadow, c) })
345+
project.configurations.compileOnly.dependencies
346+
.findAll()
347+
.toSorted(sortClosure)
348+
.each({ c -> depJavadocClosure(hasShadow, c) })
349+
if (hasShadow) {
350+
project.configurations.shadow.dependencies
351+
.findAll()
352+
.toSorted(sortClosure)
353+
.each({ c -> depJavadocClosure(false, c) })
354+
}
315355
}
316356
}
317357
}
@@ -432,6 +472,9 @@ allprojects {
432472
if (isEclipse) {
433473
// set this so generated dirs will be relative to eclipse build
434474
project.buildDir = eclipseBuild
475+
// Work around https://docs.gradle.org/current/userguide/java_gradle_plugin.html confusing Eclipse by the metadata
476+
// it adds to the classpath
477+
project.file("$buildDir/pluginUnderTestMetadata").mkdirs()
435478
}
436479
eclipse.classpath.file.whenMerged { classpath ->
437480
// give each source folder a unique corresponding output folder
@@ -446,7 +489,7 @@ allprojects {
446489

447490
File licenseHeaderFile;
448491
String prefix = ':x-pack';
449-
492+
450493
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
451494
prefix = prefix.replace(':', '_')
452495
}
@@ -455,7 +498,7 @@ allprojects {
455498
} else {
456499
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/oss-license-header.txt')
457500
}
458-
501+
459502
String lineSeparator = Os.isFamily(Os.FAMILY_WINDOWS) ? '\\\\r\\\\n' : '\\\\n'
460503
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace(System.lineSeparator(), lineSeparator)
461504
task copyEclipseSettings(type: Copy) {
@@ -531,6 +574,7 @@ subprojects { project ->
531574
commandLine "${->new File(rootProject.compilerJavaHome, 'bin/jar')}",
532575
'xf', "${-> jarTask.outputs.files.singleFile}", 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'
533576
workingDir destination
577+
onlyIf {jarTask.enabled}
534578
doFirst {
535579
project.delete(destination)
536580
Files.createDirectories(destination)
@@ -539,6 +583,7 @@ subprojects { project ->
539583

540584
final Task checkNotice = project.task("verify${jarTask.name.capitalize()}Notice") {
541585
dependsOn extract
586+
onlyIf {jarTask.enabled}
542587
doLast {
543588
final List<String> noticeLines = Files.readAllLines(project.noticeFile.toPath())
544589
final Path noticePath = extract.destination.resolve('META-INF/NOTICE.txt')
@@ -549,6 +594,7 @@ subprojects { project ->
549594

550595
final Task checkLicense = project.task("verify${jarTask.name.capitalize()}License") {
551596
dependsOn extract
597+
onlyIf {jarTask.enabled}
552598
doLast {
553599
final List<String> licenseLines = Files.readAllLines(project.licenseFile.toPath())
554600
final Path licensePath = extract.destination.resolve('META-INF/LICENSE.txt')
@@ -576,6 +622,21 @@ gradle.projectsEvaluated {
576622
}
577623
}
578624
}
625+
// Having the same group and name for distinct projects causes Gradle to consider them equal when resolving
626+
// dependencies leading to hard to debug failures. Run a check across all project to prevent this from happening.
627+
// see: https://github.com/gradle/gradle/issues/847
628+
Map coordsToProject = [:]
629+
project.allprojects.forEach { p ->
630+
String coords = "${p.group}:${p.name}"
631+
if (false == coordsToProject.putIfAbsent(coords, p)) {
632+
throw new GradleException(
633+
"Detected that two projects: ${p.path} and ${coordsToProject[coords].path} " +
634+
"have the same name and group: ${coords}. " +
635+
"This doesn't currently work correctly in Gradle, see: " +
636+
"https://github.com/gradle/gradle/issues/847"
637+
)
638+
}
639+
}
579640
}
580641

581642
if (System.properties.get("build.compare") != null) {
@@ -590,7 +651,7 @@ if (System.properties.get("build.compare") != null) {
590651
}
591652
}
592653
sourceBuild {
593-
gradleVersion = "4.8.1" // does not default to gradle weapper of project dir, but current version
654+
gradleVersion = gradle.getGradleVersion()
594655
projectDir = referenceProject
595656
tasks = ["clean", "assemble"]
596657
arguments = ["-Dbuild.compare_friendly=true"]

buildSrc/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ dependencies {
104104
compile 'de.thetaphi:forbiddenapis:2.5'
105105
compile 'org.apache.rat:apache-rat:0.11'
106106
compile "org.elasticsearch:jna:4.5.1"
107+
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
107108
testCompile "junit:junit:${props.getProperty('junit')}"
108109
}
109110

@@ -128,6 +129,10 @@ if (project == rootProject) {
128129
}
129130
mavenCentral()
130131
}
132+
test {
133+
include "**/*Tests.class"
134+
exclude "**/*IT.class"
135+
}
131136
}
132137

133138
/*****************************************************************************
@@ -152,6 +157,18 @@ if (project != rootProject) {
152157
jarHell.enabled = false
153158
thirdPartyAudit.enabled = false
154159

160+
// tests can't be run with randomized test runner
161+
// it's fine as we run them as part of :buildSrc
162+
test.enabled = false
163+
task integTest(type: Test) {
164+
exclude "**/*Tests.class"
165+
include "**/*IT.class"
166+
testClassesDirs = sourceSets.test.output.classesDirs
167+
classpath = sourceSets.test.runtimeClasspath
168+
inputs.dir(file("src/testKit"))
169+
}
170+
check.dependsOn(integTest)
171+
155172
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
156173
licenseHeaders.enabled = false
157174

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class RandomizedTestingPlugin implements Plugin<Project> {
7474
// since we can't be sure if the task was ever realized, we remove both the provider and the task
7575
TaskProvider<Test> oldTestProvider
7676
try {
77-
oldTestProvider = tasks.getByNameLater(Test, 'test')
77+
oldTestProvider = tasks.named('test')
7878
} catch (UnknownTaskException unused) {
7979
// no test task, ok, user will use testing task on their own
8080
return

0 commit comments

Comments
 (0)