Skip to content

Commit 65060ed

Browse files
committed
Merge remote-tracking branch 'elastic/master' into replication-tracker-primary-term
* elastic/master: Mute failing date index name processor test Reenable BWC testing after retention lease stats (elastic#38062) Move watcher to use seq# and primary term for concurrency control (elastic#37977) ILM setPriority corrections for a 0 value (elastic#38001) Temporarily disable BWC for retention lease stats (elastic#38049) Skip Shrink when numberOfShards not changed (elastic#37953) Add dispatching to `HandledTransportAction` (elastic#38050) Update httpclient for JDK 11 TLS engine (elastic#37994) Reduce flaxiness of ccr recovery timeouts test (elastic#38035) Fix ILM status to allow unknown fields (elastic#38043) Fix ILM Lifecycle Policy to allow unknown fields (elastic#38041) Update verify repository to allow unknown fields (elastic#37619) [ML] Datafeed deprecation checks (elastic#38026) Deprecate minimum_master_nodes (elastic#37868)
2 parents 72e2e7b + 89bffc2 commit 65060ed

File tree

186 files changed

+1634
-588
lines changed

Some content is hidden

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

186 files changed

+1634
-588
lines changed

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

Lines changed: 5 additions & 8 deletions
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

Lines changed: 4 additions & 7 deletions
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

Lines changed: 15 additions & 0 deletions
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/WatcherRequestConverters.java

Lines changed: 4 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/watcher/GetWatchResponse.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@
3131
import java.util.Map;
3232
import java.util.Objects;
3333

34+
import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_PRIMARY_TERM;
35+
import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO;
36+
3437
public class GetWatchResponse {
3538
private final String id;
3639
private final long version;
40+
private final long seqNo;
41+
private final long primaryTerm;
3742
private final WatchStatus status;
3843

3944
private final BytesReference source;
@@ -43,15 +48,18 @@ public class GetWatchResponse {
4348
* Ctor for missing watch
4449
*/
4550
public GetWatchResponse(String id) {
46-
this(id, Versions.NOT_FOUND, null, null, null);
51+
this(id, Versions.NOT_FOUND, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, null, null, null);
4752
}
4853

49-
public GetWatchResponse(String id, long version, WatchStatus status, BytesReference source, XContentType xContentType) {
54+
public GetWatchResponse(String id, long version, long seqNo, long primaryTerm, WatchStatus status,
55+
BytesReference source, XContentType xContentType) {
5056
this.id = id;
5157
this.version = version;
5258
this.status = status;
5359
this.source = source;
5460
this.xContentType = xContentType;
61+
this.seqNo = seqNo;
62+
this.primaryTerm = primaryTerm;
5563
}
5664

5765
public String getId() {
@@ -62,6 +70,14 @@ public long getVersion() {
6270
return version;
6371
}
6472

73+
public long getSeqNo() {
74+
return seqNo;
75+
}
76+
77+
public long getPrimaryTerm() {
78+
return primaryTerm;
79+
}
80+
6581
public boolean isFound() {
6682
return version != Versions.NOT_FOUND;
6783
}
@@ -111,6 +127,8 @@ public int hashCode() {
111127
private static final ParseField ID_FIELD = new ParseField("_id");
112128
private static final ParseField FOUND_FIELD = new ParseField("found");
113129
private static final ParseField VERSION_FIELD = new ParseField("_version");
130+
private static final ParseField SEQ_NO_FIELD = new ParseField("_seq_no");
131+
private static final ParseField PRIMARY_TERM_FIELD = new ParseField("_primary_term");
114132
private static final ParseField STATUS_FIELD = new ParseField("status");
115133
private static final ParseField WATCH_FIELD = new ParseField("watch");
116134

@@ -119,9 +137,10 @@ public int hashCode() {
119137
a -> {
120138
boolean isFound = (boolean) a[1];
121139
if (isFound) {
122-
XContentBuilder builder = (XContentBuilder) a[4];
140+
XContentBuilder builder = (XContentBuilder) a[6];
123141
BytesReference source = BytesReference.bytes(builder);
124-
return new GetWatchResponse((String) a[0], (long) a[2], (WatchStatus) a[3], source, builder.contentType());
142+
return new GetWatchResponse((String) a[0], (long) a[2], (long) a[3], (long) a[4], (WatchStatus) a[5],
143+
source, builder.contentType());
125144
} else {
126145
return new GetWatchResponse((String) a[0]);
127146
}
@@ -131,6 +150,8 @@ public int hashCode() {
131150
PARSER.declareString(ConstructingObjectParser.constructorArg(), ID_FIELD);
132151
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), FOUND_FIELD);
133152
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), VERSION_FIELD);
153+
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), SEQ_NO_FIELD);
154+
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), PRIMARY_TERM_FIELD);
134155
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(),
135156
(parser, context) -> WatchStatus.parse(parser), STATUS_FIELD);
136157
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(),

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323
import org.elasticsearch.common.bytes.BytesReference;
2424
import org.elasticsearch.common.lucene.uid.Versions;
2525
import org.elasticsearch.common.xcontent.XContentType;
26+
import org.elasticsearch.index.seqno.SequenceNumbers;
2627

