1717import org .elasticsearch .common .io .stream .StreamOutput ;
1818import org .elasticsearch .common .xcontent .ChunkedToXContentObject ;
1919import org .elasticsearch .core .Nullable ;
20- import org .elasticsearch .core .UpdateForV9 ;
2120import org .elasticsearch .snapshots .SnapshotInfo ;
2221import org .elasticsearch .xcontent .ToXContent ;
2322
2423import java .io .IOException ;
25- import java .util .Collections ;
2624import java .util .Iterator ;
2725import java .util .List ;
2826import java .util .Map ;
@@ -35,9 +33,6 @@ public class GetSnapshotsResponse extends ActionResponse implements ChunkedToXCo
3533
3634 private final List <SnapshotInfo > snapshots ;
3735
38- @ UpdateForV9 (owner = UpdateForV9 .Owner .DISTRIBUTED_COORDINATION ) // always empty, can be dropped
39- private final Map <String , ElasticsearchException > failures ;
40-
4136 @ Nullable
4237 private final String next ;
4338
@@ -53,15 +48,15 @@ public GetSnapshotsResponse(
5348 final int remaining
5449 ) {
5550 this .snapshots = List .copyOf (snapshots );
56- this .failures = failures == null ? Map .of () : Map .copyOf (failures );
5751 this .next = next ;
5852 this .total = total ;
5953 this .remaining = remaining ;
6054 }
6155
6256 public GetSnapshotsResponse (StreamInput in ) throws IOException {
6357 this .snapshots = in .readCollectionAsImmutableList (SnapshotInfo ::readFrom );
64- this .failures = Collections .unmodifiableMap (in .readMap (StreamInput ::readException ));
58+ // TODO Skip when we have V9 in TransportVersions
59+ in .readMap (StreamInput ::readException );
6560 this .next = in .readOptionalString ();
6661 this .total = in .readVInt ();
6762 this .remaining = in .readVInt ();
@@ -76,25 +71,11 @@ public List<SnapshotInfo> getSnapshots() {
7671 return snapshots ;
7772 }
7873
79- /**
80- * Returns a map of repository name to {@link ElasticsearchException} for each unsuccessful response.
81- */
82- public Map <String , ElasticsearchException > getFailures () {
83- return failures ;
84- }
85-
8674 @ Nullable
8775 public String next () {
8876 return next ;
8977 }
9078
91- /**
92- * Returns true if there is at least one failed response.
93- */
94- public boolean isFailed () {
95- return failures .isEmpty () == false ;
96- }
97-
9879 public int totalCount () {
9980 return total ;
10081 }
@@ -106,7 +87,8 @@ public int remaining() {
10687 @ Override
10788 public void writeTo (StreamOutput out ) throws IOException {
10889 out .writeCollection (snapshots );
109- out .writeMap (failures , StreamOutput ::writeException );
90+ // TODO Skip when we have V9 in TransportVersions
91+ out .writeMap (Map .of (), StreamOutput ::writeException );
11092 out .writeOptionalString (next );
11193 out .writeVInt (total );
11294 out .writeVInt (remaining );
@@ -120,18 +102,6 @@ public Iterator<ToXContent> toXContentChunked(ToXContent.Params params) {
120102 return b ;
121103 }), Iterators .map (getSnapshots ().iterator (), snapshotInfo -> snapshotInfo ::toXContentExternal ), Iterators .single ((b , p ) -> {
122104 b .endArray ();
123- if (failures .isEmpty () == false ) {
124- b .startObject ("failures" );
125- for (Map .Entry <String , ElasticsearchException > error : failures .entrySet ()) {
126- b .field (error .getKey (), (bb , pa ) -> {
127- bb .startObject ();
128- error .getValue ().toXContent (bb , pa );
129- bb .endObject ();
130- return bb ;
131- });
132- }
133- b .endObject ();
134- }
135105 if (next != null ) {
136106 b .field ("next" , next );
137107 }
@@ -151,12 +121,12 @@ public boolean equals(Object o) {
151121 if (this == o ) return true ;
152122 if (o == null || getClass () != o .getClass ()) return false ;
153123 GetSnapshotsResponse that = (GetSnapshotsResponse ) o ;
154- return Objects .equals (snapshots , that .snapshots ) && Objects .equals (failures , that . failures ) && Objects . equals ( next , that .next );
124+ return Objects .equals (snapshots , that .snapshots ) && Objects .equals (next , that .next );
155125 }
156126
157127 @ Override
158128 public int hashCode () {
159- return Objects .hash (snapshots , failures , next );
129+ return Objects .hash (snapshots , next );
160130 }
161131
162132 @ Override
0 commit comments