private static PartitionReassignmentState topicDescriptionFutureToState(int partition,
                                                                            KafkaFuture<TopicDescription> future,
                                                                            List<Integer> targetReplicas
    ) throws InterruptedException, ExecutionException {
        try {
            TopicDescription topicDescription = future.get();
            if (topicDescription.partitions().size() < partition) {
                throw new ExecutionException("Too few partitions found", new UnknownTopicOrPartitionException());
            }
            return new PartitionReassignmentState(
                topicDescription.partitions().get(partition).replicas().stream().map(Node::id).collect(Collectors.toList()),
                targetReplicas,
                true);
        } catch (ExecutionException t) {
            if (t.getCause() instanceof UnknownTopicOrPartitionException)
                return new PartitionReassignmentState(Collections.emptyList(), targetReplicas, true);

            throw t;
        }
    }
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