public synchronized boolean tryUpdatingPreferredReadReplica(TopicPartition tp,
                                                             int preferredReadReplicaId,
                                                             LongSupplier timeMs) {
        final TopicPartitionState state = assignedStateOrNull(tp);
        if (state != null) {
            assignedState(tp).updatePreferredReadReplica(preferredReadReplicaId, timeMs);
            return true;
        }
        return false;
    }
Tries to set the preferred read replica with a lease timeout. After this time, the replica will no longer be valid and
{@link #preferredReadReplica(TopicPartition, long)} will return an empty result. If the preferred replica of
the partition could not be updated (e.g. because the partition is not assigned) this method will return
{@code false}, otherwise it will return {@code true}.

@param tp The topic partition
@param preferredReadReplicaId The preferred read replica
@param timeMs The time at which this preferred replica is no longer valid
@return {@code true} if the preferred read replica was updated, {@code false} otherwise.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/SubscriptionState.java