|
31 | 31 | import java.util.Map;
|
32 | 32 | import java.util.Objects;
|
33 | 33 | import java.util.Optional;
|
| 34 | +import java.util.Set; |
34 | 35 | import java.util.function.Function;
|
35 | 36 | import java.util.function.Supplier;
|
36 | 37 | import java.util.stream.Collectors;
|
@@ -63,7 +64,9 @@ static KafkaTopicClient createProxy(final KafkaTopicClient delegate,
|
63 | 64 | .forward("isTopicExists", methodParams(String.class), sandbox)
|
64 | 65 | .forward("describeTopic", methodParams(String.class), sandbox)
|
65 | 66 | .forward("getTopicConfig", methodParams(String.class), sandbox)
|
| 67 | + .forward("describeTopic", methodParams(String.class, Boolean.class), sandbox) |
66 | 68 | .forward("describeTopics", methodParams(Collection.class), sandbox)
|
| 69 | + .forward("describeTopics", methodParams(Collection.class, Boolean.class), sandbox) |
67 | 70 | .forward("deleteTopics", methodParams(Collection.class), sandbox)
|
68 | 71 | .forward("listTopicsStartOffsets", methodParams(Collection.class), sandbox)
|
69 | 72 | .forward("listTopicsEndOffsets", methodParams(Collection.class), sandbox)
|
@@ -159,21 +162,32 @@ public TopicDescription describeTopic(final String topicName) {
|
159 | 162 | return describeTopics(ImmutableList.of(topicName)).get(topicName);
|
160 | 163 | }
|
161 | 164 |
|
| 165 | + public TopicDescription describeTopic(final String topicName, |
| 166 | + final Boolean skipRetriesOnFailure) { |
| 167 | + return describeTopics(ImmutableList.of(topicName), skipRetriesOnFailure).get(topicName); |
| 168 | + } |
| 169 | + |
162 | 170 | private Map<String, TopicDescription> describeTopics(final Collection<String> topicNames) {
|
| 171 | + return describeTopics(topicNames, false); |
| 172 | + } |
| 173 | + |
| 174 | + private Map<String, TopicDescription> describeTopics(final Collection<String> topicNames, |
| 175 | + final Boolean skipRetriesOnFailure) { |
163 | 176 | final Map<String, TopicDescription> descriptions = topicNames.stream()
|
164 | 177 | .map(createdTopics::get)
|
165 | 178 | .filter(Objects::nonNull)
|
166 | 179 | .collect(Collectors.toMap(TopicDescription::name, Function.identity()));
|
167 | 180 |
|
168 |
| - final HashSet<String> remaining = new HashSet<>(topicNames); |
169 |
| - remaining.removeAll(descriptions.keySet()); |
170 |
| - if (remaining.isEmpty()) { |
| 181 | + final Set<String> topicsToFetch = new HashSet<>(topicNames); |
| 182 | + topicsToFetch.removeAll(descriptions.keySet()); |
| 183 | + if (topicsToFetch.isEmpty()) { |
171 | 184 | return descriptions;
|
172 | 185 | }
|
173 | 186 |
|
174 |
| - final Map<String, TopicDescription> fromKafka = delegate.describeTopics(remaining); |
| 187 | + final Map<String, TopicDescription> remainingTopicDescriptionMap = |
| 188 | + delegate.describeTopics(topicsToFetch, skipRetriesOnFailure); |
175 | 189 |
|
176 |
| - descriptions.putAll(fromKafka); |
| 190 | + descriptions.putAll(remainingTopicDescriptionMap); |
177 | 191 | return descriptions;
|
178 | 192 | }
|
179 | 193 |
|
|
0 commit comments