private void change(int brokerId, Uuid topicId, int partition,
                        boolean wasLeader, boolean isLeader) {
        TimelineHashMap<Uuid, int[]> topicMap = isrMembers.get(brokerId);
        if (topicMap == null) {
            throw new RuntimeException("Broker " + brokerId + " has no isrMembers " +
                "entry, so we can't change " + topicId + ":" + partition);
        }
        int[] partitions = topicMap.get(topicId);
        if (partitions == null) {
            throw new RuntimeException("Broker " + brokerId + " has no " +
                "entry in isrMembers for topic " + topicId);
        }
        int[] newPartitions = new int[partitions.length];
        int target = wasLeader ? partition | LEADER_FLAG : partition;
        for (int i = 0; i < partitions.length; i++) {
            int cur = partitions[i];
            if (cur == target) {
                newPartitions[i] = isLeader ? partition | LEADER_FLAG : partition;
            } else {
                newPartitions[i] = cur;
            }
        }
        topicMap.put(topicId, newPartitions);
    }
Update our records of a partition's ISR.

@param topicId       The topic ID of the partition.
@param partitionId   The partition ID of the partition.
@param prevIsr       The previous ISR, or null if the partition is new.
@param nextIsr       The new ISR, or null if the partition is being removed.
@param prevLeader    The previous leader, or NO_LEADER if the partition had no leader.
@param nextLeader    The new leader, or NO_LEADER if the partition now has no leader.
metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java