static void createTopics(
        Logger log, Admin adminClient,
        Map<String, NewTopic> topics, boolean failOnExisting) throws Throwable {
        if (topics.isEmpty()) {
            log.warn("Request to create topics has an empty topic list.");
            return;
        }

        Collection<String> topicsExists = createTopics(log, adminClient, topics.values());
        if (!topicsExists.isEmpty()) {
            if (failOnExisting) {
                log.warn("Topic(s) {} already exist.", topicsExists);
                throw new TopicExistsException("One or more topics already exist.");
            } else {
                verifyTopics(log, adminClient, topicsExists, topics, 3, 2500);
            }
        }
    }
The actual create topics functionality is separated into this method and called from the
above method to be able to unit test with mock adminClient.
@throws TopicExistsException if the specified topic already exists.
@throws UnknownTopicOrPartitionException if topic creation was issued but failed to verify if it was created.
@throws Throwable if creation of one or more topics fails (except for the cases above).
trogdor/src/main/java/org/apache/kafka/trogdor/common/WorkerUtils.java