@@ -260,20 +260,20 @@ public void writeTo(StreamOutput out) throws IOException {
260
260
*
261
261
* @opensearch.internal
262
262
*/
263
- public static class NodeGatewayStartedShard {
263
+ public static class NodeGatewayStartedShard extends BaseShardResponse {
264
264
private final String allocationId ;
265
265
private final boolean primary ;
266
- private final Exception storeException ;
267
266
private final ReplicationCheckpoint replicationCheckpoint ;
268
267
268
+ @ Override
269
+ public boolean isEmpty () {
270
+ return allocationId == null && primary == false && getException () == null && replicationCheckpoint == null ;
271
+ }
272
+
269
273
public NodeGatewayStartedShard (StreamInput in ) throws IOException {
274
+ super (in );
270
275
allocationId = in .readOptionalString ();
271
276
primary = in .readBoolean ();
272
- if (in .readBoolean ()) {
273
- storeException = in .readException ();
274
- } else {
275
- storeException = null ;
276
- }
277
277
if (in .readBoolean ()) {
278
278
replicationCheckpoint = new ReplicationCheckpoint (in );
279
279
} else {
@@ -291,10 +291,10 @@ public NodeGatewayStartedShard(
291
291
ReplicationCheckpoint replicationCheckpoint ,
292
292
Exception storeException
293
293
) {
294
+ super (storeException );
294
295
this .allocationId = allocationId ;
295
296
this .primary = primary ;
296
297
this .replicationCheckpoint = replicationCheckpoint ;
297
- this .storeException = storeException ;
298
298
}
299
299
300
300
public String allocationId () {
@@ -309,19 +309,10 @@ public ReplicationCheckpoint replicationCheckpoint() {
309
309
return this .replicationCheckpoint ;
310
310
}
311
311
312
- public Exception storeException () {
313
- return this .storeException ;
314
- }
315
-
316
312
public void writeTo (StreamOutput out ) throws IOException {
313
+ super .writeTo (out );
317
314
out .writeOptionalString (allocationId );
318
315
out .writeBoolean (primary );
319
- if (storeException != null ) {
320
- out .writeBoolean (true );
321
- out .writeException (storeException );
322
- } else {
323
- out .writeBoolean (false );
324
- }
325
316
if (replicationCheckpoint != null ) {
326
317
out .writeBoolean (true );
327
318
replicationCheckpoint .writeTo (out );
@@ -343,15 +334,15 @@ public boolean equals(Object o) {
343
334
344
335
return primary == that .primary
345
336
&& Objects .equals (allocationId , that .allocationId )
346
- && Objects .equals (storeException , that .storeException )
337
+ && Objects .equals (getException () , that .getException () )
347
338
&& Objects .equals (replicationCheckpoint , that .replicationCheckpoint );
348
339
}
349
340
350
341
@ Override
351
342
public int hashCode () {
352
343
int result = (allocationId != null ? allocationId .hashCode () : 0 );
353
344
result = 31 * result + (primary ? 1 : 0 );
354
- result = 31 * result + (storeException != null ? storeException .hashCode () : 0 );
345
+ result = 31 * result + (getException () != null ? getException () .hashCode () : 0 );
355
346
result = 31 * result + (replicationCheckpoint != null ? replicationCheckpoint .hashCode () : 0 );
356
347
return result ;
357
348
}
@@ -360,8 +351,8 @@ public int hashCode() {
360
351
public String toString () {
361
352
StringBuilder buf = new StringBuilder ();
362
353
buf .append ("NodeGatewayStartedShards[" ).append ("allocationId=" ).append (allocationId ).append (",primary=" ).append (primary );
363
- if (storeException != null ) {
364
- buf .append (",storeException=" ).append (storeException );
354
+ if (getException () != null ) {
355
+ buf .append (",storeException=" ).append (getException () );
365
356
}
366
357
if (replicationCheckpoint != null ) {
367
358
buf .append (",ReplicationCheckpoint=" ).append (replicationCheckpoint .toString ());
@@ -387,13 +378,28 @@ public Map<ShardId, NodeGatewayStartedShard> getNodeGatewayStartedShardsBatch()
387
378
388
379
public NodeGatewayStartedShardsBatch (StreamInput in ) throws IOException {
389
380
super (in );
390
- this .nodeGatewayStartedShardsBatch = in .readMap (ShardId ::new , NodeGatewayStartedShard ::new );
381
+ this .nodeGatewayStartedShardsBatch = in .readMap (ShardId ::new ,
382
+ i -> {
383
+ if (i .readBoolean ()) {
384
+ return new NodeGatewayStartedShard (i );
385
+ } else {
386
+ return null ;
387
+ }
388
+ });
391
389
}
392
390
393
391
@ Override
394
392
public void writeTo (StreamOutput out ) throws IOException {
395
393
super .writeTo (out );
396
- out .writeMap (nodeGatewayStartedShardsBatch , (o , k ) -> k .writeTo (o ), (o , v ) -> v .writeTo (o ));
394
+ out .writeMap (nodeGatewayStartedShardsBatch , (o , k ) -> k .writeTo (o ),
395
+ (o , v ) -> {
396
+ if (v != null ) {
397
+ o .writeBoolean (true );
398
+ v .writeTo (o );
399
+ } else {
400
+ o .writeBoolean (false );
401
+ }
402
+ });
397
403
}
398
404
399
405
public NodeGatewayStartedShardsBatch (DiscoveryNode node , Map <ShardId , NodeGatewayStartedShard > nodeGatewayStartedShardsBatch ) {
0 commit comments