static Entry<Map<TopicPartition, PartitionReassignmentState>, Boolean> findPartitionReassignmentStates(Admin adminClient,
                                                                                                            List<Entry<TopicPartition,
                                                                                                            List<Integer>>> targetReassignments
    ) throws ExecutionException, InterruptedException {
        Map<TopicPartition, PartitionReassignment> currentReassignments = adminClient.
            listPartitionReassignments().reassignments().get();

        List<Entry<TopicPartition, List<Integer>>> foundReassignments = new ArrayList<>();
        List<Entry<TopicPartition, List<Integer>>> notFoundReassignments = new ArrayList<>();

        targetReassignments.forEach(reassignment -> {
            if (currentReassignments.containsKey(reassignment.getKey()))
                foundReassignments.add(reassignment);
            else
                notFoundReassignments.add(reassignment);
        });

        List<Entry<TopicPartition, PartitionReassignmentState>> foundResults = foundReassignments.stream().map(e -> {
            TopicPartition part = e.getKey();
            List<Integer> targetReplicas = e.getValue();
            return new SimpleImmutableEntry<>(part,
                new PartitionReassignmentState(
                    currentReassignments.get(part).replicas(),
                    targetReplicas,
                    false));
        }).collect(Collectors.toList());

        Set<String> topicNamesToLookUp = notFoundReassignments.stream()
            .map(e -> e.getKey())
            .filter(part -> !currentReassignments.containsKey(part))
            .map(TopicPartition::topic)
            .collect(Collectors.toSet());

        Map<String, KafkaFuture<TopicDescription>> topicDescriptions = adminClient.
            describeTopics(topicNamesToLookUp).topicNameValues();

        List<Entry<TopicPartition, PartitionReassignmentState>> notFoundResults = new ArrayList<>();
        for (Entry<TopicPartition, List<Integer>> e : notFoundReassignments) {
            TopicPartition part = e.getKey();
            List<Integer> targetReplicas = e.getValue();

            if (currentReassignments.containsKey(part)) {
                PartitionReassignment reassignment = currentReassignments.get(part);
                notFoundResults.add(new SimpleImmutableEntry<>(part, new PartitionReassignmentState(
                    reassignment.replicas(),
                    targetReplicas,
                    false)));
            } else {
                notFoundResults.add(new SimpleImmutableEntry<>(part, topicDescriptionFutureToState(part.partition(),
                    topicDescriptions.get(part.topic()), targetReplicas)));
            }
        }

        Map<TopicPartition, PartitionReassignmentState> allResults = new HashMap<>();
        foundResults.forEach(e -> allResults.put(e.getKey(), e.getValue()));
        notFoundResults.forEach(e -> allResults.put(e.getKey(), e.getValue()));

        return new SimpleImmutableEntry<>(allResults, !currentReassignments.isEmpty());
    }
Find the state of the specified partition reassignments.

@param adminClient          The Admin client to use.
@param targetReassignments  The reassignments we want to learn about.

@return                     A tuple containing the reassignment states for each topic
                            partition, plus whether there are any ongoing reassignments.
tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java