Skip to content

Commit 738cf9f

Browse files
author
Andrey Ershov
committed
Merge branch 'master' into zen2_tests_bootstrap
# Conflicts: # server/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java # server/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java # server/src/test/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapMasterIT.java
2 parents 3d0ffed + cde126d commit 738cf9f

File tree

566 files changed

+5719
-3804
lines changed

Some content is hidden

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

566 files changed

+5719
-3804
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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.time;
20+
21+
import org.elasticsearch.common.time.DateFormatter;
22+
import org.elasticsearch.common.time.DateFormatters;
23+
import org.openjdk.jmh.annotations.Benchmark;
24+
import org.openjdk.jmh.annotations.BenchmarkMode;
25+
import org.openjdk.jmh.annotations.Fork;
26+
import org.openjdk.jmh.annotations.Measurement;
27+
import org.openjdk.jmh.annotations.Mode;
28+
import org.openjdk.jmh.annotations.OutputTimeUnit;
29+
import org.openjdk.jmh.annotations.Scope;
30+
import org.openjdk.jmh.annotations.State;
31+
import org.openjdk.jmh.annotations.Warmup;
32+
33+
import java.time.temporal.TemporalAccessor;
34+
import java.util.concurrent.TimeUnit;
35+
36+
@Fork(3)
37+
@Warmup(iterations = 10)
38+
@Measurement(iterations = 10)
39+
@BenchmarkMode(Mode.AverageTime)
40+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
41+
@State(Scope.Benchmark)
42+
@SuppressWarnings("unused") //invoked by benchmarking framework
43+
public class DateFormatterFromBenchmark {
44+
45+
private final TemporalAccessor accessor = DateFormatter.forPattern("epoch_millis").parse("1234567890");
46+
47+
@Benchmark
48+
public TemporalAccessor benchmarkFrom() {
49+
// benchmark an accessor that does not contain a timezone
50+
// this used to throw an exception earlier and thus was very very slow
51+
return DateFormatters.from(accessor);
52+
}
53+
}

