Skip to content

Commit

Permalink
Remove unnecessary method from OngoingSegmentReplications
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <[email protected]>
  • Loading branch information
mch2 committed Apr 3, 2024
1 parent ce239f7 commit 13522a0
Showing 1 changed file with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,20 @@ void startSegmentCopy(GetSegmentFilesRequest request, ActionListener<GetSegmentF
* @return {@link SegmentReplicationSourceHandler} the built CopyState for this replication event.
*/
SegmentReplicationSourceHandler prepareForReplication(CheckpointInfoRequest request, FileChunkWriter 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 allocationIdToHandlers.computeIfAbsent(request.getTargetAllocationId(), aId -> {
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);

Check warning on line 110 in server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java#L109-L110

Added lines #L109 - L110 were not covered by tests
}
Expand Down Expand Up @@ -146,22 +153,6 @@ Map<String, SegmentReplicationSourceHandler> 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}
Expand Down

0 comments on commit 13522a0

Please sign in to comment.