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;
    }
@Test
    public void testTryUpdatingPreferredReadReplica() {
        state.assignFromUser(Collections.singleton(tp0));
        final TopicPartition unassignedPartition = new TopicPartition("unassigned", 0);

        final int preferredReadReplicaId = 10;
        final LongSupplier expirationTimeMs = () -> System.currentTimeMillis() + 60000L;
        assertTrue(state.tryUpdatingPreferredReadReplica(tp0, preferredReadReplicaId, expirationTimeMs));
        assertEquals(Optional.of(preferredReadReplicaId), state.preferredReadReplica(tp0, System.currentTimeMillis()));
        assertFalse(state.tryUpdatingPreferredReadReplica(unassignedPartition, preferredReadReplicaId, expirationTimeMs));
        assertEquals(Optional.empty(), state.preferredReadReplica(unassignedPartition, System.currentTimeMillis()));
    }