build.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ task verifyVersions {
159159
* the enabled state of every bwc task. It should be set back to true
160160
* after the backport of the backcompat code is complete.
161161
*/
162-
final boolean bwc_tests_enabled = true
163-
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
162+
final boolean bwc_tests_enabled = false
163+
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/37899" /* place a PR link here when committing bwc changes */
164164
if (bwc_tests_enabled == false) {
165165
if (bwc_tests_disabled_issue.isEmpty()) {
166166
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
@@ -201,7 +201,7 @@ allprojects {
201201
}
202202

203203
/* Sets up the dependencies that we build as part of this project but
204-
register as thought they were external to resolve internally. We register
204+
register as though they were external to resolve internally. We register
205205
them as external dependencies so the build plugin that we use can be used
206206
to build elasticsearch plugins outside of the elasticsearch source tree. */
207207
ext.projectSubstitutions = [
@@ -214,6 +214,7 @@ allprojects {
214214
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
215215
"org.elasticsearch:elasticsearch-geo:${version}": ':libs:elasticsearch-geo',
216216
"org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
217+
"org.elasticsearch:elasticsearch-ssl-config:${version}": ':libs:elasticsearch-ssl-config',
217218
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
218219
"org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',
219220
"org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}": ':client:rest-high-level',

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

+5-8
Original file line numberDiff line numberDiff line change
@@ -373,18 +373,15 @@ class ClusterFormationTasks {
373373
'path.repo' : "${node.sharedDir}/repo",
374374
'path.shared_data' : "${node.sharedDir}/",
375375
// Define a node attribute so we can test that it exists
376-
'node.attr.testattr' : 'test'
376+
'node.attr.testattr' : 'test',
377+
// Don't wait for state, just start up quickly. This will also allow new and old nodes in the BWC case to become the master
378+
'discovery.initial_state_timeout' : '0s'
377379
]
378380
int minimumMasterNodes = node.config.minimumMasterNodes.call()
379-
if (minimumMasterNodes > 0) {
381+
if (node.nodeVersion.before("7.0.0") && minimumMasterNodes > 0) {
380382
esConfig['discovery.zen.minimum_master_nodes'] = minimumMasterNodes
381383
}
382-
if (minimumMasterNodes > 1) {
383-
// don't wait for state.. just start up quickly
384-
// this will also allow new and old nodes in the BWC case to become the master
385-
esConfig['discovery.initial_state_timeout'] = '0s'
386-
}
387-
if (esConfig.containsKey('discovery.zen.master_election.wait_for_joins_timeout') == false) {
384+
if (node.nodeVersion.before("7.0.0") && esConfig.containsKey('discovery.zen.master_election.wait_for_joins_timeout') == false) {
388385
// If a node decides to become master based on partial information from the pinging, don't let it hang for 30 seconds to correct
389386
// its mistake. Instead, only wait 5s to do another round of pinging.
390387
// This is necessary since we use 30s as the default timeout in REST requests waiting for cluster formation

buildSrc/version.properties

+4-7
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ joda = 2.10.1
2121
# test dependencies
2222
randomizedrunner = 2.7.1
2323
junit = 4.12
24-
httpclient = 4.5.2
25-
# When updating httpcore, please also update server/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy
26-
httpcore = 4.4.5
27-
# When updating httpasyncclient, please also update server/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy
28-
httpasyncclient = 4.1.2
24+
httpclient = 4.5.7
25+
httpcore = 4.4.11
26+
httpasyncclient = 4.1.4
2927
commonslogging = 1.1.3
30-
commonscodec = 1.10
28+
commonscodec = 1.11
3129
hamcrest = 1.3
3230
securemock = 1.2
33-
# When updating mocksocket, please also update server/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy
3431
mocksocket = 1.2
3532

3633
# benchmark dependencies

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

+15
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
7777
import org.elasticsearch.index.reindex.ReindexRequest;
7878
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
79+
import org.elasticsearch.index.seqno.SequenceNumbers;
7980
import org.elasticsearch.rest.action.search.RestSearchAction;
8081
import org.elasticsearch.script.mustache.MultiSearchTemplateRequest;
8182
import org.elasticsearch.script.mustache.SearchTemplateRequest;
@@ -885,6 +886,20 @@ Params withVersionType(VersionType versionType) {
885886
return this;
886887
}
887888

889+
Params withIfSeqNo(long ifSeqNo) {
890+
if (ifSeqNo != SequenceNumbers.UNASSIGNED_SEQ_NO) {
891+
return putParam("if_seq_no", Long.toString(ifSeqNo));
892+
}
893+
return this;
894+
}
895+
896+
Params withIfPrimaryTerm(long ifPrimaryTerm) {
897+
if (ifPrimaryTerm != SequenceNumbers.UNASSIGNED_PRIMARY_TERM) {
898+
return putParam("if_primary_term", Long.toString(ifPrimaryTerm));
899+
}
900+
return this;
901+
}
902+
888903
Params withWaitForActiveShards(ActiveShardCount activeShardCount) {
889904
return withWaitForActiveShards(activeShardCount, ActiveShardCount.DEFAULT);
890905
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1671,15 +1671,16 @@ protected final ElasticsearchStatusException parseResponseException(ResponseExce
16711671
Response response = responseException.getResponse();
16721672
HttpEntity entity = response.getEntity();
16731673
ElasticsearchStatusException elasticsearchException;
1674+
RestStatus restStatus = RestStatus.fromCode(response.getStatusLine().getStatusCode());
1675+
16741676
if (entity == null) {
16751677
elasticsearchException = new ElasticsearchStatusException(
1676-
responseException.getMessage(), RestStatus.fromCode(response.getStatusLine().getStatusCode()), responseException);
1678+
responseException.getMessage(), restStatus, responseException);
16771679
} else {
16781680
try {
16791681
elasticsearchException = parseEntity(entity, BytesRestResponse::errorFromXContent);
16801682
elasticsearchException.addSuppressed(responseException);
16811683
} catch (Exception e) {
1682-
RestStatus restStatus = RestStatus.fromCode(response.getStatusLine().getStatusCode());
16831684
elasticsearchException = new ElasticsearchStatusException("Unable to parse response body", restStatus, responseException);
16841685
elasticsearchException.addSuppressed(e);
16851686
}

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ static Request putWatch(PutWatchRequest putWatchRequest) {
6969
.build();
7070

7171
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
72-
RequestConverters.Params params = new RequestConverters.Params(request).withVersion(putWatchRequest.getVersion());
72+
RequestConverters.Params params = new RequestConverters.Params(request)
73+
.withVersion(putWatchRequest.getVersion())
74+
.withIfSeqNo(putWatchRequest.ifSeqNo())
75+
.withIfPrimaryTerm(putWatchRequest.ifPrimaryTerm());
7376
if (putWatchRequest.isActive() == false) {
7477
params.putParam("active", "false");
7578
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class AllocateAction implements LifecycleAction, ToXContentObject {
4040
static final ParseField REQUIRE_FIELD = new ParseField("require");
4141

4242
@SuppressWarnings("unchecked")
43-
private static final ConstructingObjectParser<AllocateAction, Void> PARSER = new ConstructingObjectParser<>(NAME,
43+
private static final ConstructingObjectParser<AllocateAction, Void> PARSER = new ConstructingObjectParser<>(NAME, true,
4444
a -> new AllocateAction((Integer) a[0], (Map<String, String>) a[1], (Map<String, String>) a[2], (Map<String, String>) a[3]));
4545

4646
static {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class DeleteAction implements LifecycleAction, ToXContentObject {
3131
public static final String NAME = "delete";
3232

33-
private static final ObjectParser<DeleteAction, Void> PARSER = new ObjectParser<>(NAME, DeleteAction::new);
33+
private static final ObjectParser<DeleteAction, Void> PARSER = new ObjectParser<>(NAME, true, DeleteAction::new);
3434

3535
public static DeleteAction parse(XContentParser parser) {
3636
return PARSER.apply(parser, null);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class ForceMergeAction implements LifecycleAction, ToXContentObject {
3333
private static final ParseField MAX_NUM_SEGMENTS_FIELD = new ParseField("max_num_segments");
3434

3535
private static final ConstructingObjectParser<ForceMergeAction, Void> PARSER = new ConstructingObjectParser<>(NAME,
36-
false, a -> {
36+
true, a -> {
3737
int maxNumSegments = (int) a[0];
3838
return new ForceMergeAction(maxNumSegments);
3939
});

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
public class FreezeAction implements LifecycleAction, ToXContentObject {
3030
public static final String NAME = "freeze";
3131

32-
private static final ObjectParser<FreezeAction, Void> PARSER = new ObjectParser<>(NAME, FreezeAction::new);
32+
private static final ObjectParser<FreezeAction, Void> PARSER = new ObjectParser<>(NAME, true, FreezeAction::new);
3333

3434
public static FreezeAction parse(XContentParser parser) {
3535
return PARSER.apply(parser, null);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class LifecycleManagementStatusResponse {
3434
private static final String OPERATION_MODE = "operation_mode";
3535
@SuppressWarnings("unchecked")
3636
private static final ConstructingObjectParser<LifecycleManagementStatusResponse, Void> PARSER = new ConstructingObjectParser<>(
37-
OPERATION_MODE, a -> new LifecycleManagementStatusResponse((String) a[0]));
37+
OPERATION_MODE, true, a -> new LifecycleManagementStatusResponse((String) a[0]));
3838

3939
static {
4040
PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField(OPERATION_MODE));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class LifecyclePolicy implements ToXContentObject {
4444
static final ParseField PHASES_FIELD = new ParseField("phases");
4545

4646
@SuppressWarnings("unchecked")
47-
public static ConstructingObjectParser<LifecyclePolicy, String> PARSER = new ConstructingObjectParser<>("lifecycle_policy", false,
47+
public static ConstructingObjectParser<LifecyclePolicy, String> PARSER = new ConstructingObjectParser<>("lifecycle_policy", true,
4848
(a, name) -> {
4949
List<Phase> phases = (List<Phase>) a[0];
5050
Map<String, Phase> phaseMap = phases.stream().collect(Collectors.toMap(Phase::getName, Function.identity()));

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public class LifecyclePolicyMetadata implements ToXContentObject {
3838
static final ParseField MODIFIED_DATE = new ParseField("modified_date");
3939

4040
@SuppressWarnings("unchecked")
41-
public static final ConstructingObjectParser<LifecyclePolicyMetadata, String> PARSER = new ConstructingObjectParser<>("policy_metadata",
41+
public static final ConstructingObjectParser<LifecyclePolicyMetadata, String> PARSER = new ConstructingObjectParser<>(
42+
"policy_metadata", true,
4243
a -> {
4344
LifecyclePolicy policy = (LifecyclePolicy) a[0];
4445
return new LifecyclePolicyMetadata(policy, (long) a[1], ZonedDateTime.parse((String) a[2]).toInstant().toEpochMilli());

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class Phase implements ToXContentObject {
4444
static final ParseField ACTIONS_FIELD = new ParseField("actions");
4545

4646
@SuppressWarnings("unchecked")
47-
private static final ConstructingObjectParser<Phase, String> PARSER = new ConstructingObjectParser<>("phase", false,
47+
private static final ConstructingObjectParser<Phase, String> PARSER = new ConstructingObjectParser<>("phase", true,
4848
(a, name) -> new Phase(name, (TimeValue) a[0], ((List<LifecycleAction>) a[1]).stream()
4949
.collect(Collectors.toMap(LifecycleAction::getName, Function.identity()))));
5050
static {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class PhaseExecutionInfo implements ToXContentObject {
4040
private static final ParseField MODIFIED_DATE_IN_MILLIS_FIELD = new ParseField("modified_date_in_millis");
4141

4242
private static final ConstructingObjectParser<PhaseExecutionInfo, String> PARSER = new ConstructingObjectParser<>(
43-
"phase_execution_info", false,
43+
"phase_execution_info", true,
4444
(a, name) -> new PhaseExecutionInfo((String) a[0], (Phase) a[1], (long) a[2], (long) a[3]));
4545
static {
4646
PARSER.declareString(ConstructingObjectParser.constructorArg(), POLICY_NAME_FIELD);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
public class ReadOnlyAction implements LifecycleAction, ToXContentObject {
3030
public static final String NAME = "readonly";
3131

32-
private static final ObjectParser<ReadOnlyAction, Void> PARSER = new ObjectParser<>(NAME, false, ReadOnlyAction::new);
32+
private static final ObjectParser<ReadOnlyAction, Void> PARSER = new ObjectParser<>(NAME, true, ReadOnlyAction::new);
3333

3434
public static ReadOnlyAction parse(XContentParser parser) {
3535
return PARSER.apply(parser, null);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class RolloverAction implements LifecycleAction, ToXContentObject {
3838
private static final ParseField MAX_DOCS_FIELD = new ParseField("max_docs");
3939
private static final ParseField MAX_AGE_FIELD = new ParseField("max_age");
4040

41-
private static final ConstructingObjectParser<RolloverAction, Void> PARSER = new ConstructingObjectParser<>(NAME,
41+
private static final ConstructingObjectParser<RolloverAction, Void> PARSER = new ConstructingObjectParser<>(NAME, true,
4242
a -> new RolloverAction((ByteSizeValue) a[0], (TimeValue) a[1], (Long) a[2]));
4343
static {
4444
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static SetPriorityAction parse(XContentParser parser) {
5555
}
5656

5757
public SetPriorityAction(@Nullable Integer recoveryPriority) {
58-
if (recoveryPriority != null && recoveryPriority <= 0) {
58+
if (recoveryPriority != null && recoveryPriority < 0) {
5959
throw new IllegalArgumentException("[" + RECOVERY_PRIORITY_FIELD.getPreferredName() + "] must be 0 or greater");
6060
}
6161
this.recoveryPriority = recoveryPriority;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class ShrinkAction implements LifecycleAction, ToXContentObject {
3333
private static final ParseField NUMBER_OF_SHARDS_FIELD = new ParseField("number_of_shards");
3434

3535
private static final ConstructingObjectParser<ShrinkAction, Void> PARSER =
36-
new ConstructingObjectParser<>(NAME, a -> new ShrinkAction((Integer) a[0]));
36+
new ConstructingObjectParser<>(NAME, true, a -> new ShrinkAction((Integer) a[0]));
3737

3838
static {
3939
PARSER.declareInt(ConstructingObjectParser.constructorArg(), NUMBER_OF_SHARDS_FIELD);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
public class UnfollowAction implements LifecycleAction, ToXContentObject {
3232
public static final String NAME = "unfollow";
3333

34-
private static final ObjectParser<UnfollowAction, Void> PARSER = new ObjectParser<>(NAME, UnfollowAction::new);
34+
private static final ObjectParser<UnfollowAction, Void> PARSER = new ObjectParser<>(NAME, true, UnfollowAction::new);
3535

3636
public UnfollowAction() {}
3737

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/job/util/TimeUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static Date parseTimeField(XContentParser parser, String fieldName) throw
3939
if (parser.currentToken() == XContentParser.Token.VALUE_NUMBER) {
4040
return new Date(parser.longValue());
4141
} else if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
42-
return new Date(DateFormatters.toZonedDateTime(DateTimeFormatter.ISO_INSTANT.parse(parser.text())).toInstant().toEpochMilli());
42+
return new Date(DateFormatters.from(DateTimeFormatter.ISO_INSTANT.parse(parser.text())).toInstant().toEpochMilli());
4343
}
4444
throw new IllegalArgumentException(
4545
"unexpected token [" + parser.currentToken() + "] for [" + fieldName + "]");

0 commit comments

Comments
 (0)