From 13522a0e3c7af2f024c5425347c82d64fbcd2e40 Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Tue, 2 Apr 2024 17:22:54 -0700 Subject: [PATCH] Remove unnecessary method from OngoingSegmentReplications Signed-off-by: Marc Handalian --- .../OngoingSegmentReplications.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java b/server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java index b9caf8591f432..6b99b3c0b0696 100644 --- a/server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java +++ b/server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java @@ -92,13 +92,20 @@ void startSegmentCopy(GetSegmentFilesRequest request, ActionListener { try { - return createTargetHandler(request.getTargetNode(), indexShard, request.getTargetAllocationId(), fileChunkWriter); + // From the checkpoint's shard ID, fetch the IndexShard + final ShardId shardId = request.getCheckpoint().getShardId(); + final IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex()); + final IndexShard indexShard = indexService.getShard(shardId.id()); + return new SegmentReplicationSourceHandler( + request.getTargetNode(), + fileChunkWriter, + indexShard, + request.getTargetAllocationId(), + Math.toIntExact(recoverySettings.getChunkSize().getBytes()), + recoverySettings.getMaxConcurrentFileChunks() + ); } catch (IOException e) { throw new UncheckedIOException("Error creating replication handler", e); } @@ -146,22 +153,6 @@ Map getHandlers() { return allocationIdToHandlers; } - private SegmentReplicationSourceHandler createTargetHandler( - DiscoveryNode node, - IndexShard shard, - String allocationId, - FileChunkWriter fileChunkWriter - ) throws IOException { - return new SegmentReplicationSourceHandler( - node, - fileChunkWriter, - shard, - allocationId, - Math.toIntExact(recoverySettings.getChunkSize().getBytes()), - recoverySettings.getMaxConcurrentFileChunks() - ); - } - /** * Clear handlers for any allocationIds not in sync. * @param shardId {@link ShardId}