@@ -132,16 +132,7 @@ protected void innerUpdateMapping(long minRequiredMappingVersion, LongConsumer h
132
132
final Index followerIndex = params .getFollowShardId ().getIndex ();
133
133
final Index leaderIndex = params .getLeaderShardId ().getIndex ();
134
134
final Supplier <TimeValue > timeout = () -> isStopped () ? TimeValue .MINUS_ONE : waitForMetadataTimeOut ;
135
-
136
- final Client remoteClient ;
137
- try {
138
- remoteClient = remoteClient (params );
139
- } catch (NoSuchRemoteClusterException e ) {
140
- errorHandler .accept (e );
141
- return ;
142
- }
143
-
144
- CcrRequests .getIndexMetadata (remoteClient , leaderIndex , minRequiredMappingVersion , 0L , timeout , ActionListener .wrap (
135
+ final ActionListener <IndexMetaData > listener = ActionListener .wrap (
145
136
indexMetaData -> {
146
137
if (indexMetaData .mapping () == null ) {
147
138
assert indexMetaData .getMappingVersion () == 1 ;
@@ -155,7 +146,12 @@ protected void innerUpdateMapping(long minRequiredMappingVersion, LongConsumer h
155
146
errorHandler ));
156
147
},
157
148
errorHandler
158
- ));
149
+ );
150
+ try {
151
+ CcrRequests .getIndexMetadata (remoteClient (params ), leaderIndex , minRequiredMappingVersion , 0L , timeout , listener );
152
+ } catch (NoSuchRemoteClusterException e ) {
153
+ errorHandler .accept (e );
154
+ }
159
155
}
160
156
161
157
@ Override
@@ -424,21 +420,27 @@ protected Scheduler.Cancellable scheduleBackgroundRetentionLeaseRenewal(final Lo
424
420
"{} background adding retention lease [{}] while following" ,
425
421
params .getFollowShardId (),
426
422
retentionLeaseId );
427
- CcrRetentionLeases .asyncAddRetentionLease (
423
+ try {
424
+ final ActionListener <RetentionLeaseActions .Response > wrappedListener = ActionListener .wrap (
425
+ r -> {},
426
+ inner -> {
427
+ /*
428
+ * If this fails that the retention lease already exists, something highly unusual is
429
+ * going on. Log it, and renew again after another renew interval has passed.
430
+ */
431
+ final Throwable innerCause = ExceptionsHelper .unwrapCause (inner );
432
+ logRetentionLeaseFailure (retentionLeaseId , innerCause );
433
+ });
434
+ CcrRetentionLeases .asyncAddRetentionLease (
428
435
params .getLeaderShardId (),
429
436
retentionLeaseId ,
430
437
followerGlobalCheckpoint .getAsLong (),
431
438
remoteClient (params ),
432
- ActionListener .wrap (
433
- r -> {},
434
- inner -> {
435
- /*
436
- * If this fails that the retention lease already exists, something highly unusual is
437
- * going on. Log it, and renew again after another renew interval has passed.
438
- */
439
- final Throwable innerCause = ExceptionsHelper .unwrapCause (inner );
440
- logRetentionLeaseFailure (retentionLeaseId , innerCause );
441
- }));
439
+ wrappedListener );
440
+ } catch (NoSuchRemoteClusterException rce ) {
441
+ // we will attempt to renew again after another renew interval has passed
442
+ logRetentionLeaseFailure (retentionLeaseId , rce );
443
+ }
442
444
} else {
443
445
// if something else happened, we will attempt to renew again after another renew interval has passed
444
446
}
0 commit comments