static Map<TopicPartition, List<Integer>> getReplicaAssignmentForTopics(Admin adminClient,
                                                                            List<String> topics
    ) throws ExecutionException, InterruptedException {
        Map<TopicPartition, List<Integer>> res = new HashMap<>();
        describeTopics(adminClient, new HashSet<>(topics)).forEach((topicName, topicDescription) ->
            topicDescription.partitions().forEach(info -> res.put(
                new TopicPartition(topicName, info.partition()),
                info.replicas().stream().map(Node::id).collect(Collectors.toList())
            )
        ));
        return res;
    }
Get the current replica assignments for some topics.

@param adminClient     The AdminClient to use.
@param topics          The topics to get information about.
@return                A map from partitions to broker assignments.
                       If any topic can't be found, an exception will be thrown.
tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java