private K randomKey() {
        if (availableKeys.isEmpty()) return null;

        int lastIndex = availableKeys.size() - 1;
        int randomIndex = random.nextInt(availableKeys.size());
        K randomKey = availableKeys.get(randomIndex);
        Collections.swap(availableKeys, randomIndex, lastIndex);
        availableKeys.remove(lastIndex);
        return randomKey;
    }
Returns the next available key. The key is selected randomly
from the available keys set.

This method must be called while holding the lock.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/runtime/EventAccumulator.java