Skip to content

Commit

Permalink
Set Version to 2.17 for hashed prefix snapshots
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <ssashish@amazon.com>
  • Loading branch information
ashking94 committed Sep 4, 2024
1 parent 14e442c commit dcc21dd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions server/src/main/java/org/opensearch/repositories/IndexId.java
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 @@ -551,7 +551,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 @@ -589,7 +589,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 @@ -361,7 +361,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
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

0 comments on commit dcc21dd

Please sign in to comment.