Skip to content

Commit 7c1bcfc

Browse files
committed
Merge branch 'master' into ccr
* master: (35 commits) Create weights lazily in filter and filters aggregation (#26983) Use a dedicated ThreadGroup in rest sniffer (#26897) Fire global checkpoint sync under system context Update by Query is modified to accept short `script` parameter. (#26841) Cat shards bytes (#26952) Add support for parsing inline script (#23824) (#26846) Change default value to true for transpositions parameter of fuzzy query (#26901) Adding unreleased 5.6.4 version number to Version.java Rename TCPTransportTests to TcpTransportTests (#26954) Fix NPE for /_cat/indices when no primary shard (#26953) [DOCS] Fixed indentation of the definition list. Fix formatting in channel close test Check for closed connection while opening Clarify systemd overrides [DOCS] Plugin Installation for Windows (#21671) Painless: add tests for cached boxing (#24163) Don't detect source's XContentType in DocumentParser.parseDocument() (#26880) Fix handling of paths containing parentheses Allow only a fixed-size receive predictor (#26165) Add Homebrew instructions to getting started ...
2 parents 6e403b0 + e1679bf commit 7c1bcfc

File tree

165 files changed

+1263
-1067
lines changed

Some content is hidden

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

165 files changed

+1263
-1067
lines changed

CONTRIBUTING.md

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ If you have a bugfix or new feature that you would like to contribute to Elastic
3838

3939
We enjoy working with contributors to get their code accepted. There are many approaches to fixing a problem and it is important to find the best approach before writing too much code.
4040

41+
Note that it is unlikely the project will merge refactors for the sake of refactoring. These
42+
types of pull requests have a high cost to maintainers in reviewing and testing with little
43+
to no tangible benefit. This especially includes changes generated by tools. For example,
44+
converting all generic interface instances to use the diamond operator.
45+
4146
The process for contributing to any of the [Elastic repositories](https://github.com/elastic/) is similar. Details for individual projects can be found below.
4247

4348
### Fork and clone the repository

TESTING.asciidoc

+13-11
Original file line numberDiff line numberDiff line change
@@ -472,28 +472,30 @@ is tested depends on the branch. On master, this will test against the current
472472
stable branch. On the stable branch, it will test against the latest release
473473
branch. Finally, on a release branch, it will test against the most recent release.
474474

475-
=== BWC Testing against a specific branch
475+
=== BWC Testing against a specific remote/branch
476476

477477
Sometimes a backward compatibility change spans two versions. A common case is a new functionality
478478
that needs a BWC bridge in and an unreleased versioned of a release branch (for example, 5.x).
479-
To test the changes, you can instruct gradle to build the BWC version from a local branch instead of
480-
pulling the release branch from GitHub. You do so using the `tests.bwc.refspec` system property:
479+
To test the changes, you can instruct gradle to build the BWC version from a another remote/branch combination instead of
480+
pulling the release branch from GitHub. You do so using the `tests.bwc.remote` and `tests.bwc.refspec` system properties:
481481

482482
-------------------------------------------------
483-
gradle check -Dtests.bwc.refspec=origin/index_req_bwc_5.x
483+
gradle check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec=index_req_bwc_5.x
484484
-------------------------------------------------
485485

486-
The branch needs to be available on the local clone that the BWC makes of the repository you run the
487-
tests from. Using the `origin` remote is a handy trick to make sure that a branch is available
488-
and is up to date in the case of multiple runs.
486+
The branch needs to be available on the remote that the BWC makes of the
487+
repository you run the tests from. Using the remote is a handy trick to make
488+
sure that a branch is available and is up to date in the case of multiple runs.
489489

490490
Example:
491491

492-
Say you need to make a change to `master` and have a BWC layer in `5.x`. You will need to:
493-
. Create a branch called `index_req_change` off `master`. This will contain your change.
492+
Say you need to make a change to `master` and have a BWC layer in `5.x`. You
493+
will need to:
494+
. Create a branch called `index_req_change` off your remote `${remote}`. This
495+
will contain your change.
494496
. Create a branch called `index_req_bwc_5.x` off `5.x`. This will contain your bwc layer.
495-
. If not running the tests locally, push both branches to your remote repository.
496-
. Run the tests with `gradle check -Dtests.bwc.refspec=origin/index_req_bwc_5.x`
497+
. Push both branches to your remote repository.
498+
. Run the tests with `gradle check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec=index_req_bwc_5.x`.
497499

498500
== Coverage analysis
499501

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy

+3-5
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ class ClusterConfiguration {
6363
boolean debug = false
6464

6565
/**
66-
* if <code>true</code> each node will be configured with <tt>discovery.zen.minimum_master_nodes</tt> set
67-
* to the total number of nodes in the cluster. This will also cause that each node has `0s` state recovery
68-
* timeout which can lead to issues if for instance an existing clusterstate is expected to be recovered
69-
* before any tests start
66+
* Configuration of the setting <tt>discovery.zen.minimum_master_nodes</tt> on the nodes.
67+
* In case of more than one node, this defaults to (number of nodes / 2) + 1
7068
*/
7169
@Input
72-
boolean useMinimumMasterNodes = true
70+
Closure<Integer> minimumMasterNodes = { getNumNodes() > 1 ? getNumNodes().intdiv(2) + 1 : -1 }
7371

7472
@Input
7573
String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') +

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

+8-7
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,14 @@ class ClusterFormationTasks {
311311
// Define a node attribute so we can test that it exists
312312
'node.attr.testattr' : 'test'
313313
]
314-
// we set min master nodes to the total number of nodes in the cluster and
315-
// basically skip initial state recovery to allow the cluster to form using a realistic master election
316-
// this means all nodes must be up, join the seed node and do a master election. This will also allow new and
317-
// old nodes in the BWC case to become the master
318-
if (node.config.useMinimumMasterNodes && node.config.numNodes > 1) {
319-
esConfig['discovery.zen.minimum_master_nodes'] = node.config.numNodes
320-
esConfig['discovery.initial_state_timeout'] = '0s' // don't wait for state.. just start up quickly
314+
int minimumMasterNodes = node.config.minimumMasterNodes.call()
315+
if (minimumMasterNodes > 0) {
316+
esConfig['discovery.zen.minimum_master_nodes'] = minimumMasterNodes
317+
}
318+
if (node.config.numNodes > 1) {
319+
// don't wait for state.. just start up quickly
320+
// this will also allow new and old nodes in the BWC case to become the master
321+
esConfig['discovery.initial_state_timeout'] = '0s'
321322
}
322323
esConfig['node.max_local_storage_nodes'] = node.config.numNodes
323324
esConfig['http.port'] = node.config.httpPort

client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/NoopSearchRequestBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ public NoopSearchRequestBuilder setRouting(String... routing) {
142142

143143
/**
144144
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
145-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
146-
* a custom value, which guarantees that the same order will be used across different requests.
145+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
146+
* will be used across different requests.
147147
*/
148148
public NoopSearchRequestBuilder setPreference(String preference) {
149149
request.preference(preference);

client/sniffer/src/main/java/org/elasticsearch/client/sniff/Sniffer.java

+37-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@
2727

2828
import java.io.Closeable;
2929
import java.io.IOException;
30+
import java.security.AccessController;
31+
import java.security.PrivilegedAction;
3032
import java.util.List;
3133
import java.util.concurrent.Executors;
3234
import java.util.concurrent.ScheduledExecutorService;
3335
import java.util.concurrent.ScheduledFuture;
36+
import java.util.concurrent.ThreadFactory;
3437
import java.util.concurrent.TimeUnit;
3538
import java.util.concurrent.atomic.AtomicBoolean;
39+
import java.util.concurrent.atomic.AtomicInteger;
3640

3741
/**
3842
* Class responsible for sniffing nodes from some source (default is elasticsearch itself) and setting them to a provided instance of
@@ -45,6 +49,7 @@
4549
public class Sniffer implements Closeable {
4650

4751
private static final Log logger = LogFactory.getLog(Sniffer.class);
52+
private static final String SNIFFER_THREAD_NAME = "es_rest_client_sniffer";
4853

4954
private final Task task;
5055

@@ -79,7 +84,8 @@ private Task(HostsSniffer hostsSniffer, RestClient restClient, long sniffInterva
7984
this.restClient = restClient;
8085
this.sniffIntervalMillis = sniffIntervalMillis;
8186
this.sniffAfterFailureDelayMillis = sniffAfterFailureDelayMillis;
82-
this.scheduledExecutorService = Executors.newScheduledThreadPool(1);
87+
SnifferThreadFactory threadFactory = new SnifferThreadFactory(SNIFFER_THREAD_NAME);
88+
this.scheduledExecutorService = Executors.newScheduledThreadPool(1, threadFactory);
8389
scheduleNextRun(0);
8490
}
8591

@@ -151,4 +157,34 @@ synchronized void shutdown() {
151157
public static SnifferBuilder builder(RestClient restClient) {
152158
return new SnifferBuilder(restClient);
153159
}
160+
161+
private static class SnifferThreadFactory implements ThreadFactory {
162+
163+
private final AtomicInteger threadNumber = new AtomicInteger(1);
164+
private final String namePrefix;
165+
private final ThreadFactory originalThreadFactory;
166+
167+
private SnifferThreadFactory(String namePrefix) {
168+
this.namePrefix = namePrefix;
169+
this.originalThreadFactory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() {
170+
@Override
171+
public ThreadFactory run() {
172+
return Executors.defaultThreadFactory();
173+
}
174+
});
175+
}
176+
177+
@Override
178+
public Thread newThread(final Runnable r) {
179+
return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
180+
@Override
181+
public Thread run() {
182+
Thread t = originalThreadFactory.newThread(r);
183+
t.setName(namePrefix + "[T#" + threadNumber.getAndIncrement() + "]");
184+
t.setDaemon(true);
185+
return t;
186+
}
187+
});
188+
}
189+
}
154190
}

core/src/main/java/org/elasticsearch/Version.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public class Version implements Comparable<Version> {
9898
public static final Version V_5_6_2 = new Version(V_5_6_2_ID, org.apache.lucene.util.Version.LUCENE_6_6_1);
9999
public static final int V_5_6_3_ID = 5060399;
100100
public static final Version V_5_6_3 = new Version(V_5_6_3_ID, org.apache.lucene.util.Version.LUCENE_6_6_1);
101+
public static final int V_5_6_4_ID = 5060499;
102+
public static final Version V_5_6_4 = new Version(V_5_6_4_ID, org.apache.lucene.util.Version.LUCENE_6_6_1);
101103
public static final int V_6_0_0_alpha1_ID = 6000001;
102104
public static final Version V_6_0_0_alpha1 =
103105
new Version(V_6_0_0_alpha1_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
@@ -115,7 +117,7 @@ public class Version implements Comparable<Version> {
115117
new Version(V_6_0_0_rc1_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
116118
public static final int V_6_0_0_rc2_ID = 6000052;
117119
public static final Version V_6_0_0_rc2 =
118-
new Version(V_6_0_0_rc2_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
120+
new Version(V_6_0_0_rc2_ID, org.apache.lucene.util.Version.LUCENE_7_0_1);
119121
public static final int V_6_1_0_ID = 6010099;
120122
public static final Version V_6_1_0 =
121123
new Version(V_6_1_0_ID, org.apache.lucene.util.Version.LUCENE_7_1_0);
@@ -153,6 +155,8 @@ public static Version fromId(int id) {
153155
return V_6_0_0_alpha2;
154156
case V_6_0_0_alpha1_ID:
155157
return V_6_0_0_alpha1;
158+
case V_5_6_4_ID:
159+
return V_5_6_4;
156160
case V_5_6_3_ID:
157161
return V_5_6_3;
158162
case V_5_6_2_ID:

core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ public ClusterSearchShardsRequest routing(String... routings) {
146146

147147
/**
148148
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
149-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
150-
* a custom value, which guarantees that the same order will be used across different requests.
149+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
150+
* will be used across different requests.
151151
*/
152152
public ClusterSearchShardsRequest preference(String preference) {
153153
this.preference = preference;

core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public ClusterSearchShardsRequestBuilder setRouting(String... routing) {
5555

5656
/**
5757
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
58-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
59-
* a custom value, which guarantees that the same order will be used across different requests.
58+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
59+
* will be used across different requests.
6060
*/
6161
public ClusterSearchShardsRequestBuilder setPreference(String preference) {
6262
request.preference(preference);

core/src/main/java/org/elasticsearch/action/get/GetRequest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ public GetRequest routing(String routing) {
152152

153153
/**
154154
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
155-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
156-
* a custom value, which guarantees that the same order will be used across different requests.
155+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
156+
* will be used across different requests.
157157
*/
158158
public GetRequest preference(String preference) {
159159
this.preference = preference;

core/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public GetRequestBuilder setRouting(String routing) {
7676

7777
/**
7878
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
79-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
80-
* a custom value, which guarantees that the same order will be used across different requests.
79+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
80+
* will be used across different requests.
8181
*/
8282
public GetRequestBuilder setPreference(String preference) {
8383
request.preference(preference);

core/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ public ActionRequestValidationException validate() {
284284

285285
/**
286286
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
287-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
288-
* a custom value, which guarantees that the same order will be used across different requests.
287+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
288+
* will be used across different requests.
289289
*/
290290
public MultiGetRequest preference(String preference) {
291291
this.preference = preference;

core/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public MultiGetRequestBuilder add(MultiGetRequest.Item item) {
5858

5959
/**
6060
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
61-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
62-
* a custom value, which guarantees that the same order will be used across different requests.
61+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
62+
* will be used across different requests.
6363
*/
6464
public MultiGetRequestBuilder setPreference(String preference) {
6565
request.preference(preference);

core/src/main/java/org/elasticsearch/action/get/MultiGetShardRequest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public int shardId() {
6464

6565
/**
6666
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
67-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
68-
* a custom value, which guarantees that the same order will be used across different requests.
67+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
68+
* will be used across different requests.
6969
*/
7070
public MultiGetShardRequest preference(String preference) {
7171
this.preference = preference;

core/src/main/java/org/elasticsearch/action/search/SearchRequest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ public SearchRequest routing(String... routings) {
241241

242242
/**
243243
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
244-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
245-
* a custom value, which guarantees that the same order will be used across different requests.
244+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
245+
* will be used across different requests.
246246
*/
247247
public SearchRequest preference(String preference) {
248248
this.preference = preference;

core/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ public SearchRequestBuilder setRouting(String... routing) {
144144

145145
/**
146146
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
147-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
148-
* a custom value, which guarantees that the same order will be used across different requests.
147+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
148+
* will be used across different requests.
149149
*/
150150
public SearchRequestBuilder setPreference(String preference) {
151151
request.preference(preference);

core/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsShardRequest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public int shardId() {
5959

6060
/**
6161
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
62-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
63-
* a custom value, which guarantees that the same order will be used across different requests.
62+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
63+
* will be used across different requests.
6464
*/
6565
public MultiTermVectorsShardRequest preference(String preference) {
6666
this.preference = preference;

core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ public String preference() {
294294

295295
/**
296296
* Sets the preference to execute the search. Defaults to randomize across
297-
* shards. Can be set to <tt>_local</tt> to prefer local shards,
298-
* <tt>_primary</tt> to execute only on primary shards, or a custom value,
297+
* shards. Can be set to <tt>_local</tt> to prefer local shards or a custom value,
299298
* which guarantees that the same order will be used across different
300299
* requests.
301300
*/

core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequestBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ public TermVectorsRequestBuilder setParent(String parent) {
9999

100100
/**
101101
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
102-
* <tt>_local</tt> to prefer local shards, <tt>_primary</tt> to execute only on primary shards, or
103-
* a custom value, which guarantees that the same order will be used across different requests.
102+
* <tt>_local</tt> to prefer local shards or a custom value, which guarantees that the same order
103+
* will be used across different requests.
104104
*/
105105
public TermVectorsRequestBuilder setPreference(String preference) {
106106
request.preference(preference);

0 commit comments

Comments
 (0)