Skip to content

Commit 7e7c5db

Browse files
authored
Rename max_single_primary_size to max_primary_shard_size (#69239)
1 parent db6b3b8 commit 7e7c5db

File tree

45 files changed

+325
-325
lines changed

Some content is hidden

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

45 files changed

+325
-325
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ tasks.register("verifyVersions") {
189189
* after the backport of the backcompat code is complete.
190190
*/
191191

192-
boolean bwc_tests_enabled = true
193-
String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
192+
boolean bwc_tests_enabled = false
193+
String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/69239" /* place a PR link here when committing bwc changes */
194194
/*
195195
* FIPS 140-2 behavior was fixed in 7.11.0. Before that there is no way to run elasticsearch in a
196196
* JVM that is properly configured to be in fips mode with BCFIPS. For now we need to disable

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class RolloverAction implements LifecycleAction, ToXContentObject {
2424
public static final String NAME = "rollover";
2525
private static final ParseField MAX_SIZE_FIELD = new ParseField("max_size");
26-
private static final ParseField MAX_SINGLE_PRIMARY_SIZE_FIELD = new ParseField("max_single_primary_size");
26+
private static final ParseField MAX_PRIMARY_SHARD_SIZE_FIELD = new ParseField("max_primary_shard_size");
2727
private static final ParseField MAX_AGE_FIELD = new ParseField("max_age");
2828
private static final ParseField MAX_DOCS_FIELD = new ParseField("max_docs");
2929

@@ -35,29 +35,29 @@ public class RolloverAction implements LifecycleAction, ToXContentObject {
3535
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_SIZE_FIELD.getPreferredName()),
3636
MAX_SIZE_FIELD, ValueType.VALUE);
3737
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
38-
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_SINGLE_PRIMARY_SIZE_FIELD.getPreferredName()),
39-
MAX_SINGLE_PRIMARY_SIZE_FIELD, ValueType.VALUE);
38+
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_PRIMARY_SHARD_SIZE_FIELD.getPreferredName()),
39+
MAX_PRIMARY_SHARD_SIZE_FIELD, ValueType.VALUE);
4040
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
4141
(p, c) -> TimeValue.parseTimeValue(p.text(), MAX_AGE_FIELD.getPreferredName()),
4242
MAX_AGE_FIELD, ValueType.VALUE);
4343
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), MAX_DOCS_FIELD);
4444
}
4545

4646
private final ByteSizeValue maxSize;
47-
private final ByteSizeValue maxSinglePrimarySize;
47+
private final ByteSizeValue maxPrimaryShardSize;
4848
private final TimeValue maxAge;
4949
private final Long maxDocs;
5050

5151
public static RolloverAction parse(XContentParser parser) {
5252
return PARSER.apply(parser, null);
5353
}
5454

55-
public RolloverAction(ByteSizeValue maxSize, ByteSizeValue maxSinglePrimarySize, TimeValue maxAge, Long maxDocs) {
56-
if (maxSize == null && maxSinglePrimarySize == null && maxAge == null && maxDocs == null) {
55+
public RolloverAction(ByteSizeValue maxSize, ByteSizeValue maxPrimaryShardSize, TimeValue maxAge, Long maxDocs) {
56+
if (maxSize == null && maxPrimaryShardSize == null && maxAge == null && maxDocs == null) {
5757
throw new IllegalArgumentException("At least one rollover condition must be set.");
5858
}
5959
this.maxSize = maxSize;
60-
this.maxSinglePrimarySize = maxSinglePrimarySize;
60+
this.maxPrimaryShardSize = maxPrimaryShardSize;
6161
this.maxAge = maxAge;
6262
this.maxDocs = maxDocs;
6363
}
@@ -66,8 +66,8 @@ public ByteSizeValue getMaxSize() {
6666
return maxSize;
6767
}
6868

69-
public ByteSizeValue getMaxSinglePrimarySize() {
70-
return maxSinglePrimarySize;
69+
public ByteSizeValue getMaxPrimaryShardSize() {
70+
return maxPrimaryShardSize;
7171
}
7272

7373
public TimeValue getMaxAge() {
@@ -89,8 +89,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
8989
if (maxSize != null) {
9090
builder.field(MAX_SIZE_FIELD.getPreferredName(), maxSize.getStringRep());
9191
}
92-
if (maxSinglePrimarySize != null) {
93-
builder.field(MAX_SINGLE_PRIMARY_SIZE_FIELD.getPreferredName(), maxSinglePrimarySize.getStringRep());
92+
if (maxPrimaryShardSize != null) {
93+
builder.field(MAX_PRIMARY_SHARD_SIZE_FIELD.getPreferredName(), maxPrimaryShardSize.getStringRep());
9494
}
9595
if (maxAge != null) {
9696
builder.field(MAX_AGE_FIELD.getPreferredName(), maxAge.getStringRep());
@@ -104,7 +104,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
104104

105105
@Override
106106
public int hashCode() {
107-
return Objects.hash(maxSize, maxSinglePrimarySize, maxAge, maxDocs);
107+
return Objects.hash(maxSize, maxPrimaryShardSize, maxAge, maxDocs);
108108
}
109109

110110
@Override
@@ -117,7 +117,7 @@ public boolean equals(Object obj) {
117117
}
118118
RolloverAction other = (RolloverAction) obj;
119119
return Objects.equals(maxSize, other.maxSize) &&
120-
Objects.equals(maxSinglePrimarySize, other.maxSinglePrimarySize) &&
120+
Objects.equals(maxPrimaryShardSize, other.maxPrimaryShardSize) &&
121121
Objects.equals(maxAge, other.maxAge) &&
122122
Objects.equals(maxDocs, other.maxDocs);
123123
}

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,37 @@
2323
public class ShrinkAction implements LifecycleAction, ToXContentObject {
2424
public static final String NAME = "shrink";
2525
private static final ParseField NUMBER_OF_SHARDS_FIELD = new ParseField("number_of_shards");
26-
private static final ParseField MAX_SINGLE_PRIMARY_SIZE = new ParseField("max_single_primary_size");
26+
private static final ParseField MAX_PRIMARY_SHARD_SIZE = new ParseField("max_primary_shard_size");
2727

2828
private static final ConstructingObjectParser<ShrinkAction, Void> PARSER =
2929
new ConstructingObjectParser<>(NAME, true, a -> new ShrinkAction((Integer) a[0], (ByteSizeValue) a[1]));
3030

3131
static {
3232
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), NUMBER_OF_SHARDS_FIELD);
3333
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
34-
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_SINGLE_PRIMARY_SIZE.getPreferredName()),
35-
MAX_SINGLE_PRIMARY_SIZE, ObjectParser.ValueType.STRING);
34+
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_PRIMARY_SHARD_SIZE.getPreferredName()),
35+
MAX_PRIMARY_SHARD_SIZE, ObjectParser.ValueType.STRING);
3636
}
3737

3838
private Integer numberOfShards;
39-
private ByteSizeValue maxSinglePrimarySize;
39+
private ByteSizeValue maxPrimaryShardSize;
4040

4141
public static ShrinkAction parse(XContentParser parser) throws IOException {
4242
return PARSER.parse(parser, null);
4343
}
4444

45-
public ShrinkAction(@Nullable Integer numberOfShards, ByteSizeValue maxSinglePrimarySize) {
46-
if (numberOfShards != null && maxSinglePrimarySize != null) {
47-
throw new IllegalArgumentException("Cannot set both [number_of_shards] and [max_single_primary_size]");
45+
public ShrinkAction(@Nullable Integer numberOfShards, ByteSizeValue maxPrimaryShardSize) {
46+
if (numberOfShards != null && maxPrimaryShardSize != null) {
47+
throw new IllegalArgumentException("Cannot set both [number_of_shards] and [max_primary_shard_size]");
4848
}
49-
if (numberOfShards == null && maxSinglePrimarySize == null) {
50-
throw new IllegalArgumentException("Either [number_of_shards] or [max_single_primary_size] must be set");
49+
if (numberOfShards == null && maxPrimaryShardSize == null) {
50+
throw new IllegalArgumentException("Either [number_of_shards] or [max_primary_shard_size] must be set");
5151
}
52-
if (maxSinglePrimarySize != null) {
53-
if (maxSinglePrimarySize.getBytes() <= 0) {
54-
throw new IllegalArgumentException("[max_single_primary_size] must be greater than 0");
52+
if (maxPrimaryShardSize != null) {
53+
if (maxPrimaryShardSize.getBytes() <= 0) {
54+
throw new IllegalArgumentException("[max_primary_shard_size] must be greater than 0");
5555
}
56-
this.maxSinglePrimarySize = maxSinglePrimarySize;
56+
this.maxPrimaryShardSize = maxPrimaryShardSize;
5757
} else {
5858
if (numberOfShards <= 0) {
5959
throw new IllegalArgumentException("[" + NUMBER_OF_SHARDS_FIELD.getPreferredName() + "] must be greater than 0");
@@ -66,8 +66,8 @@ Integer getNumberOfShards() {
6666
return numberOfShards;
6767
}
6868

69-
ByteSizeValue getMaxSinglePrimarySize() {
70-
return maxSinglePrimarySize;
69+
ByteSizeValue getMaxPrimaryShardSize() {
70+
return maxPrimaryShardSize;
7171
}
7272

7373
@Override
@@ -81,8 +81,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
8181
if (numberOfShards != null) {
8282
builder.field(NUMBER_OF_SHARDS_FIELD.getPreferredName(), numberOfShards);
8383
}
84-
if (maxSinglePrimarySize != null) {
85-
builder.field(MAX_SINGLE_PRIMARY_SIZE.getPreferredName(), maxSinglePrimarySize);
84+
if (maxPrimaryShardSize != null) {
85+
builder.field(MAX_PRIMARY_SHARD_SIZE.getPreferredName(), maxPrimaryShardSize);
8686
}
8787
builder.endObject();
8888
return builder;
@@ -95,12 +95,12 @@ public boolean equals(Object o) {
9595
ShrinkAction that = (ShrinkAction) o;
9696

9797
return Objects.equals(numberOfShards, that.numberOfShards) &&
98-
Objects.equals(maxSinglePrimarySize, that.maxSinglePrimarySize);
98+
Objects.equals(maxPrimaryShardSize, that.maxPrimaryShardSize);
9999
}
100100

101101
@Override
102102
public int hashCode() {
103-
return Objects.hash(numberOfShards, maxSinglePrimarySize);
103+
return Objects.hash(numberOfShards, maxPrimaryShardSize);
104104
}
105105

106106
@Override

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class ResizeRequest extends TimedRequest implements Validatable, ToXConte
3535
private final String targetIndex;
3636
private Settings settings = Settings.EMPTY;
3737
private Set<Alias> aliases = new HashSet<>();
38-
private ByteSizeValue maxSinglePrimarySize;
38+
private ByteSizeValue maxPrimaryShardSize;
3939

4040
/**
4141
* Creates a new resize request
@@ -79,17 +79,17 @@ public Set<Alias> getAliases() {
7979
}
8080

8181
/**
82-
* Sets the max single primary shard size of the target index
82+
* Sets the max primary shard size of the target index
8383
*/
84-
public void setMaxSinglePrimarySize(ByteSizeValue maxSinglePrimarySize) {
85-
this.maxSinglePrimarySize = maxSinglePrimarySize;
84+
public void setMaxPrimaryShardSize(ByteSizeValue maxPrimaryShardSize) {
85+
this.maxPrimaryShardSize = maxPrimaryShardSize;
8686
}
8787

8888
/**
89-
* Return the max single primary shard size of the target index
89+
* Return the max primary shard size of the target index
9090
*/
91-
public ByteSizeValue getMaxSinglePrimarySize() {
92-
return maxSinglePrimarySize;
91+
public ByteSizeValue getMaxPrimaryShardSize() {
92+
return maxPrimaryShardSize;
9393
}
9494

9595
@Override

client/rest-high-level/src/main/java/org/elasticsearch/client/indices/rollover/RolloverRequest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.elasticsearch.action.admin.indices.rollover.Condition;
1111
import org.elasticsearch.action.admin.indices.rollover.MaxAgeCondition;
1212
import org.elasticsearch.action.admin.indices.rollover.MaxDocsCondition;
13-
import org.elasticsearch.action.admin.indices.rollover.MaxSinglePrimarySizeCondition;
13+
import org.elasticsearch.action.admin.indices.rollover.MaxPrimaryShardSizeCondition;
1414
import org.elasticsearch.action.admin.indices.rollover.MaxSizeCondition;
1515
import org.elasticsearch.client.TimedRequest;
1616
import org.elasticsearch.client.indices.CreateIndexRequest;
@@ -111,12 +111,12 @@ public RolloverRequest addMaxIndexSizeCondition(ByteSizeValue size) {
111111
/**
112112
* Adds a size-based condition to check if the size of the largest primary shard is at least <code>size</code>.
113113
*/
114-
public RolloverRequest addMaxSinglePrimarySizeCondition(ByteSizeValue size) {
115-
MaxSinglePrimarySizeCondition maxSinglePrimarySizeCondition = new MaxSinglePrimarySizeCondition(size);
116-
if (this.conditions.containsKey(maxSinglePrimarySizeCondition.name())) {
117-
throw new IllegalArgumentException(maxSinglePrimarySizeCondition + " condition is already set");
114+
public RolloverRequest addMaxPrimaryShardSizeCondition(ByteSizeValue size) {
115+
MaxPrimaryShardSizeCondition maxPrimaryShardSizeCondition = new MaxPrimaryShardSizeCondition(size);
116+
if (this.conditions.containsKey(maxPrimaryShardSizeCondition.name())) {
117+
throw new IllegalArgumentException(maxPrimaryShardSizeCondition + " condition is already set");
118118
}
119-
this.conditions.put(maxSinglePrimarySizeCondition.name(), maxSinglePrimarySizeCondition);
119+
this.conditions.put(maxPrimaryShardSizeCondition.name(), maxPrimaryShardSizeCondition);
120120
return this;
121121
}
122122

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ public void testRollover() throws IOException {
958958
rolloverRequest.getCreateIndexRequest().mapping(mappings, XContentType.JSON);
959959
rolloverRequest.dryRun(false);
960960
rolloverRequest.addMaxIndexSizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB));
961-
rolloverRequest.addMaxSinglePrimarySizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB));
961+
rolloverRequest.addMaxPrimaryShardSizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB));
962962
RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover,
963963
highLevelClient().indices()::rolloverAsync);
964964
assertTrue(rolloverResponse.isRolledOver());
@@ -968,7 +968,7 @@ public void testRollover() throws IOException {
968968
assertTrue(conditionStatus.get("[max_docs: 1]"));
969969
assertTrue(conditionStatus.get("[max_age: 1ms]"));
970970
assertFalse(conditionStatus.get("[max_size: 1mb]"));
971-
assertFalse(conditionStatus.get("[max_single_primary_size: 1mb]"));
971+
assertFalse(conditionStatus.get("[max_primary_shard_size: 1mb]"));
972972
assertEquals("test", rolloverResponse.getOldIndex());
973973
assertEquals("test_new", rolloverResponse.getNewIndex());
974974
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ private void resizeTest(ResizeType resizeType, CheckedFunction<ResizeRequest, Re
646646
resizeRequest.setSettings(Settings.builder().put("index.number_of_shards", 2).build());
647647
}
648648
if (resizeType == ResizeType.SHRINK) {
649-
resizeRequest.setMaxSinglePrimarySize(new ByteSizeValue(randomIntBetween(1, 100)));
649+
resizeRequest.setMaxPrimaryShardSize(new ByteSizeValue(randomIntBetween(1, 100)));
650650
}
651651

652652
Request request = function.apply(resizeRequest);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,9 +1607,9 @@ public void testShrinkIndex() throws Exception {
16071607
} else {
16081608
request.getTargetIndexRequest().settings(Settings.builder()
16091609
.putNull("index.routing.allocation.require._name"));
1610-
// tag::shrink-index-request-maxSinglePrimarySize
1611-
request.setMaxSinglePrimarySize(new ByteSizeValue(50, ByteSizeUnit.GB)); // <1>
1612-
// end::shrink-index-request-maxSinglePrimarySize
1610+
// tag::shrink-index-request-maxPrimaryShardSize
1611+
request.setMaxPrimaryShardSize(new ByteSizeValue(50, ByteSizeUnit.GB)); // <1>
1612+
// end::shrink-index-request-maxPrimaryShardSize
16131613
}
16141614
// tag::shrink-index-request-aliases
16151615
request.getTargetIndexRequest().alias(new Alias("target_alias")); // <1>
@@ -1802,7 +1802,7 @@ public void testRolloverIndex() throws Exception {
18021802
request.addMaxIndexAgeCondition(new TimeValue(7, TimeUnit.DAYS)); // <2>
18031803
request.addMaxIndexDocsCondition(1000); // <3>
18041804
request.addMaxIndexSizeCondition(new ByteSizeValue(5, ByteSizeUnit.GB)); // <4>
1805-
request.addMaxSinglePrimarySizeCondition(new ByteSizeValue(2, ByteSizeUnit.GB)); // <5>
1805+
request.addMaxPrimaryShardSizeCondition(new ByteSizeValue(2, ByteSizeUnit.GB)); // <5>
18061806
// end::rollover-index-request
18071807

18081808
// tag::rollover-index-request-timeout

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ static RolloverAction randomInstance() {
3434
ByteSizeUnit maxSizeUnit = randomFrom(ByteSizeUnit.values());
3535
ByteSizeValue maxSize = randomBoolean()
3636
? null : new ByteSizeValue(randomNonNegativeLong() / maxSizeUnit.toBytes(1), maxSizeUnit);
37-
ByteSizeUnit maxSinglePrimarySizeUnit = randomFrom(ByteSizeUnit.values());
38-
ByteSizeValue maxSinglePrimarySize = randomBoolean()
39-
? null : new ByteSizeValue(randomNonNegativeLong() / maxSinglePrimarySizeUnit.toBytes(1), maxSinglePrimarySizeUnit);
37+
ByteSizeUnit maxPrimaryShardSizeUnit = randomFrom(ByteSizeUnit.values());
38+
ByteSizeValue maxPrimaryShardSize = randomBoolean()
39+
? null : new ByteSizeValue(randomNonNegativeLong() / maxPrimaryShardSizeUnit.toBytes(1), maxPrimaryShardSizeUnit);
4040
TimeValue maxAge = randomBoolean()
4141
? null : TimeValue.parseTimeValue(randomPositiveTimeValue(), "rollover_action_test");
42-
Long maxDocs = (maxSize == null && maxSinglePrimarySize == null && maxAge == null || randomBoolean())
42+
Long maxDocs = (maxSize == null && maxPrimaryShardSize == null && maxAge == null || randomBoolean())
4343
? randomNonNegativeLong() : null;
44-
return new RolloverAction(maxSize, maxSinglePrimarySize, maxAge, maxDocs);
44+
return new RolloverAction(maxSize, maxPrimaryShardSize, maxAge, maxDocs);
4545
}
4646

4747
public void testNoConditions() {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public void testNonPositiveShardNumber() {
4545
assertThat(e.getMessage(), equalTo("[number_of_shards] must be greater than 0"));
4646
}
4747

48-
public void testMaxSinglePrimarySize() {
49-
ByteSizeValue maxSinglePrimarySize1 = new ByteSizeValue(10);
50-
Exception e1 = expectThrows(Exception.class, () -> new ShrinkAction(randomIntBetween(1, 100), maxSinglePrimarySize1));
51-
assertThat(e1.getMessage(), equalTo("Cannot set both [number_of_shards] and [max_single_primary_size]"));
52-
53-
ByteSizeValue maxSinglePrimarySize2 = new ByteSizeValue(0);
54-
Exception e2 = expectThrows(Exception.class, () -> new org.elasticsearch.client.ilm.ShrinkAction(null, maxSinglePrimarySize2));
55-
assertThat(e2.getMessage(), equalTo("[max_single_primary_size] must be greater than 0"));
48+
public void testMaxPrimaryShardSize() {
49+
ByteSizeValue maxPrimaryShardSize1 = new ByteSizeValue(10);
50+
Exception e1 = expectThrows(Exception.class, () -> new ShrinkAction(randomIntBetween(1, 100), maxPrimaryShardSize1));
51+
assertThat(e1.getMessage(), equalTo("Cannot set both [number_of_shards] and [max_primary_shard_size]"));
52+
53+
ByteSizeValue maxPrimaryShardSize2 = new ByteSizeValue(0);
54+
Exception e2 = expectThrows(Exception.class, () -> new org.elasticsearch.client.ilm.ShrinkAction(null, maxPrimaryShardSize2));
55+
assertThat(e2.getMessage(), equalTo("[max_primary_shard_size] must be greater than 0"));
5656
}
5757
}

0 commit comments

Comments
 (0)