Skip to content

Commit

Permalink
Add Transport version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
arteam committed Feb 4, 2025
1 parent 0d776db commit 7ecfe8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ static TransportVersion def(int id) {
public static final TransportVersion INFERENCE_REQUEST_ADAPTIVE_RATE_LIMITING = def(8_839_0_00);
public static final TransportVersion ML_INFERENCE_IBM_WATSONX_RERANK_ADDED = def(8_840_0_00);
public static final TransportVersion ELASTICSEARCH_9_0 = def(9_000_0_00);
public static final TransportVersion REMOVE_SNAPSHOT_FAILURES = def(9_000_0_01);

/*
* STOP! READ THIS FIRST! No, really,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.elasticsearch.action.admin.cluster.snapshots.get;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.collect.Iterators;
Expand Down Expand Up @@ -48,8 +49,9 @@ public GetSnapshotsResponse(List<SnapshotInfo> snapshots, @Nullable String next,

public GetSnapshotsResponse(StreamInput in) throws IOException {
this.snapshots = in.readCollectionAsImmutableList(SnapshotInfo::readFrom);
// TODO Skip when we have V9 in TransportVersions
in.readMap(StreamInput::readException);
if (in.getTransportVersion().before(TransportVersions.REMOVE_SNAPSHOT_FAILURES)) {
in.readMap(StreamInput::readException);
}
this.next = in.readOptionalString();
this.total = in.readVInt();
this.remaining = in.readVInt();
Expand Down Expand Up @@ -80,8 +82,9 @@ public int remaining() {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeCollection(snapshots);
// TODO Skip when we have V9 in TransportVersions
out.writeMap(Map.of(), StreamOutput::writeException);
if (out.getTransportVersion().before(TransportVersions.REMOVE_SNAPSHOT_FAILURES)) {
out.writeMap(Map.of(), StreamOutput::writeException);
}
out.writeOptionalString(next);
out.writeVInt(total);
out.writeVInt(remaining);
Expand Down

0 comments on commit 7ecfe8f

Please sign in to comment.