From 606255fa4c251d570f3ed83e02f9d97e144a36af Mon Sep 17 00:00:00 2001 From: Harish Bhakuni Date: Thu, 15 Jun 2023 14:20:12 -0700 Subject: [PATCH] Create Snapshot Changes for Shallow Copy Snapshot has been backported to 2.x, change version checks from 3.0 to 2.9. (#8092) Signed-off-by: Harish Bhakuni Co-authored-by: Harish Bhakuni --- .../main/java/org/opensearch/cluster/SnapshotsInProgress.java | 4 ++-- .../src/main/java/org/opensearch/snapshots/SnapshotInfo.java | 4 ++-- .../snapshots/SnapshotsInProgressSerializationTests.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java b/server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java index c554c40506b03..d827dc6409778 100644 --- a/server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java +++ b/server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java @@ -300,7 +300,7 @@ private Entry(StreamInput in) throws IOException { dataStreams = in.readStringList(); source = in.readOptionalWriteable(SnapshotId::new); clones = in.readMap(RepositoryShardId::new, ShardSnapshotStatus::readFrom); - if (in.getVersion().onOrAfter(Version.V_3_0_0)) { + if (in.getVersion().onOrAfter(Version.V_2_9_0)) { remoteStoreIndexShallowCopy = in.readBoolean(); } else { remoteStoreIndexShallowCopy = false; @@ -736,7 +736,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringCollection(dataStreams); out.writeOptionalWriteable(source); out.writeMap(clones, (o, v) -> v.writeTo(o), (o, v) -> v.writeTo(o)); - if (out.getVersion().onOrAfter(Version.V_3_0_0)) { + if (out.getVersion().onOrAfter(Version.V_2_9_0)) { out.writeBoolean(remoteStoreIndexShallowCopy); } } diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java b/server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java index a3744a38307fd..1619f36738f7b 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java @@ -420,7 +420,7 @@ public SnapshotInfo(final StreamInput in) throws IOException { includeGlobalState = in.readOptionalBoolean(); userMetadata = in.readMap(); dataStreams = in.readStringList(); - if (in.getVersion().onOrAfter(Version.V_3_0_0)) { + if (in.getVersion().onOrAfter(Version.V_2_9_0)) { remoteStoreIndexShallowCopy = in.readOptionalBoolean(); } } @@ -866,7 +866,7 @@ public void writeTo(final StreamOutput out) throws IOException { out.writeOptionalBoolean(includeGlobalState); out.writeMap(userMetadata); out.writeStringCollection(dataStreams); - if (out.getVersion().onOrAfter(Version.V_3_0_0)) { + if (out.getVersion().onOrAfter(Version.V_2_9_0)) { out.writeOptionalBoolean(remoteStoreIndexShallowCopy); } } diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotsInProgressSerializationTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotsInProgressSerializationTests.java index 91f7021ef565e..bf491cacc88d1 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotsInProgressSerializationTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotsInProgressSerializationTests.java @@ -215,7 +215,7 @@ public void testSerDeRemoteStoreIndexShallowCopy() throws IOException { } } try (StreamInput in = out.bytes().streamInput()) { - in.setVersion(Version.V_3_0_0); + in.setVersion(Version.V_2_9_0); actualSnapshotsInProgress = new SnapshotsInProgress(in); assert in.available() == 0; for (Entry curr_entry : actualSnapshotsInProgress.entries()) {