2728
import java.util.Objects;
2829
import java.util.regex.Pattern;
2930

31+
import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_PRIMARY_TERM;
32+
import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO;
33+
3034
/**
3135
* This request class contains the data needed to create a watch along with the name of the watch.
3236
* The name of the watch will become the ID of the indexed document.
@@ -40,6 +44,9 @@ public final class PutWatchRequest implements Validatable {
4044
private final XContentType xContentType;
4145
private boolean active = true;
4246
private long version = Versions.MATCH_ANY;
47+
private long ifSeqNo = SequenceNumbers.UNASSIGNED_SEQ_NO;
48+
private long ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM;
49+
4350

4451
public PutWatchRequest(String id, BytesReference source, XContentType xContentType) {
4552
Objects.requireNonNull(id, "watch id is missing");
@@ -96,6 +103,56 @@ public void setVersion(long version) {
96103
this.version = version;
97104
}
98105

106+
/**
107+
* only performs this put request if the watch's last modification was assigned the given
108+
* sequence number. Must be used in combination with {@link #setIfPrimaryTerm(long)}
109+
*
110+
* If the watch's last modification was assigned a different sequence number a
111+
* {@link org.elasticsearch.index.engine.VersionConflictEngineException} will be thrown.
112+
*/
113+
public PutWatchRequest setIfSeqNo(long seqNo) {
114+
if (seqNo < 0 && seqNo != UNASSIGNED_SEQ_NO) {
115+
throw new IllegalArgumentException("sequence numbers must be non negative. got [" + seqNo + "].");
116+
}
117+
ifSeqNo = seqNo;
118+
return this;
119+
}
120+
121+
/**
122+
* only performs this put request if the watch's last modification was assigned the given
123+
* primary term. Must be used in combination with {@link #setIfSeqNo(long)}
124+
*
125+
* If the watch last modification was assigned a different term a
126+
* {@link org.elasticsearch.index.engine.VersionConflictEngineException} will be thrown.
127+
*/
128+
public PutWatchRequest setIfPrimaryTerm(long term) {
129+
if (term < 0) {
130+
throw new IllegalArgumentException("primary term must be non negative. got [" + term + "]");
131+
}
132+
ifPrimaryTerm = term;
133+
return this;
134+
}
135+
136+
/**
137+
* If set, only perform this put watch request if the watch's last modification was assigned this sequence number.
138+
* If the watch last last modification was assigned a different sequence number a
139+
* {@link org.elasticsearch.index.engine.VersionConflictEngineException} will be thrown.
140+
*/
141+
public long ifSeqNo() {
142+
return ifSeqNo;
143+
}
144+
145+
/**
146+
* If set, only perform this put watch request if the watch's last modification was assigned this primary term.
147+
*
148+
* If the watch's last modification was assigned a different term a
149+
* {@link org.elasticsearch.index.engine.VersionConflictEngineException} will be thrown.
150+
*/
151+
public long ifPrimaryTerm() {
152+
return ifPrimaryTerm;
153+
}
154+
155+
99156
public static boolean isValidId(String id) {
100157
return Strings.isEmpty(id) == false && NO_WS_PATTERN.matcher(id).matches();
101158
}

0 commit comments

Comments
 (0)