Skip to content

Commit 98a387f

Browse files
committed
fix(tools/perf): only delete test topics on reset
Signed-off-by: Ning Yu <[email protected]>
1 parent 3235c49 commit 98a387f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tools/src/main/java/org/apache/kafka/tools/automq/PerfCommand.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ private void run() {
9595
TimerUtil timer = new TimerUtil();
9696

9797
if (config.reset) {
98-
LOGGER.info("Deleting all topics...");
98+
LOGGER.info("Deleting all test topics...");
9999
int deleted = topicService.deleteTopics();
100-
LOGGER.info("Deleted all topics ({} in total), took {} ms", deleted, timer.elapsedAndResetAs(TimeUnit.MILLISECONDS));
100+
LOGGER.info("Deleted all test topics ({} in total), took {} ms", deleted, timer.elapsedAndResetAs(TimeUnit.MILLISECONDS));
101101
}
102102

103103
LOGGER.info("Creating topics...");

tools/src/main/java/org/apache/kafka/tools/automq/perf/TopicService.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ public List<Topic> createTopics(TopicsConfig config) {
8787
public int deleteTopics() {
8888
ListTopicsResult result = admin.listTopics();
8989
try {
90-
Set<String> topics = result.names().get();
91-
topics.removeIf(name -> name.startsWith(COMMON_TOPIC_PREFIX));
92-
admin.deleteTopics(topics).all().get();
93-
return topics.size();
90+
List<String> toDelete = result.names().get().stream()
91+
.filter(name -> name.startsWith(COMMON_TOPIC_PREFIX))
92+
.collect(Collectors.toList());
93+
admin.deleteTopics(toDelete).all().get();
94+
return toDelete.size();
9495
} catch (InterruptedException e) {
9596
Thread.currentThread().interrupt();
9697
} catch (ExecutionException ignored) {

0 commit comments

Comments
 (0)