Skip to content

Commit 176bd71

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

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
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-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.List;
3030
import java.util.Map;
3131
import java.util.Objects;
32-
import java.util.Set;
3332
import java.util.concurrent.ExecutionException;
3433
import java.util.stream.Collectors;
3534
import java.util.stream.IntStream;
@@ -87,10 +86,11 @@ public List<Topic> createTopics(TopicsConfig config) {
8786
public int deleteTopics() {
8887
ListTopicsResult result = admin.listTopics();
8988
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();
89+
List<String> toDelete = result.names().get().stream()
90+
.filter(name -> name.startsWith(COMMON_TOPIC_PREFIX))
91+
.collect(Collectors.toList());
92+
admin.deleteTopics(toDelete).all().get();
93+
return toDelete.size();
9494
} catch (InterruptedException e) {
9595
Thread.currentThread().interrupt();
9696
} catch (ExecutionException ignored) {

0 commit comments

Comments
 (0)