Skip to content

Commit 0b3ce96

Browse files
authored
Rename max_single_primary_size to max_primary_shard_size (#69250)
1 parent 9108c72 commit 0b3ce96

File tree

35 files changed

+234
-234
lines changed

35 files changed

+234
-234
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/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
@@ -1213,7 +1213,7 @@ public void testRollover() throws IOException {
12131213
rolloverRequest.getCreateIndexRequest().mapping(mappings, XContentType.JSON);
12141214
rolloverRequest.dryRun(false);
12151215
rolloverRequest.addMaxIndexSizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB));
1216-
rolloverRequest.addMaxSinglePrimarySizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB));
1216+
rolloverRequest.addMaxPrimaryShardSizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB));
12171217
RolloverResponse rolloverResponse = execute(rolloverRequest, highLevelClient().indices()::rollover,
12181218
highLevelClient().indices()::rolloverAsync);
12191219
assertTrue(rolloverResponse.isRolledOver());
@@ -1223,7 +1223,7 @@ public void testRollover() throws IOException {
12231223
assertTrue(conditionStatus.get("[max_docs: 1]"));
12241224
assertTrue(conditionStatus.get("[max_age: 1ms]"));
12251225
assertFalse(conditionStatus.get("[max_size: 1mb]"));
1226-
assertFalse(conditionStatus.get("[max_single_primary_size: 1mb]"));
1226+
assertFalse(conditionStatus.get("[max_primary_shard_size: 1mb]"));
12271227
assertEquals("test", rolloverResponse.getOldIndex());
12281228
assertEquals("test_new", rolloverResponse.getNewIndex());
12291229
}

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
@@ -901,7 +901,7 @@ private void resizeTest(ResizeType resizeType, CheckedFunction<ResizeRequest, Re
901901
resizeRequest.setSettings(Settings.builder().put("index.number_of_shards", 2).build());
902902
}
903903
if (resizeType == ResizeType.SHRINK) {
904-
resizeRequest.setMaxSinglePrimarySize(new ByteSizeValue(randomIntBetween(1, 100)));
904+
resizeRequest.setMaxPrimaryShardSize(new ByteSizeValue(randomIntBetween(1, 100)));
905905
}
906906

907907
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
@@ -1704,9 +1704,9 @@ public void testShrinkIndex() throws Exception {
17041704
} else {
17051705
request.getTargetIndexRequest().settings(Settings.builder()
17061706
.putNull("index.routing.allocation.require._name"));
1707-
// tag::shrink-index-request-maxSinglePrimarySize
1708-
request.setMaxSinglePrimarySize(new ByteSizeValue(50, ByteSizeUnit.GB)); // <1>
1709-
// end::shrink-index-request-maxSinglePrimarySize
1707+
// tag::shrink-index-request-maxPrimaryShardSize
1708+
request.setMaxPrimaryShardSize(new ByteSizeValue(50, ByteSizeUnit.GB)); // <1>
1709+
// end::shrink-index-request-maxPrimaryShardSize
17101710
}
17111711
// tag::shrink-index-request-aliases
17121712
request.getTargetIndexRequest().alias(new Alias("target_alias")); // <1>
@@ -1899,7 +1899,7 @@ public void testRolloverIndex() throws Exception {
18991899
request.addMaxIndexAgeCondition(new TimeValue(7, TimeUnit.DAYS)); // <2>
19001900
request.addMaxIndexDocsCondition(1000); // <3>
19011901
request.addMaxIndexSizeCondition(new ByteSizeValue(5, ByteSizeUnit.GB)); // <4>
1902-
request.addMaxSinglePrimarySizeCondition(new ByteSizeValue(2, ByteSizeUnit.GB)); // <5>
1902+
request.addMaxPrimaryShardSizeCondition(new ByteSizeValue(2, ByteSizeUnit.GB)); // <5>
19031903
// end::rollover-index-request
19041904

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

client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/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 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 ShrinkAction(null, maxPrimaryShardSize2));
55+
assertThat(e2.getMessage(), equalTo("[max_primary_shard_size] must be greater than 0"));
5656
}
5757
}

