public synchronized Optional<Integer> preferredReadReplica(TopicPartition tp, long timeMs) {
        final TopicPartitionState topicPartitionState = assignedStateOrNull(tp);
        if (topicPartitionState == null) {
            return Optional.empty();
        } else {
            return topicPartitionState.preferredReadReplica(timeMs);
        }
    }
Get the preferred read replica

@param tp The topic partition
@param timeMs The current time
@return Returns the current preferred read replica, if it has been set and if it has not expired.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/SubscriptionState.java