@@ -228,7 +228,7 @@ public synchronized void onNewCheckpoint(final ReplicationCheckpoint receivedChe
228228 }
229229 final Thread thread = Thread .currentThread ();
230230 if (replicaShard .shouldProcessCheckpoint (receivedCheckpoint )) {
231- startReplication (receivedCheckpoint , replicaShard , new SegmentReplicationListener () {
231+ startReplication (replicaShard , new SegmentReplicationListener () {
232232 @ Override
233233 public void onReplicationDone (SegmentReplicationState state ) {
234234 logger .trace (
@@ -301,17 +301,8 @@ protected void updateLatestReceivedCheckpoint(ReplicationCheckpoint receivedChec
301301 }
302302 }
303303
304- public SegmentReplicationTarget startReplication (
305- final ReplicationCheckpoint checkpoint ,
306- final IndexShard indexShard ,
307- final SegmentReplicationListener listener
308- ) {
309- final SegmentReplicationTarget target = new SegmentReplicationTarget (
310- checkpoint ,
311- indexShard ,
312- sourceFactory .get (indexShard ),
313- listener
314- );
304+ public SegmentReplicationTarget startReplication (final IndexShard indexShard , final SegmentReplicationListener listener ) {
305+ final SegmentReplicationTarget target = new SegmentReplicationTarget (indexShard , sourceFactory .get (indexShard ), listener );
315306 startReplication (target );
316307 return target ;
317308 }
@@ -429,57 +420,49 @@ public void messageReceived(final ForceSyncRequest request, TransportChannel cha
429420 channel .sendResponse (TransportResponse .Empty .INSTANCE );
430421 return ;
431422 }
432- startReplication (
433- ReplicationCheckpoint .empty (request .getShardId (), indexShard .getDefaultCodecName ()),
434- indexShard ,
435- new SegmentReplicationTargetService .SegmentReplicationListener () {
436- @ Override
437- public void onReplicationDone (SegmentReplicationState state ) {
438- logger .trace (
439- () -> new ParameterizedMessage (
440- "[shardId {}] [replication id {}] Replication complete to {}, timing data: {}" ,
441- indexShard .shardId ().getId (),
442- state .getReplicationId (),
443- indexShard .getLatestReplicationCheckpoint (),
444- state .getTimingData ()
445- )
446- );
447- try {
448- // Promote engine type for primary target
449- if (indexShard .recoveryState ().getPrimary () == true ) {
450- indexShard .resetToWriteableEngine ();
451- }
452- channel .sendResponse (TransportResponse .Empty .INSTANCE );
453- } catch (InterruptedException | TimeoutException | IOException e ) {
454- throw new RuntimeException (e );
423+ startReplication (indexShard , new SegmentReplicationTargetService .SegmentReplicationListener () {
424+ @ Override
425+ public void onReplicationDone (SegmentReplicationState state ) {
426+ logger .trace (
427+ () -> new ParameterizedMessage (
428+ "[shardId {}] [replication id {}] Replication complete to {}, timing data: {}" ,
429+ indexShard .shardId ().getId (),
430+ state .getReplicationId (),
431+ indexShard .getLatestReplicationCheckpoint (),
432+ state .getTimingData ()
433+ )
434+ );
435+ try {
436+ // Promote engine type for primary target
437+ if (indexShard .recoveryState ().getPrimary () == true ) {
438+ indexShard .resetToWriteableEngine ();
455439 }
440+ channel .sendResponse (TransportResponse .Empty .INSTANCE );
441+ } catch (InterruptedException | TimeoutException | IOException e ) {
442+ throw new RuntimeException (e );
456443 }
444+ }
457445
458- @ Override
459- public void onReplicationFailure (
460- SegmentReplicationState state ,
461- ReplicationFailedException e ,
462- boolean sendShardFailure
463- ) {
464- logger .trace (
465- () -> new ParameterizedMessage (
466- "[shardId {}] [replication id {}] Replication failed, timing data: {}" ,
467- indexShard .shardId ().getId (),
468- state .getReplicationId (),
469- state .getTimingData ()
470- )
471- );
472- if (sendShardFailure == true ) {
473- indexShard .failShard ("replication failure" , e );
474- }
475- try {
476- channel .sendResponse (e );
477- } catch (IOException ex ) {
478- throw new RuntimeException (ex );
479- }
446+ @ Override
447+ public void onReplicationFailure (SegmentReplicationState state , ReplicationFailedException e , boolean sendShardFailure ) {
448+ logger .trace (
449+ () -> new ParameterizedMessage (
450+ "[shardId {}] [replication id {}] Replication failed, timing data: {}" ,
451+ indexShard .shardId ().getId (),
452+ state .getReplicationId (),
453+ state .getTimingData ()
454+ )
455+ );
456+ if (sendShardFailure == true ) {
457+ indexShard .failShard ("replication failure" , e );
458+ }
459+ try {
460+ channel .sendResponse (e );
461+ } catch (IOException ex ) {
462+ throw new RuntimeException (ex );
480463 }
481464 }
482- );
465+ } );
483466 }
484467 }
485468
0 commit comments