client/rest-high-level/src/test/java/org/elasticsearch/client/indices/rollover/RolloverRequestTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.elasticsearch.action.admin.indices.rollover.Condition;
1212
import org.elasticsearch.action.admin.indices.rollover.MaxAgeCondition;
1313
import org.elasticsearch.action.admin.indices.rollover.MaxDocsCondition;
14-
import org.elasticsearch.action.admin.indices.rollover.MaxSinglePrimarySizeCondition;
14+
import org.elasticsearch.action.admin.indices.rollover.MaxPrimaryShardSizeCondition;
1515
import org.elasticsearch.action.admin.indices.rollover.MaxSizeCondition;
1616
import org.elasticsearch.common.unit.ByteSizeValue;
1717
import org.elasticsearch.common.unit.TimeValue;
@@ -39,14 +39,14 @@ public void testConstructorAndFieldAssignments() {
3939
MaxAgeCondition maxAgeCondition = new MaxAgeCondition(new TimeValue(10));
4040
MaxDocsCondition maxDocsCondition = new MaxDocsCondition(10000L);
4141
MaxSizeCondition maxSizeCondition = new MaxSizeCondition(new ByteSizeValue(2000));
42-
MaxSinglePrimarySizeCondition maxSinglePrimarySizeCondition = new MaxSinglePrimarySizeCondition(new ByteSizeValue(3000));
42+
MaxPrimaryShardSizeCondition maxPrimaryShardSizeCondition = new MaxPrimaryShardSizeCondition(new ByteSizeValue(3000));
4343
Condition<?>[] expectedConditions = new Condition<?>[]{
44-
maxAgeCondition, maxDocsCondition, maxSizeCondition, maxSinglePrimarySizeCondition
44+
maxAgeCondition, maxDocsCondition, maxSizeCondition, maxPrimaryShardSizeCondition
4545
};
4646
rolloverRequest.addMaxIndexAgeCondition(maxAgeCondition.value());
4747
rolloverRequest.addMaxIndexDocsCondition(maxDocsCondition.value());
4848
rolloverRequest.addMaxIndexSizeCondition(maxSizeCondition.value());
49-
rolloverRequest.addMaxSinglePrimarySizeCondition(maxSinglePrimarySizeCondition.value());
49+
rolloverRequest.addMaxPrimaryShardSizeCondition(maxPrimaryShardSizeCondition.value());
5050
List<Condition<?>> requestConditions = new ArrayList<>(rolloverRequest.getConditions().values());
5151
assertThat(requestConditions, containsInAnyOrder(expectedConditions));
5252
}

client/rest-high-level/src/test/java/org/elasticsearch/client/indices/rollover/RolloverResponseTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.elasticsearch.action.admin.indices.rollover.Condition;
1212
import org.elasticsearch.action.admin.indices.rollover.MaxAgeCondition;
1313
import org.elasticsearch.action.admin.indices.rollover.MaxDocsCondition;
14-
import org.elasticsearch.action.admin.indices.rollover.MaxSinglePrimarySizeCondition;
14+
import org.elasticsearch.action.admin.indices.rollover.MaxPrimaryShardSizeCondition;
1515
import org.elasticsearch.action.admin.indices.rollover.MaxSizeCondition;
1616
import org.elasticsearch.common.unit.ByteSizeValue;
1717
import org.elasticsearch.common.unit.TimeValue;
@@ -39,7 +39,7 @@ public class RolloverResponseTests extends ESTestCase {
3939
conditionSuppliers.add(() -> new MaxAgeCondition(new TimeValue(randomNonNegativeLong())));
4040
conditionSuppliers.add(() -> new MaxDocsCondition(randomNonNegativeLong()));
4141
conditionSuppliers.add(() -> new MaxSizeCondition(new ByteSizeValue(randomNonNegativeLong())));
42-
conditionSuppliers.add(() -> new MaxSinglePrimarySizeCondition(new ByteSizeValue(randomNonNegativeLong())));
42+
conditionSuppliers.add(() -> new MaxPrimaryShardSizeCondition(new ByteSizeValue(randomNonNegativeLong())));
4343
}
4444

4545
public void testFromXContent() throws IOException {

docs/java-rest/high-level/indices/shrink_index.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ include-tagged::{doc-tests-file}[{api}-request-settings]
5656

5757
["source","java",subs="attributes,callouts,macros"]
5858
--------------------------------------------------
59-
include-tagged::{doc-tests-file}[{api}-request-maxSinglePrimarySize]
59+
include-tagged::{doc-tests-file}[{api}-request-maxPrimaryShardSize]
6060
--------------------------------------------------
61-
<1> The max single primary shard size of the target index
61+
<1> The max primary shard size of the target index
6262

6363
["source","java",subs="attributes,callouts,macros"]
6464
--------------------------------------------------

0 commit comments

Comments
 (0)