Skip to content

Commit b5be08a

Browse files
authored
[Backport 2.x] Set Version to 2.17 for hashed prefix snapshots (#15661)
Signed-off-by: Ashish Singh <ssashish@amazon.com>
1 parent b408ef8 commit b5be08a

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

server/src/main/java/org/opensearch/repositories/IndexId.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public IndexId(String name, String id, int shardPathType) {
7878
public IndexId(final StreamInput in) throws IOException {
7979
this.name = in.readString();
8080
this.id = in.readString();
81-
if (in.getVersion().onOrAfter(Version.CURRENT)) {
81+
if (in.getVersion().onOrAfter(Version.V_2_17_0)) {
8282
this.shardPathType = in.readVInt();
8383
} else {
8484
this.shardPathType = DEFAULT_SHARD_PATH_TYPE;
@@ -145,7 +145,7 @@ private int computeHashCode() {
145145
public void writeTo(final StreamOutput out) throws IOException {
146146
out.writeString(name);
147147
out.writeString(id);
148-
if (out.getVersion().onOrAfter(Version.CURRENT)) {
148+
if (out.getVersion().onOrAfter(Version.V_2_17_0)) {
149149
out.writeVInt(shardPathType);
150150
}
151151
}

server/src/main/java/org/opensearch/repositories/RepositoryData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ public List<IndexId> resolveNewIndices(List<String> indicesToResolve, Map<String
552552

553553
// Visible for testing only
554554
public XContentBuilder snapshotsToXContent(final XContentBuilder builder, final Version repoMetaVersion) throws IOException {
555-
return snapshotsToXContent(builder, repoMetaVersion, Version.CURRENT);
555+
return snapshotsToXContent(builder, repoMetaVersion, Version.V_2_17_0);
556556
}
557557

558558
/**
@@ -594,7 +594,7 @@ public XContentBuilder snapshotsToXContent(final XContentBuilder builder, final
594594
for (final IndexId indexId : getIndices().values()) {
595595
builder.startObject(indexId.getName());
596596
builder.field(INDEX_ID, indexId.getId());
597-
if (minNodeVersion.onOrAfter(Version.CURRENT)) {
597+
if (minNodeVersion.onOrAfter(Version.V_2_17_0)) {
598598
builder.field(IndexId.SHARD_PATH_TYPE, indexId.getShardPathType());
599599
}
600600
builder.startArray(SNAPSHOTS);

server/src/main/java/org/opensearch/snapshots/SnapshotsService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public ClusterState execute(ClusterState currentState) {
528528

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

531-
int pathType = clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.CURRENT)
531+
int pathType = clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.V_2_17_0)
532532
? SHARD_PATH_TYPE.get(repository.getMetadata().settings()).getCode()
533533
: IndexId.DEFAULT_SHARD_PATH_TYPE;
534534
final List<IndexId> indexIds = repositoryData.resolveNewIndices(
@@ -1354,7 +1354,7 @@ public ClusterState execute(ClusterState currentState) {
13541354
assert entry.shards().isEmpty();
13551355
hadAbortedInitializations = true;
13561356
} else {
1357-
int pathType = clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.CURRENT)
1357+
int pathType = clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.V_2_17_0)
13581358
? SHARD_PATH_TYPE.get(repository.getMetadata().settings()).getCode()
13591359
: IndexId.DEFAULT_SHARD_PATH_TYPE;
13601360
final List<IndexId> indexIds = repositoryData.resolveNewIndices(

server/src/test/java/org/opensearch/repositories/IndexIdTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void testEqualsAndHashCode() {
8686
public void testSerialization() throws IOException {
8787
IndexId indexId = new IndexId(randomAlphaOfLength(8), UUIDs.randomBase64UUID(), randomIntBetween(0, 2));
8888
BytesStreamOutput out = new BytesStreamOutput();
89-
out.setVersion(Version.CURRENT);
89+
out.setVersion(Version.V_2_17_0);
9090
indexId.writeTo(out);
9191
assertEquals(indexId, new IndexId(out.bytes().streamInput()));
9292
}

0 commit comments

Comments
 (0)