@Override public void onMetadataUpdate(Cluster cluster, Set<String> unavailableTopics) { // if we encounter any unauthorized topics, raise an exception to the user if (!cluster.unauthorizedTopics().isEmpty()) throw new TopicAuthorizationException(new HashSet<>(cluster.unauthorizedTopics())); // if we encounter any invalid topics, raise an exception to the user if (!cluster.invalidTopics().isEmpty()) throw new InvalidTopicException(cluster.invalidTopics()); if (subscriptions.hasPatternSubscription()) updatePatternSubscription(cluster); // check if there are any changes to the metadata which should trigger a rebalance if (subscriptions.partitionsAutoAssigned()) { MetadataSnapshot snapshot = new MetadataSnapshot(subscriptions, cluster); if (!snapshot.equals(metadataSnapshot)) metadataSnapshot = snapshot; } if (!Collections.disjoint(metadata.topics(), unavailableTopics)) metadata.requestUpdate(); } });
Cluster cluster = response.cluster(); Set<String> unauthorizedTopics = cluster.unauthorizedTopics(); if (!unauthorizedTopics.isEmpty()) throw new TopicAuthorizationException(unauthorizedTopics);
partition, topic, partitionsCount, maxWaitMs)); if (cluster.unauthorizedTopics().contains(topic)) throw new TopicAuthorizationException(topic); if (cluster.invalidTopics().contains(topic))
assertEquals(cluster.unauthorizedTopics(), Collections.singleton("topic4")); assertEquals(cluster.topics().size(), 3); assertEquals(cluster.internalTopics(), Collections.singleton(Topic.GROUP_METADATA_TOPIC_NAME));