private void movePartition(TopicIdPartition partition, String oldOwner, String newOwner) {
            MemberPair pair = new MemberPair(oldOwner, newOwner);

            if (partitionMovementsByPartition.containsKey(partition)) {
                // This partition was previously moved.
                MemberPair existingPair = removeMovementRecordOfPartition(partition);
                if (existingPair.dstMemberId.equals(oldOwner)) {
                    throw new PartitionAssignorException("Mismatch in partition movement record with respect to " +
                        "partition ownership during a rebalance"
                    );
                }
                if (!existingPair.srcMemberId.equals(newOwner)) {
                    // The partition is not moving back to its previous member.
                    addPartitionMovementRecord(partition, new MemberPair(existingPair.srcMemberId, newOwner));
                }
            } else
                addPartitionMovementRecord(partition, pair);
        }
This class maintains some data structures to simplify lookup of partition movements among members.
During a partition rebalance, it keeps track of partition movements corresponding to each topic,
and also possible movement (in form a <code>MemberPair</code> object) for each partition.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHeterogeneousAssignmentBuilder.java