private void maybeCheckExpectedTopics(MetadataUpdate update, MetadataRequest.Builder builder) {
            if (update.expectMatchRefreshTopics) {
                if (builder.isAllTopics())
                    throw new IllegalStateException("The metadata topics does not match expectation. "
                            + "Expected topics: " + update.topics()
                            + ", asked topics: ALL");

                Set<String> requestedTopics = new HashSet<>(builder.topics());
                if (!requestedTopics.equals(update.topics())) {
                    throw new IllegalStateException("The metadata topics does not match expectation. "
                            + "Expected topics: " + update.topics()
                            + ", asked topics: " + requestedTopics);
                }
            }
        }
This is a dumbed down version of {@link MetadataUpdater} which is used to facilitate
metadata tracking primarily in order to serve {@link KafkaClient#leastLoadedNode(long)}
and bookkeeping through {@link Metadata}. The extensibility allows AdminClient, which does
not rely on {@link Metadata} to do its own thing.
clients/src/test/java/org/apache/kafka/clients/MockClient.java