Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.17] Set Version to 2.17 for hashed prefix snapshots #15666

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -78,7 +78,7 @@ public IndexId(String name, String id, int shardPathType) {
public IndexId(final StreamInput in) throws IOException {
this.name = in.readString();
this.id = in.readString();
if (in.getVersion().onOrAfter(Version.CURRENT)) {
if (in.getVersion().onOrAfter(Version.V_2_17_0)) {
this.shardPathType = in.readVInt();
} else {
this.shardPathType = DEFAULT_SHARD_PATH_TYPE;
Expand Down Expand Up @@ -145,7 +145,7 @@ private int computeHashCode() {
public void writeTo(final StreamOutput out) throws IOException {
out.writeString(name);
out.writeString(id);
if (out.getVersion().onOrAfter(Version.CURRENT)) {
if (out.getVersion().onOrAfter(Version.V_2_17_0)) {
out.writeVInt(shardPathType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public List<IndexId> resolveNewIndices(List<String> indicesToResolve, Map<String

// Visible for testing only
public XContentBuilder snapshotsToXContent(final XContentBuilder builder, final Version repoMetaVersion) throws IOException {
return snapshotsToXContent(builder, repoMetaVersion, Version.CURRENT);
return snapshotsToXContent(builder, repoMetaVersion, Version.V_2_17_0);
}

/**
Expand Down Expand Up @@ -594,7 +594,7 @@ public XContentBuilder snapshotsToXContent(final XContentBuilder builder, final
for (final IndexId indexId : getIndices().values()) {
builder.startObject(indexId.getName());
builder.field(INDEX_ID, indexId.getId());
if (minNodeVersion.onOrAfter(Version.CURRENT)) {
if (minNodeVersion.onOrAfter(Version.V_2_17_0)) {
builder.field(IndexId.SHARD_PATH_TYPE, indexId.getShardPathType());
}
builder.startArray(SNAPSHOTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public ClusterState execute(ClusterState currentState) {

logger.trace("[{}][{}] creating snapshot for indices [{}]", repositoryName, snapshotName, indices);

int pathType = clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.CURRENT)
int pathType = clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.V_2_17_0)
? SHARD_PATH_TYPE.get(repository.getMetadata().settings()).getCode()
: IndexId.DEFAULT_SHARD_PATH_TYPE;
final List<IndexId> indexIds = repositoryData.resolveNewIndices(
Expand Down Expand Up @@ -1342,7 +1342,7 @@ public ClusterState execute(ClusterState currentState) {
assert entry.shards().isEmpty();
hadAbortedInitializations = true;
} else {
int pathType = clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.CURRENT)
int pathType = clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.V_2_17_0)
? SHARD_PATH_TYPE.get(repository.getMetadata().settings()).getCode()
: IndexId.DEFAULT_SHARD_PATH_TYPE;
final List<IndexId> indexIds = repositoryData.resolveNewIndices(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void testEqualsAndHashCode() {
public void testSerialization() throws IOException {
IndexId indexId = new IndexId(randomAlphaOfLength(8), UUIDs.randomBase64UUID(), randomIntBetween(0, 2));
BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(Version.CURRENT);
out.setVersion(Version.V_2_17_0);
indexId.writeTo(out);
assertEquals(indexId, new IndexId(out.bytes().streamInput()));
}
Expand Down
Loading