48
48
import java .io .IOException ;
49
49
import java .util .Objects ;
50
50
51
+ import static org .opensearch .Version .CURRENT ;
52
+
51
53
/**
52
54
* Represents the recovery source of a shard. Available recovery types are:
53
55
* <p>
@@ -264,6 +266,9 @@ public static class SnapshotRecoverySource extends RecoverySource {
264
266
private final boolean isSearchableSnapshot ;
265
267
private final boolean remoteStoreIndexShallowCopy ;
266
268
private final String sourceRemoteStoreRepository ;
269
+ private final String sourceRemoteTranslogRepository ;
270
+
271
+ private final long pinnedTimestamp ;
267
272
268
273
public SnapshotRecoverySource (String restoreUUID , Snapshot snapshot , Version version , IndexId indexId ) {
269
274
this (restoreUUID , snapshot , version , indexId , false , false , null );
@@ -277,6 +282,30 @@ public SnapshotRecoverySource(
277
282
boolean isSearchableSnapshot ,
278
283
boolean remoteStoreIndexShallowCopy ,
279
284
@ Nullable String sourceRemoteStoreRepository
285
+ ) {
286
+ this (
287
+ restoreUUID ,
288
+ snapshot ,
289
+ version ,
290
+ indexId ,
291
+ isSearchableSnapshot ,
292
+ remoteStoreIndexShallowCopy ,
293
+ sourceRemoteStoreRepository ,
294
+ null ,
295
+ 0L
296
+ );
297
+ }
298
+
299
+ public SnapshotRecoverySource (
300
+ String restoreUUID ,
301
+ Snapshot snapshot ,
302
+ Version version ,
303
+ IndexId indexId ,
304
+ boolean isSearchableSnapshot ,
305
+ boolean remoteStoreIndexShallowCopy ,
306
+ @ Nullable String sourceRemoteStoreRepository ,
307
+ @ Nullable String sourceRemoteTranslogRepository ,
308
+ long pinnedTimestamp
280
309
) {
281
310
this .restoreUUID = restoreUUID ;
282
311
this .snapshot = Objects .requireNonNull (snapshot );
@@ -285,6 +314,8 @@ public SnapshotRecoverySource(
285
314
this .isSearchableSnapshot = isSearchableSnapshot ;
286
315
this .remoteStoreIndexShallowCopy = remoteStoreIndexShallowCopy ;
287
316
this .sourceRemoteStoreRepository = sourceRemoteStoreRepository ;
317
+ this .sourceRemoteTranslogRepository = sourceRemoteTranslogRepository ;
318
+ this .pinnedTimestamp = pinnedTimestamp ;
288
319
}
289
320
290
321
SnapshotRecoverySource (StreamInput in ) throws IOException {
@@ -304,6 +335,13 @@ public SnapshotRecoverySource(
304
335
remoteStoreIndexShallowCopy = false ;
305
336
sourceRemoteStoreRepository = null ;
306
337
}
338
+ if (in .getVersion ().onOrAfter (CURRENT )) {
339
+ sourceRemoteTranslogRepository = in .readOptionalString ();
340
+ pinnedTimestamp = in .readLong ();
341
+ } else {
342
+ sourceRemoteTranslogRepository = null ;
343
+ pinnedTimestamp = 0L ;
344
+ }
307
345
}
308
346
309
347
public String restoreUUID () {
@@ -336,10 +374,18 @@ public String sourceRemoteStoreRepository() {
336
374
return sourceRemoteStoreRepository ;
337
375
}
338
376
377
+ public String sourceRemoteTranslogRepository () {
378
+ return sourceRemoteTranslogRepository ;
379
+ }
380
+
339
381
public boolean remoteStoreIndexShallowCopy () {
340
382
return remoteStoreIndexShallowCopy ;
341
383
}
342
384
385
+ public long pinnedTimestamp () {
386
+ return pinnedTimestamp ;
387
+ }
388
+
343
389
@ Override
344
390
protected void writeAdditionalFields (StreamOutput out ) throws IOException {
345
391
out .writeString (restoreUUID );
@@ -353,6 +399,10 @@ protected void writeAdditionalFields(StreamOutput out) throws IOException {
353
399
out .writeBoolean (remoteStoreIndexShallowCopy );
354
400
out .writeOptionalString (sourceRemoteStoreRepository );
355
401
}
402
+ if (out .getVersion ().onOrAfter (CURRENT )) {
403
+ out .writeOptionalString (sourceRemoteTranslogRepository );
404
+ out .writeLong (pinnedTimestamp );
405
+ }
356
406
}
357
407
358
408
@ Override
@@ -369,7 +419,8 @@ public void addAdditionalFields(XContentBuilder builder, ToXContent.Params param
369
419
.field ("restoreUUID" , restoreUUID )
370
420
.field ("isSearchableSnapshot" , isSearchableSnapshot )
371
421
.field ("remoteStoreIndexShallowCopy" , remoteStoreIndexShallowCopy )
372
- .field ("sourceRemoteStoreRepository" , sourceRemoteStoreRepository );
422
+ .field ("sourceRemoteStoreRepository" , sourceRemoteStoreRepository )
423
+ .field ("sourceRemoteTranslogRepository" , sourceRemoteTranslogRepository );
373
424
}
374
425
375
426
@ Override
@@ -394,8 +445,11 @@ public boolean equals(Object o) {
394
445
&& isSearchableSnapshot == that .isSearchableSnapshot
395
446
&& remoteStoreIndexShallowCopy == that .remoteStoreIndexShallowCopy
396
447
&& sourceRemoteStoreRepository != null
397
- ? sourceRemoteStoreRepository .equals (that .sourceRemoteStoreRepository )
398
- : that .sourceRemoteStoreRepository == null ;
448
+ ? sourceRemoteStoreRepository .equals (that .sourceRemoteStoreRepository )
449
+ : that .sourceRemoteStoreRepository == null && sourceRemoteTranslogRepository != null
450
+ ? sourceRemoteTranslogRepository .equals (that .sourceRemoteTranslogRepository )
451
+ : that .sourceRemoteTranslogRepository == null && pinnedTimestamp == that .pinnedTimestamp ;
452
+
399
453
}
400
454
401
455
@ Override
@@ -407,10 +461,11 @@ public int hashCode() {
407
461
version ,
408
462
isSearchableSnapshot ,
409
463
remoteStoreIndexShallowCopy ,
410
- sourceRemoteStoreRepository
464
+ sourceRemoteStoreRepository ,
465
+ sourceRemoteTranslogRepository ,
466
+ pinnedTimestamp
411
467
);
412
468
}
413
-
414
469
}
415
470
416
471
/**
0 commit comments