Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

describe only filtered topics #629

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/main/java/org/akhq/repositories/TopicRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.inject.Singleton;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;

@Singleton
public class TopicRepository extends AbstractRepository {
Expand Down Expand Up @@ -100,14 +101,15 @@ public Topic findByName(String clusterId, String name) throws ExecutionException

public List<Topic> findByName(String clusterId, List<String> topics) throws ExecutionException, InterruptedException {
ArrayList<Topic> list = new ArrayList<>();

Set<Map.Entry<String, TopicDescription>> topicDescriptions = kafkaWrapper.describeTopics(clusterId, topics).entrySet();
Map<String, List<Partition.Offsets>> topicOffsets = kafkaWrapper.describeTopicsOffsets(clusterId, topics);

Optional<List<String>> topicRegex = getTopicFilterRegex();

List<String> filteredTopics = topics.stream()
.filter(t -> isMatchRegex(topicRegex, t))
.collect(Collectors.toList());
Set<Map.Entry<String, TopicDescription>> topicDescriptions = kafkaWrapper.describeTopics(clusterId, filteredTopics).entrySet();
Map<String, List<Partition.Offsets>> topicOffsets = kafkaWrapper.describeTopicsOffsets(clusterId, filteredTopics);

for (Map.Entry<String, TopicDescription> description : topicDescriptions) {
if(isMatchRegex(topicRegex, description.getValue().name())){
list.add(
new Topic(
description.getValue(),
Expand All @@ -117,7 +119,6 @@ public List<Topic> findByName(String clusterId, List<String> topics) throws Exec
isStream(description.getValue().name())
)
);
}
}

list.sort(Comparator.comparing(Topic::getName));
Expand Down