99import org .elasticsearch .action .support .broadcast .BroadcastResponse ;
1010import org .elasticsearch .common .ParseField ;
1111import org .elasticsearch .common .io .stream .StreamInput ;
12+ import org .elasticsearch .common .io .stream .StreamOutput ;
13+ import org .elasticsearch .common .io .stream .Writeable ;
1214import org .elasticsearch .common .xcontent .ConstructingObjectParser ;
1315import org .elasticsearch .common .xcontent .XContentBuilder ;
1416import org .elasticsearch .common .xcontent .XContentParser ;
2123import java .util .List ;
2224import java .util .Map ;
2325import java .util .Map .Entry ;
26+ import java .util .Objects ;
2427import java .util .Set ;
2528
2629import static org .elasticsearch .common .xcontent .ConstructingObjectParser .constructorArg ;
3134public class ReloadAnalyzersResponse extends BroadcastResponse {
3235
3336 private final Map <String , ReloadDetails > reloadDetails ;
37+
3438 private static final ParseField RELOAD_DETAILS_FIELD = new ParseField ("reload_details" );
3539 private static final ParseField INDEX_FIELD = new ParseField ("index" );
3640 private static final ParseField RELOADED_ANALYZERS_FIELD = new ParseField ("reloaded_analyzers" );
3741 private static final ParseField RELOADED_NODE_IDS_FIELD = new ParseField ("reloaded_node_ids" );
3842
3943 public ReloadAnalyzersResponse (StreamInput in ) throws IOException {
4044 super (in );
41- reloadDetails = null ;
42- // TODO: this needs to deserialize reloadDetails, see https://github.com/elastic/elasticsearch/issues/44383
45+ this .reloadDetails = in .readMap (StreamInput ::readString , ReloadDetails ::new );
4346 }
4447
4548 public ReloadAnalyzersResponse (int totalShards , int successfulShards , int failedShards ,
@@ -100,7 +103,30 @@ public static ReloadAnalyzersResponse fromXContent(XContentParser parser) {
100103 return PARSER .apply (parser , null );
101104 }
102105
103- public static class ReloadDetails {
106+ @ Override
107+ public void writeTo (StreamOutput out ) throws IOException {
108+ super .writeTo (out );
109+ out .writeMap (reloadDetails , StreamOutput ::writeString , (stream , details ) -> details .writeTo (stream ));
110+ }
111+
112+ @ Override
113+ public boolean equals (Object o ) {
114+ if (this == o ) {
115+ return true ;
116+ }
117+ if (o == null || getClass () != o .getClass ()) {
118+ return false ;
119+ }
120+ ReloadAnalyzersResponse that = (ReloadAnalyzersResponse ) o ;
121+ return Objects .equals (reloadDetails , that .reloadDetails );
122+ }
123+
124+ @ Override
125+ public int hashCode () {
126+ return Objects .hash (reloadDetails );
127+ }
128+
129+ public static class ReloadDetails implements Writeable {
104130
105131 private final String indexName ;
106132 private final Set <String > reloadedIndicesNodes ;
@@ -112,6 +138,19 @@ public ReloadDetails(String name, Set<String> reloadedIndicesNodes, Set<String>
112138 this .reloadedAnalyzers = reloadedAnalyzers ;
113139 }
114140
141+ ReloadDetails (StreamInput in ) throws IOException {
142+ this .indexName = in .readString ();
143+ this .reloadedIndicesNodes = new HashSet <>(in .readList (StreamInput ::readString ));
144+ this .reloadedAnalyzers = new HashSet <>(in .readList (StreamInput ::readString ));
145+ }
146+
147+ @ Override
148+ public void writeTo (StreamOutput out ) throws IOException {
149+ out .writeString (indexName );
150+ out .writeStringCollection (reloadedIndicesNodes );
151+ out .writeStringCollection (reloadedAnalyzers );
152+ }
153+
115154 public String getIndexName () {
116155 return indexName ;
117156 }
@@ -129,5 +168,24 @@ void merge(ReloadResult other) {
129168 this .reloadedAnalyzers .addAll (other .reloadedSearchAnalyzers );
130169 this .reloadedIndicesNodes .add (other .nodeId );
131170 }
171+
172+ @ Override
173+ public boolean equals (Object o ) {
174+ if (this == o ) {
175+ return true ;
176+ }
177+ if (o == null || getClass () != o .getClass ()) {
178+ return false ;
179+ }
180+ ReloadDetails that = (ReloadDetails ) o ;
181+ return Objects .equals (indexName , that .indexName )
182+ && Objects .equals (reloadedIndicesNodes , that .reloadedIndicesNodes )
183+ && Objects .equals (reloadedAnalyzers , that .reloadedAnalyzers );
184+ }
185+
186+ @ Override
187+ public int hashCode () {
188+ return Objects .hash (indexName , reloadedIndicesNodes , reloadedAnalyzers );
189+ }
132190 }
133191}
0 commit comments