Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ public Iterator<Setting<?>> settings() {

public static final String KEY_INFERENCE_FIELDS = "field_inference";

public static final String KEY_RESHARDING = "resharding";

public static final String INDEX_STATE_FILE_PREFIX = "state-";

static final TransportVersion STATS_AND_FORECAST_ADDED = TransportVersions.V_8_6_0;
Expand Down Expand Up @@ -654,6 +656,8 @@ public Iterator<Setting<?>> settings() {
private final Double writeLoadForecast;
@Nullable
private final Long shardSizeInBytesForecast;
@Nullable
private final IndexReshardingMetadata reshardingMetadata;

private IndexMetadata(
final Index index,
Expand Down Expand Up @@ -702,7 +706,8 @@ private IndexMetadata(
final IndexVersion indexCompatibilityVersion,
@Nullable final IndexMetadataStats stats,
@Nullable final Double writeLoadForecast,
@Nullable Long shardSizeInBytesForecast
@Nullable Long shardSizeInBytesForecast,
@Nullable IndexReshardingMetadata reshardingMetadata
) {
this.index = index;
this.version = version;
Expand Down Expand Up @@ -761,6 +766,7 @@ private IndexMetadata(
this.writeLoadForecast = writeLoadForecast;
this.shardSizeInBytesForecast = shardSizeInBytesForecast;
assert numberOfShards * routingFactor == routingNumShards : routingNumShards + " must be a multiple of " + numberOfShards;
this.reshardingMetadata = reshardingMetadata;
}

IndexMetadata withMappingMetadata(MappingMetadata mapping) {
Expand Down Expand Up @@ -814,7 +820,8 @@ IndexMetadata withMappingMetadata(MappingMetadata mapping) {
this.indexCompatibilityVersion,
this.stats,
this.writeLoadForecast,
this.shardSizeInBytesForecast
this.shardSizeInBytesForecast,
this.reshardingMetadata
);
}

Expand Down Expand Up @@ -875,7 +882,8 @@ public IndexMetadata withInSyncAllocationIds(int shardId, Set<String> inSyncSet)
this.indexCompatibilityVersion,
this.stats,
this.writeLoadForecast,
this.shardSizeInBytesForecast
this.shardSizeInBytesForecast,
this.reshardingMetadata
);
}

Expand Down Expand Up @@ -934,7 +942,8 @@ public IndexMetadata withIncrementedPrimaryTerm(int shardId) {
this.indexCompatibilityVersion,
this.stats,
this.writeLoadForecast,
this.shardSizeInBytesForecast
this.shardSizeInBytesForecast,
this.reshardingMetadata
);
}

Expand Down Expand Up @@ -994,7 +1003,8 @@ public IndexMetadata withTimestampRanges(IndexLongFieldRange timestampRange, Ind
this.indexCompatibilityVersion,
this.stats,
this.writeLoadForecast,
this.shardSizeInBytesForecast
this.shardSizeInBytesForecast,
this.reshardingMetadata
);
}

Expand Down Expand Up @@ -1049,7 +1059,8 @@ public IndexMetadata withIncrementedVersion() {
this.indexCompatibilityVersion,
this.stats,
this.writeLoadForecast,
this.shardSizeInBytesForecast
this.shardSizeInBytesForecast,
this.reshardingMetadata
);
}

Expand Down Expand Up @@ -1905,6 +1916,7 @@ public static class Builder {
private IndexMetadataStats stats = null;
private Double indexWriteLoadForecast = null;
private Long shardSizeInBytesForecast = null;
private IndexReshardingMetadata reshardingMetadata = null;

public Builder(String index) {
this.index = index;
Expand Down Expand Up @@ -1940,6 +1952,7 @@ public Builder(IndexMetadata indexMetadata) {
this.stats = indexMetadata.stats;
this.indexWriteLoadForecast = indexMetadata.writeLoadForecast;
this.shardSizeInBytesForecast = indexMetadata.shardSizeInBytesForecast;
this.reshardingMetadata = indexMetadata.reshardingMetadata;
}

public Builder index(String index) {
Expand Down Expand Up @@ -2190,6 +2203,11 @@ public Builder putInferenceFields(Map<String, InferenceFieldMetadata> values) {
return this;
}

public Builder reshardingMetadata(IndexReshardingMetadata reshardingMetadata) {
this.reshardingMetadata = reshardingMetadata;
return this;
}

public IndexMetadata build() {
return build(false);
}
Expand Down Expand Up @@ -2389,7 +2407,8 @@ IndexMetadata build(boolean repair) {
SETTING_INDEX_VERSION_COMPATIBILITY.get(settings),
stats,
indexWriteLoadForecast,
shardSizeInBytesForecast
shardSizeInBytesForecast,
reshardingMetadata
);
}

Expand Down Expand Up @@ -2529,6 +2548,12 @@ public static void toXContent(IndexMetadata indexMetadata, XContentBuilder build
builder.endObject();
}

if (indexMetadata.reshardingMetadata != null) {
builder.startObject(KEY_RESHARDING);
indexMetadata.reshardingMetadata.toXContent(builder, params);
builder.endObject();
}

builder.endObject();
}

Expand Down Expand Up @@ -2615,6 +2640,9 @@ public static IndexMetadata fromXContent(XContentParser parser, Map<String, Mapp
builder.putInferenceField(InferenceFieldMetadata.fromXContent(parser));
}
break;
case KEY_RESHARDING:
builder.reshardingMetadata(IndexReshardingMetadata.fromXContent(parser));
break;
default:
// assume it's custom index metadata
builder.putCustom(currentFieldName, parser.mapStrings());
Expand Down
Loading