Source:
<code>private Map<Node, FetchSessionHandler.FetchRequestData> prepareFetchRequests() { Map<Node, FetchSessionHandler.Builder> fetchable = new LinkedHashMap<>(); subscriptions.assignedPartitions().forEach( tp -> subscriptions.maybeValidatePosition(tp, metadata.leaderAndEpoch(tp))); for (TopicPartition partition : fetchablePartitions()) { SubscriptionState.FetchPosition position = this.subscriptions.position(partition); <START> Node node = selectReadReplica(partition, position.currentLeader.leader); <END> if (node == null || node.isEmpty()) { metadata.requestUpdate(); } else if (client.isUnavailable(node)) { client.maybeThrowAuthFailure(node); log.trace("Skipping fetch for partition because node is awaiting reconnect backoff", partition, node); } else if (client.hasPendingRequests(node)) { log.trace("Skipping fetch for partition because there is an in-flight request to {}", partition, node); } else { FetchSessionHandler.Builder builder = fetchable.get(node); if (builder == null) { int id = node.id(); FetchSessionHandler handler = sessionHandler(id); if (handler == null) { handler = new FetchSessionHandler(logContext, id); sessionHandlers.put(id, handler); } builder = handler.newBuilder(); fetchable.put(node, builder); } builder.add(partition, new FetchRequest.PartitionData(position.offset, FetchRequest.INVALID_LOG_START_OFFSET, this.fetchSize, position.currentLeader.epoch)); log.debug("Added fetch request for partition at position to node {}", isolationLevel, partition, position, node); } } Map<Node, FetchSessionHandler.FetchRequestData> reqs = new LinkedHashMap<>(); for (Map.Entry<Node, FetchSessionHandler.Builder> entry : fetchable.entrySet()) { reqs.put(entry.getKey(), entry.getValue().build()); } return reqs; }</code><technical_language>compute time.milliseconds() start of this loop pass selectReadReplica</technical_language>

Target:
private Map<Node, FetchSessionHandler.FetchRequestData> prepareFetchRequests() { Map<Node, FetchSessionHandler.Builder> fetchable = new LinkedHashMap<>(); subscriptions.assignedPartitions().forEach( tp -> subscriptions.maybeValidatePosition(tp, metadata.leaderAndEpoch(tp))); long currentTimeMs = time.milliseconds(); for (TopicPartition partition : fetchablePartitions()) { SubscriptionState.FetchPosition position = this.subscriptions.position(partition); Node node = selectReadReplica(partition, position.currentLeader.leader, currentTimeMs); if (node == null || node.isEmpty()) { metadata.requestUpdate(); } else if (client.isUnavailable(node)) { client.maybeThrowAuthFailure(node); log.trace("Skipping fetch for partition because node is awaiting reconnect backoff", partition, node); } else if (client.hasPendingRequests(node)) { log.trace("Skipping fetch for partition because there is an in-flight request to {}", partition, node); } else { FetchSessionHandler.Builder builder = fetchable.get(node); if (builder == null) { int id = node.id(); FetchSessionHandler handler = sessionHandler(id); if (handler == null) { handler = new FetchSessionHandler(logContext, id); sessionHandlers.put(id, handler); } builder = handler.newBuilder(); fetchable.put(node, builder); } builder.add(partition, new FetchRequest.PartitionData(position.offset, FetchRequest.INVALID_LOG_START_OFFSET, this.fetchSize, position.currentLeader.epoch)); log.debug("Added fetch request for partition at position to node {}", isolationLevel, partition, position, node); } } Map<Node, FetchSessionHandler.FetchRequestData> reqs = new LinkedHashMap<>(); for (Map.Entry<Node, FetchSessionHandler.Builder> entry : fetchable.entrySet()) { reqs.put(entry.getKey(), entry.getValue().build()); } return reqs; }