Skip to content

Commit d8c9593

Browse files
author
Vladimir Dolzhenko
committed
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
2 parents c6b836a + 38e09a1 commit d8c9593

File tree

535 files changed

+15982
-5861
lines changed

Some content is hidden

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

535 files changed

+15982
-5861
lines changed

.ci/matrix-build-javas.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77

88
ES_BUILD_JAVA:
99
- java10
10+
- java11

.ci/matrix-runtime-javas.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
ES_RUNTIME_JAVA:
99
- java8
1010
- java10
11+
- java11

build.gradle

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -171,7 +174,7 @@ task verifyVersions {
171174
* after the backport of the backcompat code is complete.
172175
*/
173176
final boolean bwc_tests_enabled = true
174-
final String bwc_tests_disabled_issue = "" /* place a PR link here when commiting bwc changes */
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")
@@ -445,12 +448,19 @@ allprojects {
445448
}
446449

447450
File licenseHeaderFile;
448-
if (eclipse.project.name.startsWith(':x-pack')) {
451+
String prefix = ':x-pack';
452+
453+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
454+
prefix = prefix.replace(':', '_')
455+
}
456+
if (eclipse.project.name.startsWith(prefix)) {
449457
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/elastic-license-header.txt')
450458
} else {
451459
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/oss-license-header.txt')
452460
}
453-
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace('\n', '\\\\n')
461+
462+
String lineSeparator = Os.isFamily(Os.FAMILY_WINDOWS) ? '\\\\r\\\\n' : '\\\\n'
463+
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace(System.lineSeparator(), lineSeparator)
454464
task copyEclipseSettings(type: Copy) {
455465
// TODO: "package this up" for external builds
456466
from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ class BuildPlugin implements Plugin<Project> {
691691
systemProperty 'tests.task', path
692692
systemProperty 'tests.security.manager', 'true'
693693
systemProperty 'jna.nosys', 'true'
694+
systemProperty 'es.scripting.exception_for_missing_value', 'true'
694695
// TODO: remove setting logging level via system property
695696
systemProperty 'tests.logger.level', 'WARN'
696697
for (Map.Entry<String, String> property : System.properties.entrySet()) {

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,15 @@ class VagrantTestPlugin implements Plugin<Project> {
546546
javaPackagingTest.command = 'ssh'
547547
javaPackagingTest.args = ['--command', 'sudo bash "$PACKAGING_TESTS/run-tests.sh"']
548548
} else {
549+
// powershell sessions run over winrm always run as administrator, whether --elevated is passed or not. however
550+
// remote sessions have some restrictions on what they can do, such as impersonating another user (or the same user
551+
// without administrator elevation), which we need to do for these tests. passing --elevated runs the session
552+
// as a scheduled job locally on the vm as a true administrator to get around this limitation
553+
//
554+
// https://github.com/hashicorp/vagrant/blob/9c299a2a357fcf87f356bb9d56e18a037a53d138/plugins/communicators/winrm/communicator.rb#L195-L225
555+
// https://devops-collective-inc.gitbooks.io/secrets-of-powershell-remoting/content/manuscript/accessing-remote-computers.html
549556
javaPackagingTest.command = 'winrm'
550-
// winrm commands run as administrator
551-
javaPackagingTest.args = ['--command', 'powershell -File "$Env:PACKAGING_TESTS/run-tests.ps1"']
557+
javaPackagingTest.args = ['--elevated', '--command', 'powershell -File "$Env:PACKAGING_TESTS/run-tests.ps1"']
552558
}
553559

554560
TaskExecutionAdapter javaPackagingReproListener = createReproListener(project, javaPackagingTest.path)

buildSrc/src/main/resources/forbidden/jdk-signatures.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ java.lang.Thread#getAllStackTraces()
8888

8989
@defaultMessage Stopping threads explicitly leads to inconsistent states. Use interrupt() instead.
9090
java.lang.Thread#stop()
91-
java.lang.Thread#stop(java.lang.Throwable)
91+
# uncomment when https://github.com/elastic/elasticsearch/issues/31715 is fixed
92+
# java.lang.Thread#stop(java.lang.Throwable)
9293

9394
@defaultMessage Please do not terminate the application
9495
java.lang.System#exit(int)

client/rest-high-level/build.gradle

Lines changed: 111 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import org.elasticsearch.gradle.precommit.PrecommitTasks
2-
31
/*
42
* Licensed to Elasticsearch under one or more contributor
53
* license agreements. See the NOTICE file distributed with
@@ -18,29 +16,86 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
1816
* specific language governing permissions and limitations
1917
* under the License.
2018
*/
19+
20+
import org.elasticsearch.gradle.precommit.PrecommitTasks
21+
import org.gradle.api.XmlProvider
22+
import org.gradle.api.publish.maven.MavenPublication
23+
24+
buildscript {
25+
repositories {
26+
maven {
27+
url 'https://plugins.gradle.org/m2/'
28+
}
29+
}
30+
dependencies {
31+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
32+
}
33+
}
34+
2135
apply plugin: 'elasticsearch.build'
2236
apply plugin: 'elasticsearch.rest-test'
2337
apply plugin: 'nebula.maven-base-publish'
2438
apply plugin: 'nebula.maven-scm'
39+
apply plugin: 'com.github.johnrengelman.shadow'
2540

2641
group = 'org.elasticsearch.client'
2742
archivesBaseName = 'elasticsearch-rest-high-level-client'
2843

2944
publishing {
30-
publications {
31-
nebula {
32-
artifactId = archivesBaseName
45+
publications {
46+
nebula(MavenPublication) {
47+
artifact shadowJar
48+
artifactId = archivesBaseName
49+
/*
50+
* Configure the pom to include the "shadow" as compile dependencies
51+
* because that is how we're using them but remove all other dependencies
52+
* because they've been shaded into the jar.
53+
*/
54+
pom.withXml { XmlProvider xml ->
55+
Node root = xml.asNode()
56+
root.remove(root.dependencies)
57+
Node dependenciesNode = root.appendNode('dependencies')
58+
project.configurations.shadow.allDependencies.each {
59+
if (false == it instanceof SelfResolvingDependency) {
60+
Node dependencyNode = dependenciesNode.appendNode('dependency')
61+
dependencyNode.appendNode('groupId', it.group)
62+
dependencyNode.appendNode('artifactId', it.name)
63+
dependencyNode.appendNode('version', it.version)
64+
dependencyNode.appendNode('scope', 'compile')
65+
}
3366
}
67+
}
3468
}
69+
}
70+
}
71+
72+
/*
73+
* We need somewhere to configure dependencies that we don't wish to shade
74+
* into the high level REST client. The shadow plugin creates a "shadow"
75+
* configuration which is *almost* exactly that. It is never bundled into
76+
* the shaded jar but is used for main source compilation. Unfortunately,
77+
* by default it is not used for *test* source compilation and isn't used
78+
* in tests at all. This change makes it available for test compilation.
79+
* A change below makes it available for testing.
80+
*/
81+
sourceSets {
82+
test {
83+
compileClasspath += configurations.shadow
84+
}
3585
}
3686

3787
dependencies {
38-
compile "org.elasticsearch:elasticsearch:${version}"
39-
compile "org.elasticsearch.client:elasticsearch-rest-client:${version}"
40-
compile "org.elasticsearch.plugin:parent-join-client:${version}"
41-
compile "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
42-
compile "org.elasticsearch.plugin:rank-eval-client:${version}"
43-
compile "org.elasticsearch.plugin:lang-mustache-client:${version}"
88+
/*
89+
* Everything in the "shadow" configuration is *not* copied into the
90+
* shadowJar.
91+
*/
92+
shadow "org.elasticsearch:elasticsearch:${version}"
93+
shadow "org.elasticsearch.client:elasticsearch-rest-client:${version}"
94+
shadow "org.elasticsearch.plugin:parent-join-client:${version}"
95+
shadow "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
96+
shadow "org.elasticsearch.plugin:rank-eval-client:${version}"
97+
shadow "org.elasticsearch.plugin:lang-mustache-client:${version}"
98+
compile project(':x-pack:protocol')
4499

45100
testCompile "org.elasticsearch.client:test:${version}"
46101
testCompile "org.elasticsearch.test:framework:${version}"
@@ -63,3 +118,48 @@ forbiddenApisMain {
63118
signaturesURLs += [PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
64119
signaturesURLs += [file('src/main/resources/forbidden/rest-high-level-signatures.txt').toURI().toURL()]
65120
}
121+
122+
shadowJar {
123+
classifier = null
124+
mergeServiceFiles()
125+
}
126+
127+
// We don't need normal jar, we use shadow jar instead
128+
jar.enabled = false
129+
assemble.dependsOn shadowJar
130+
131+
javadoc {
132+
/*
133+
* Bundle all of the javadoc from all of the shaded projects into this one
134+
* so we don't *have* to publish javadoc for all of the "client" jars.
135+
*/
136+
configurations.compile.dependencies.all { Dependency dep ->
137+
Project p = dependencyToProject(dep)
138+
if (p != null) {
139+
evaluationDependsOn(p.path)
140+
source += p.sourceSets.main.allJava
141+
}
142+
}
143+
}
144+
145+
/*
146+
* Use the jar for testing so we have tests of the bundled jar.
147+
* Use the "shadow" configuration for testing because we need things
148+
* in it.
149+
*/
150+
test {
151+
classpath -= compileJava.outputs.files
152+
classpath -= configurations.compile
153+
classpath -= configurations.runtime
154+
classpath += configurations.shadow
155+
classpath += shadowJar.outputs.files
156+
dependsOn shadowJar
157+
}
158+
integTestRunner {
159+
classpath -= compileJava.outputs.files
160+
classpath -= configurations.compile
161+
classpath -= configurations.runtime
162+
classpath += configurations.shadow
163+
classpath += shadowJar.outputs.files
164+
dependsOn shadowJar
165+
}

client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
2424
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
2525
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
26+
import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest;
27+
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
2628
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
2729
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
2830
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
@@ -37,6 +39,7 @@
3739
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
3840
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
3941
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
42+
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
4043
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest;
4144
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
4245
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
@@ -435,6 +438,34 @@ public void getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptio
435438
GetSettingsResponse::fromXContent, listener, emptySet());
436439
}
437440

441+
/**
442+
* Retrieve information about one or more indexes
443+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html">
444+
* Indices Get Index API on elastic.co</a>
445+
* @param getIndexRequest the request
446+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
447+
* @return the response
448+
* @throws IOException in case there is a problem sending the request or parsing back the response
449+
*/
450+
public GetIndexResponse get(GetIndexRequest getIndexRequest, RequestOptions options) throws IOException {
451+
return restHighLevelClient.performRequestAndParseEntity(getIndexRequest, RequestConverters::getIndex, options,
452+
GetIndexResponse::fromXContent, emptySet());
453+
}
454+
455+
/**
456+
* Retrieve information about one or more indexes
457+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html">
458+
* Indices Get Index API on elastic.co</a>
459+
* @param getIndexRequest the request
460+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
461+
* @param listener the listener to be notified upon request completion
462+
*/
463+
public void getAsync(GetIndexRequest getIndexRequest, RequestOptions options,
464+
ActionListener<GetIndexResponse> listener) {
465+
restHighLevelClient.performRequestAsyncAndParseEntity(getIndexRequest, RequestConverters::getIndex, options,
466+
GetIndexResponse::fromXContent, listener, emptySet());
467+
}
468+
438469
/**
439470
* Force merge one or more indices using the Force Merge API.
440471
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html">
@@ -752,4 +783,32 @@ public void getTemplateAsync(GetIndexTemplatesRequest getIndexTemplatesRequest,
752783
restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest, RequestConverters::getTemplates,
753784
options, GetIndexTemplatesResponse::fromXContent, listener, emptySet());
754785
}
786+
787+
/**
788+
* Calls the analyze API
789+
*
790+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html">Analyze API on elastic.co</a>
791+
*
792+
* @param request the request
793+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
794+
*/
795+
public AnalyzeResponse analyze(AnalyzeRequest request, RequestOptions options) throws IOException {
796+
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::analyze, options,
797+
AnalyzeResponse::fromXContent, emptySet());
798+
}
799+
800+
/**
801+
* Asynchronously calls the analyze API
802+
*
803+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html">Analyze API on elastic.co</a>
804+
*
805+
* @param request the request
806+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
807+
* @param listener the listener to be notified upon request completion
808+
*/
809+
public void analyzeAsync(AnalyzeRequest request, RequestOptions options,
810+
ActionListener<AnalyzeResponse> listener) {
811+
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::analyze, options,
812+
AnalyzeResponse::fromXContent, listener, emptySet());
813+
}
755814
}

0 commit comments

Comments
 (0)