private static void verifyBrokerIds(Admin adminClient, Set<Integer> brokers) throws ExecutionException, InterruptedException {
        Set<Integer> allNodeIds = adminClient.describeCluster().nodes().get().stream().map(Node::id).collect(Collectors.toSet());
        Optional<Integer> unknown = brokers.stream()
            .filter(brokerId -> !allNodeIds.contains(brokerId))
            .findFirst();
        if (unknown.isPresent())
            throw new AdminCommandFailedException("Unknown broker id " + unknown.get());
    }
Verify that all the brokers in an assignment exist.

@param adminClient                 The AdminClient to use.
@param brokers                     The broker IDs to verify.
tools/src/main/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommand.java