Skip to content

Commit 7b84214

Browse files
Remove Outdated BwC Serialization in SnapshotInfo (#55451)
This is long outdated and can be removed in `8` now.
1 parent 16a141b commit 7b84214

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/create/CreateSnapshotRequest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import static org.elasticsearch.common.settings.Settings.readSettingsFromStream;
4848
import static org.elasticsearch.common.settings.Settings.writeSettingsToStream;
4949
import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue;
50-
import static org.elasticsearch.snapshots.SnapshotInfo.METADATA_FIELD_INTRODUCED;
5150

5251
/**
5352
* Create snapshot request
@@ -109,9 +108,7 @@ public CreateSnapshotRequest(StreamInput in) throws IOException {
109108
includeGlobalState = in.readBoolean();
110109
waitForCompletion = in.readBoolean();
111110
partial = in.readBoolean();
112-
if (in.getVersion().onOrAfter(METADATA_FIELD_INTRODUCED)) {
113-
userMetadata = in.readMap();
114-
}
111+
userMetadata = in.readMap();
115112
}
116113

117114
@Override
@@ -125,9 +122,7 @@ public void writeTo(StreamOutput out) throws IOException {
125122
out.writeBoolean(includeGlobalState);
126123
out.writeBoolean(waitForCompletion);
127124
out.writeBoolean(partial);
128-
if (out.getVersion().onOrAfter(METADATA_FIELD_INTRODUCED)) {
129-
out.writeMap(userMetadata);
130-
}
125+
out.writeMap(userMetadata);
131126
}
132127

133128
@Override

server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
import java.util.Set;
5151
import java.util.stream.Collectors;
5252

53-
import static org.elasticsearch.snapshots.SnapshotInfo.METADATA_FIELD_INTRODUCED;
54-
5553
/**
5654
* Meta data about snapshots that are currently executing
5755
*/
@@ -523,10 +521,7 @@ public SnapshotsInProgress(StreamInput in) throws IOException {
523521
}
524522
long repositoryStateId = in.readLong();
525523
final String failure = in.readOptionalString();
526-
Map<String, Object> userMetadata = null;
527-
if (in.getVersion().onOrAfter(METADATA_FIELD_INTRODUCED)) {
528-
userMetadata = in.readMap();
529-
}
524+
final Map<String, Object> userMetadata = in.readMap();
530525
final Version version;
531526
if (in.getVersion().onOrAfter(VERSION_IN_SNAPSHOT_VERSION)) {
532527
version = Version.readVersion(in);
@@ -572,9 +567,7 @@ public void writeTo(StreamOutput out) throws IOException {
572567
}
573568
out.writeLong(entry.repositoryStateId);
574569
out.writeOptionalString(entry.failure);
575-
if (out.getVersion().onOrAfter(METADATA_FIELD_INTRODUCED)) {
576-
out.writeMap(entry.userMetadata);
577-
}
570+
out.writeMap(entry.userMetadata);
578571
if (out.getVersion().onOrAfter(VERSION_IN_SNAPSHOT_VERSION)) {
579572
Version.writeVersion(entry.version, out);
580573
} else {

server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public final class SnapshotInfo implements Comparable<SnapshotInfo>, ToXContent,
5555

5656
public static final String CONTEXT_MODE_PARAM = "context_mode";
5757
public static final String CONTEXT_MODE_SNAPSHOT = "SNAPSHOT";
58-
public static final Version METADATA_FIELD_INTRODUCED = Version.V_7_3_0;
5958
private static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("strictDateOptionalTime");
6059
private static final String SNAPSHOT = "snapshot";
6160
private static final String UUID = "uuid";
@@ -312,11 +311,7 @@ public SnapshotInfo(final StreamInput in) throws IOException {
312311
}
313312
version = in.readBoolean() ? Version.readVersion(in) : null;
314313
includeGlobalState = in.readOptionalBoolean();
315-
if (in.getVersion().onOrAfter(METADATA_FIELD_INTRODUCED)) {
316-
userMetadata = in.readMap();
317-
} else {
318-
userMetadata = null;
319-
}
314+
userMetadata = in.readMap();
320315
}
321316

322317
/**
@@ -714,9 +709,7 @@ public void writeTo(final StreamOutput out) throws IOException {
714709
out.writeBoolean(false);
715710
}
716711
out.writeOptionalBoolean(includeGlobalState);
717-
if (out.getVersion().onOrAfter(METADATA_FIELD_INTRODUCED)) {
718-
out.writeMap(userMetadata);
719-
}
712+
out.writeMap(userMetadata);
720713
}
721714

722715
private static SnapshotState snapshotState(final String reason, final List<SnapshotShardFailure> shardFailures) {

0 commit comments

Comments
 (0)