Skip to content

Commit 853eb1c

Browse files
committed
Merge branch 'master' into ccr
* master: Generalize remote license checker (#32971) Trim translog when safe commit advanced (#32967) Fix an inaccuracy in the dynamic templates documentation. (#32890) Logging: Use settings when building daemon threads (#32751) All Translog inner closes should happen after tragedy exception is set (#32674) HLREST: AwaitsFix ML Test Pass DiscoveryNode to initiateChannel (#32958) Add mzn and dz to unsupported locales (#32957) Use settings from the context in BootstrapChecks (#32908) Update docs for node specifications (#30468) HLRC: Forbid all Elasticsearch logging infra (#32784) Only configure publishing if it's applied externally (#32351) Fixes libs:dissect when in eclipse Protect ScriptedMetricIT test cases against failures on 0-doc shards (#32959) (#32968) [Kerberos] Add documentation for Kerberos realm (#32662) Watcher: Properly find next valid date in cron expressions (#32734) Fix some small issues in the getting started docs (#30346) Set forbidden APIs target compatibility to compiler java version (#32935) Move connection listener to ConnectionManager (#32956)
2 parents ac75968 + 9050c7e commit 853eb1c

File tree

80 files changed

+1673
-983
lines changed

Some content is hidden

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

80 files changed

+1673
-983
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,12 @@ class BuildPlugin implements Plugin<Project> {
528528
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
529529
// The GenerateMavenPom task is aggressive about setting the destination, instead of fighting it,
530530
// just make a copy.
531+
generatePOMTask.ext.pomFileName = "${project.archivesBaseName}-${project.version}.pom"
531532
doLast {
532533
project.copy {
533534
from generatePOMTask.destination
534535
into "${project.buildDir}/distributions"
535-
rename { "${project.archivesBaseName}-${project.version}.pom" }
536+
rename { generatePOMTask.ext.pomFileName }
536537
}
537538
}
538539
// build poms with assemble (if the assemble task exists)

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

Lines changed: 35 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,19 @@
1919
package org.elasticsearch.gradle.plugin
2020

2121
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
22-
import nebula.plugin.info.scm.ScmInfoPlugin
22+
import nebula.plugin.publishing.maven.MavenScmPlugin
2323
import org.elasticsearch.gradle.BuildPlugin
2424
import org.elasticsearch.gradle.NoticeTask
2525
import org.elasticsearch.gradle.test.RestIntegTestTask
2626
import org.elasticsearch.gradle.test.RunTask
27-
import org.gradle.api.InvalidUserDataException
2827
import org.gradle.api.Project
29-
import org.gradle.api.Task
30-
import org.gradle.api.XmlProvider
3128
import org.gradle.api.publish.maven.MavenPublication
3229
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
30+
import org.gradle.api.publish.maven.tasks.GenerateMavenPom
3331
import org.gradle.api.tasks.SourceSet
3432
import org.gradle.api.tasks.bundling.Zip
33+
import org.gradle.jvm.tasks.Jar
3534

36-
import java.nio.file.Files
37-
import java.nio.file.Path
38-
import java.nio.file.StandardCopyOption
3935
import java.util.regex.Matcher
4036
import java.util.regex.Pattern
4137
/**
@@ -55,16 +51,10 @@ public class PluginBuildPlugin extends BuildPlugin {
5551
String name = project.pluginProperties.extension.name
5652
project.archivesBaseName = name
5753

58-
if (project.pluginProperties.extension.hasClientJar) {
59-
// for plugins which work with the transport client, we copy the jar
60-
// file to a new name, copy the nebula generated pom to the same name,
61-
// and generate a different pom for the zip
62-
addClientJarPomGeneration(project)
63-
addClientJarTask(project)
64-
}
65-
// while the jar isn't normally published, we still at least build a pom of deps
66-
// in case it is published, for instance when other plugins extend this plugin
67-
configureJarPom(project)
54+
// set teh project description so it will be picked up by publishing
55+
project.description = project.pluginProperties.extension.description
56+
57+
configurePublishing(project)
6858

6959
project.integTestCluster.dependsOn(project.bundlePlugin)
7060
project.tasks.run.dependsOn(project.bundlePlugin)
@@ -94,6 +84,32 @@ public class PluginBuildPlugin extends BuildPlugin {
9484
project.tasks.create('run', RunTask) // allow running ES with this plugin in the foreground of a build
9585
}
9686

87+
private void configurePublishing(Project project) {
88+
// Only configure publishing if applied externally
89+
if (project.pluginProperties.extension.hasClientJar) {
90+
project.plugins.apply(MavenScmPlugin.class)
91+
// Only change Jar tasks, we don't want a -client zip so we can't change archivesBaseName
92+
project.tasks.withType(Jar) {
93+
baseName = baseName + "-client"
94+
}
95+
// always configure publishing for client jars
96+
project.plugins.apply(MavenScmPlugin.class)
97+
project.publishing.publications.nebula(MavenPublication).artifactId(
98+
project.pluginProperties.extension.name + "-client"
99+
)
100+
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
101+
generatePOMTask.ext.pomFileName = "${project.archivesBaseName}-client-${project.version}.pom"
102+
}
103+
} else {
104+
project.plugins.withType(MavenPublishPlugin).whenPluginAdded {
105+
project.publishing.publications.nebula(MavenPublication).artifactId(
106+
project.pluginProperties.extension.name
107+
)
108+
}
109+
110+
}
111+
}
112+
97113
private static void configureDependencies(Project project) {
98114
project.dependencies {
99115
compileOnly "org.elasticsearch:elasticsearch:${project.versions.elasticsearch}"
@@ -161,33 +177,6 @@ public class PluginBuildPlugin extends BuildPlugin {
161177
}
162178

163179
/** Adds a task to move jar and associated files to a "-client" name. */
164-
protected static void addClientJarTask(Project project) {
165-
Task clientJar = project.tasks.create('clientJar')
166-
clientJar.dependsOn(project.jar, project.tasks.generatePomFileForClientJarPublication, project.javadocJar, project.sourcesJar)
167-
clientJar.doFirst {
168-
Path jarFile = project.jar.outputs.files.singleFile.toPath()
169-
String clientFileName = jarFile.fileName.toString().replace(project.version, "client-${project.version}")
170-
Files.copy(jarFile, jarFile.resolveSibling(clientFileName), StandardCopyOption.REPLACE_EXISTING)
171-
172-
String clientPomFileName = clientFileName.replace('.jar', '.pom')
173-
Files.copy(
174-
project.tasks.generatePomFileForClientJarPublication.outputs.files.singleFile.toPath(),
175-
jarFile.resolveSibling(clientPomFileName),
176-
StandardCopyOption.REPLACE_EXISTING
177-
)
178-
179-
String sourcesFileName = jarFile.fileName.toString().replace('.jar', '-sources.jar')
180-
String clientSourcesFileName = clientFileName.replace('.jar', '-sources.jar')
181-
Files.copy(jarFile.resolveSibling(sourcesFileName), jarFile.resolveSibling(clientSourcesFileName),
182-
StandardCopyOption.REPLACE_EXISTING)
183-
184-
String javadocFileName = jarFile.fileName.toString().replace('.jar', '-javadoc.jar')
185-
String clientJavadocFileName = clientFileName.replace('.jar', '-javadoc.jar')
186-
Files.copy(jarFile.resolveSibling(javadocFileName), jarFile.resolveSibling(clientJavadocFileName),
187-
StandardCopyOption.REPLACE_EXISTING)
188-
}
189-
project.assemble.dependsOn(clientJar)
190-
}
191180

192181
static final Pattern GIT_PATTERN = Pattern.compile(/git@([^:]+):([^\.]+)\.git/)
193182

@@ -209,39 +198,11 @@ public class PluginBuildPlugin extends BuildPlugin {
209198

210199
/** Adds nebula publishing task to generate a pom file for the plugin. */
211200
protected static void addClientJarPomGeneration(Project project) {
212-
project.plugins.apply(MavenPublishPlugin.class)
213-
214-
project.publishing {
215-
publications {
216-
clientJar(MavenPublication) {
217-
from project.components.java
218-
artifactId = project.pluginProperties.extension.name + '-client'
219-
pom.withXml { XmlProvider xml ->
220-
Node root = xml.asNode()
221-
root.appendNode('name', project.pluginProperties.extension.name)
222-
root.appendNode('description', project.pluginProperties.extension.description)
223-
root.appendNode('url', urlFromOrigin(project.scminfo.origin))
224-
Node scmNode = root.appendNode('scm')
225-
scmNode.appendNode('url', project.scminfo.origin)
226-
}
227-
}
228-
}
229-
}
201+
project.plugins.apply(MavenScmPlugin.class)
202+
project.description = project.pluginProperties.extension.description
230203
}
231204

232205
/** Configure the pom for the main jar of this plugin */
233-
protected static void configureJarPom(Project project) {
234-
project.plugins.apply(ScmInfoPlugin.class)
235-
project.plugins.apply(MavenPublishPlugin.class)
236-
237-
project.publishing {
238-
publications {
239-
nebula(MavenPublication) {
240-
artifactId project.pluginProperties.extension.name
241-
}
242-
}
243-
}
244-
}
245206

246207
protected void addNoticeGeneration(Project project) {
247208
File licenseFile = project.pluginProperties.extension.licenseFile

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package org.elasticsearch.gradle.precommit
2121
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
2222
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
2323
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
24+
import org.gradle.api.JavaVersion
2425
import org.gradle.api.Project
2526
import org.gradle.api.Task
2627
import org.gradle.api.file.FileCollection
@@ -101,6 +102,11 @@ class PrecommitTasks {
101102
signaturesURLs = project.forbiddenApis.signaturesURLs +
102103
[ getClass().getResource('/forbidden/es-server-signatures.txt') ]
103104
}
105+
// forbidden apis doesn't support Java 11, so stop at 10
106+
String targetMajorVersion = (project.compilerJavaVersion.compareTo(JavaVersion.VERSION_1_10) > 0 ?
107+
JavaVersion.VERSION_1_10 :
108+
project.compilerJavaVersion).getMajorVersion()
109+
targetCompatibility = Integer.parseInt(targetMajorVersion) >= 9 ?targetMajorVersion : "1.${targetMajorVersion}"
104110
}
105111
Task forbiddenApis = project.tasks.findByName('forbiddenApis')
106112
forbiddenApis.group = "" // clear group, so this does not show up under verification tasks

client/rest-high-level/src/main/resources/forbidden/rest-high-level-signatures.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,14 @@ org.apache.http.entity.ContentType#create(java.lang.String,java.lang.String)
2020
org.apache.http.entity.ContentType#create(java.lang.String,java.nio.charset.Charset)
2121
org.apache.http.entity.ContentType#create(java.lang.String,org.apache.http.NameValuePair[])
2222

23+
@defaultMessage ES's logging infrastructure uses log4j2 which we don't want to force on high level rest client users
24+
org.elasticsearch.common.logging.DeprecationLogger
25+
org.elasticsearch.common.logging.ESLoggerFactory
26+
org.elasticsearch.common.logging.LogConfigurator
27+
org.elasticsearch.common.logging.LoggerMessageFormat
28+
org.elasticsearch.common.logging.Loggers
29+
org.elasticsearch.common.logging.NodeNamePatternConverter
30+
org.elasticsearch.common.logging.PrefixLogger
31+
2332
@defaultMessage We can't rely on log4j2 being on the classpath so don't log deprecations!
2433
org.elasticsearch.common.xcontent.LoggingDeprecationHandler

client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.client;
2121

22+
import org.apache.http.util.EntityUtils;
2223
import org.elasticsearch.ElasticsearchException;
2324
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
2425
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
@@ -34,6 +35,7 @@
3435
import org.elasticsearch.common.unit.ByteSizeUnit;
3536
import org.elasticsearch.common.xcontent.XContentType;
3637
import org.elasticsearch.common.xcontent.support.XContentMapValues;
38+
import org.elasticsearch.client.Request;
3739
import org.elasticsearch.indices.recovery.RecoverySettings;
3840
import org.elasticsearch.rest.RestStatus;
3941

@@ -174,6 +176,8 @@ public void testClusterHealthYellowClusterLevel() throws IOException {
174176
request.timeout("5s");
175177
ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync);
176178

179+
logger.info("Shard stats\n{}", EntityUtils.toString(
180+
client().performRequest(new Request("GET", "/_cat/shards")).getEntity()));
177181
assertYellowShards(response);
178182
assertThat(response.getIndices().size(), equalTo(0));
179183
}
@@ -186,6 +190,8 @@ public void testClusterHealthYellowIndicesLevel() throws IOException {
186190
request.level(ClusterHealthRequest.Level.INDICES);
187191
ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync);
188192

193+
logger.info("Shard stats\n{}", EntityUtils.toString(
194+
client().performRequest(new Request("GET", "/_cat/shards")).getEntity()));
189195
assertYellowShards(response);
190196
assertThat(response.getIndices().size(), equalTo(2));
191197
for (Map.Entry<String, ClusterIndexHealth> entry : response.getIndices().entrySet()) {

client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.elasticsearch.client;
2020

2121
import com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator;
22+
import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
2223
import org.elasticsearch.common.unit.TimeValue;
2324
import org.elasticsearch.protocol.xpack.ml.DeleteJobRequest;
2425
import org.elasticsearch.protocol.xpack.ml.DeleteJobResponse;
@@ -36,6 +37,7 @@
3637

3738
import static org.hamcrest.Matchers.is;
3839

40+
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/32993")
3941
public class MachineLearningIT extends ESRestHighLevelClientTestCase {
4042

4143
public void testPutJob() throws Exception {

docs/reference/cluster.asciidoc

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,70 @@
66
["float",id="cluster-nodes"]
77
== Node specification
88

9-
Most cluster level APIs allow to specify which nodes to execute on (for
10-
example, getting the node stats for a node). Nodes can be identified in
11-
the APIs either using their internal node id, the node name, address,
12-
custom attributes, or just the `_local` node receiving the request. For
13-
example, here are some sample executions of nodes info:
9+
Some cluster-level APIs may operate on a subset of the nodes which can be
10+
specified with _node filters_. For example, the <<tasks,Task Management>>,
11+
<<cluster-nodes-stats,Nodes Stats>>, and <<cluster-nodes-info,Nodes Info>> APIs
12+
can all report results from a filtered set of nodes rather than from all nodes.
13+
14+
_Node filters_ are written as a comma-separated list of individual filters,
15+
each of which adds or removes nodes from the chosen subset. Each filter can be
16+
one of the following:
17+
18+
* `_all`, to add all nodes to the subset.
19+
* `_local`, to add the local node to the subset.
20+
* `_master`, to add the currently-elected master node to the subset.
21+
* a node id or name, to add this node to the subset.
22+
* an IP address or hostname, to add all matching nodes to the subset.
23+
* a pattern, using `*` wildcards, which adds all nodes to the subset
24+
whose name, address or hostname matches the pattern.
25+
* `master:true`, `data:true`, `ingest:true` or `coordinating_only:true`, which
26+
respectively add to the subset all master-eligible nodes, all data nodes,
27+
all ingest nodes, and all coordinating-only nodes.
28+
* `master:false`, `data:false`, `ingest:false` or `coordinating_only:false`,
29+
which respectively remove from the subset all master-eligible nodes, all data
30+
nodes, all ingest nodes, and all coordinating-only nodes.
31+
* a pair of patterns, using `*` wildcards, of the form `attrname:attrvalue`,
32+
which adds to the subset all nodes with a custom node attribute whose name
33+
and value match the respective patterns. Custom node attributes are
34+
configured by setting properties in the configuration file of the form
35+
`node.attr.attrname: attrvalue`.
36+
37+
NOTE: node filters run in the order in which they are given, which is important
38+
if using filters that remove nodes from the set. For example
39+
`_all,master:false` means all the nodes except the master-eligible ones, but
40+
`master:false,_all` means the same as `_all` because the `_all` filter runs
41+
after the `master:false` filter.
42+
43+
NOTE: if no filters are given, the default is to select all nodes. However, if
44+
any filters are given then they run starting with an empty chosen subset. This
45+
means that filters such as `master:false` which remove nodes from the chosen
46+
subset are only useful if they come after some other filters. When used on its
47+
own, `master:false` selects no nodes.
48+
49+
Here are some examples of the use of node filters with the
50+
<<cluster-nodes-info,Nodes Info>> APIs.
1451

1552
[source,js]
1653
--------------------------------------------------
17-
# Local
54+
# If no filters are given, the default is to select all nodes
55+
GET /_nodes
56+
# Explicitly select all nodes
57+
GET /_nodes/_all
58+
# Select just the local node
1859
GET /_nodes/_local
19-
# Address
20-
GET /_nodes/10.0.0.3,10.0.0.4
21-
GET /_nodes/10.0.0.*
22-
# Names
60+
# Select the elected master node
61+
GET /_nodes/_master
62+
# Select nodes by name, which can include wildcards
2363
GET /_nodes/node_name_goes_here
2464
GET /_nodes/node_name_goes_*
25-
# Attributes (set something like node.attr.rack: 2 in the config)
65+
# Select nodes by address, which can include wildcards
66+
GET /_nodes/10.0.0.3,10.0.0.4
67+
GET /_nodes/10.0.0.*
68+
# Select nodes by role
69+
GET /_nodes/_all,master:false
70+
GET /_nodes/data:true,ingest:true
71+
GET /_nodes/coordinating_only:true
72+
# Select nodes by custom attribute (e.g. with something like `node.attr.rack: 2` in the configuration file)
2673
GET /_nodes/rack:2
2774
GET /_nodes/ra*:2
2875
GET /_nodes/ra*:2*

docs/reference/cluster/nodes-hot-threads.asciidoc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
[[cluster-nodes-hot-threads]]
22
== Nodes hot_threads
33

4-
An API allowing to get the current hot threads on each node in the
5-
cluster. Endpoints are `/_nodes/hot_threads`, and
6-
`/_nodes/{nodesIds}/hot_threads`.
4+
This API yields a breakdown of the hot threads on each selected node in the
5+
cluster. Its endpoints are `/_nodes/hot_threads` and
6+
`/_nodes/{nodes}/hot_threads`:
77

8-
The output is plain text with a breakdown of each node's top hot
9-
threads. Parameters allowed are:
8+
[source,js]
9+
--------------------------------------------------
10+
GET /_nodes/hot_threads
11+
GET /_nodes/nodeId1,nodeId2/hot_threads
12+
--------------------------------------------------
13+
// CONSOLE
14+
15+
The first command gets the hot threads of all the nodes in the cluster. The
16+
second command gets the hot threads of only `nodeId1` and `nodeId2`. Nodes can
17+
be selected using <<cluster-nodes,node filters>>.
18+
19+
The output is plain text with a breakdown of each node's top hot threads. The
20+
allowed parameters are:
1021

1122
[horizontal]
1223
`threads`:: number of hot threads to provide, defaults to 3.

docs/reference/cluster/stats.asciidoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,12 @@ Will return, for example:
213213
// 3. All of the numbers and strings on the right hand side of *every* field in
214214
// the response are ignored. So we're really only asserting things about the
215215
// the shape of this response, not the values in it.
216+
217+
This API can be restricted to a subset of the nodes using the `?nodeId`
218+
parameter, which accepts <<cluster-nodes,node filters>>:
219+
220+
[source,js]
221+
--------------------------------------------------
222+
GET /_cluster/stats?nodeId=node1,node*,master:false
223+
--------------------------------------------------
224+
// CONSOLE

0 commit comments

Comments
 (0)