2424import com .carrotsearch .hppc .cursors .ObjectObjectCursor ;
2525import org .elasticsearch .Version ;
2626import org .elasticsearch .cluster .ClusterState .Custom ;
27+ import org .elasticsearch .common .Nullable ;
2728import org .elasticsearch .common .collect .ImmutableOpenMap ;
2829import org .elasticsearch .common .io .stream .StreamInput ;
2930import org .elasticsearch .common .io .stream .StreamOutput ;
@@ -93,9 +94,11 @@ public static class Entry {
9394 private final ImmutableOpenMap <String , List <ShardId >> waitingIndices ;
9495 private final long startTime ;
9596 private final long repositoryStateId ;
97+ @ Nullable private final String failure ;
9698
9799 public Entry (Snapshot snapshot , boolean includeGlobalState , boolean partial , State state , List <IndexId > indices ,
98- long startTime , long repositoryStateId , ImmutableOpenMap <ShardId , ShardSnapshotStatus > shards ) {
100+ long startTime , long repositoryStateId , ImmutableOpenMap <ShardId , ShardSnapshotStatus > shards ,
101+ String failure ) {
99102 this .state = state ;
100103 this .snapshot = snapshot ;
101104 this .includeGlobalState = includeGlobalState ;
@@ -110,15 +113,26 @@ public Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, Sta
110113 this .waitingIndices = findWaitingIndices (shards );
111114 }
112115 this .repositoryStateId = repositoryStateId ;
116+ this .failure = failure ;
117+ }
118+
119+ public Entry (Snapshot snapshot , boolean includeGlobalState , boolean partial , State state , List <IndexId > indices ,
120+ long startTime , long repositoryStateId , ImmutableOpenMap <ShardId , ShardSnapshotStatus > shards ) {
121+ this (snapshot , includeGlobalState , partial , state , indices , startTime , repositoryStateId , shards , null );
113122 }
114123
115124 public Entry (Entry entry , State state , ImmutableOpenMap <ShardId , ShardSnapshotStatus > shards ) {
116125 this (entry .snapshot , entry .includeGlobalState , entry .partial , state , entry .indices , entry .startTime ,
117- entry .repositoryStateId , shards );
126+ entry .repositoryStateId , shards , entry .failure );
127+ }
128+
129+ public Entry (Entry entry , State state , ImmutableOpenMap <ShardId , ShardSnapshotStatus > shards , String failure ) {
130+ this (entry .snapshot , entry .includeGlobalState , entry .partial , state , entry .indices , entry .startTime ,
131+ entry .repositoryStateId , shards , failure );
118132 }
119133
120134 public Entry (Entry entry , ImmutableOpenMap <ShardId , ShardSnapshotStatus > shards ) {
121- this (entry , entry .state , shards );
135+ this (entry , entry .state , shards , entry . failure );
122136 }
123137
124138 public Snapshot snapshot () {
@@ -157,6 +171,10 @@ public long getRepositoryStateId() {
157171 return repositoryStateId ;
158172 }
159173
174+ public String failure () {
175+ return failure ;
176+ }
177+
160178 @ Override
161179 public boolean equals (Object o ) {
162180 if (this == o ) return true ;
@@ -437,14 +455,21 @@ public SnapshotsInProgress(StreamInput in) throws IOException {
437455 if (in .getVersion ().onOrAfter (REPOSITORY_ID_INTRODUCED_VERSION )) {
438456 repositoryStateId = in .readLong ();
439457 }
458+ final String failure ;
459+ if (in .getVersion ().onOrAfter (Version .V_6_7_0 )) {
460+ failure = in .readOptionalString ();
461+ } else {
462+ failure = null ;
463+ }
440464 entries [i ] = new Entry (snapshot ,
441465 includeGlobalState ,
442466 partial ,
443467 state ,
444468 Collections .unmodifiableList (indexBuilder ),
445469 startTime ,
446470 repositoryStateId ,
447- builder .build ());
471+ builder .build (),
472+ failure );
448473 }
449474 this .entries = Arrays .asList (entries );
450475 }
@@ -476,6 +501,9 @@ public void writeTo(StreamOutput out) throws IOException {
476501 if (out .getVersion ().onOrAfter (REPOSITORY_ID_INTRODUCED_VERSION )) {
477502 out .writeLong (entry .repositoryStateId );
478503 }
504+ if (out .getVersion ().onOrAfter (Version .V_6_7_0 )) {
505+ out .writeOptionalString (entry .failure );
506+ }
479507 }
480508 }
481509
0 commit comments