Skip to content

Commit 035132b

Browse files
author
xiangying
committed
Add Cli
1 parent b2b1578 commit 035132b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,8 @@ public boolean matches(Long timestamp) {
20902090
cmdTopics.run(split("get-shadow-source persistent://myprop/clust/ns1/ds1"));
20912091
verify(mockTopics).getShadowSource("persistent://myprop/clust/ns1/ds1");
20922092

2093-
2093+
cmdTopics.run(split("get-message-id-by-offset persistent://myprop/clust/ns1/ds1 -o 0"));
2094+
verify(mockTopics).getMessageIdByOffset("persistent://myprop/clust/ns1/ds1", 0);
20942095

20952096
}
20962097

pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ public CmdTopics(Supplier<PulsarAdmin> admin) {
275275
addCommand("set-schema-validation-enforce", new SetSchemaValidationEnforced());
276276

277277
addCommand("trim-topic", new TrimTopic());
278+
279+
addCommand("get-message-id-by-offset", new GetMessageIdByOffset());
278280
}
279281

280282
@Command(description = "Get the list of topics under a namespace.")
@@ -3058,4 +3060,20 @@ void run() throws PulsarAdminException {
30583060
getAdmin().topics().trimTopic(topic);
30593061
}
30603062
}
3063+
3064+
@Command(description = "Get message id by offset")
3065+
private class GetMessageIdByOffset extends CliCommand {
3066+
3067+
@Parameters(description = "persistent://tenant/namespace/topic", arity = "1")
3068+
private String topicName;
3069+
3070+
@Option(names = { "--offset", "-o" }, description = "Offset to get message id for the topic", required = true)
3071+
private Long offset;
3072+
3073+
@Override
3074+
void run() throws Exception {
3075+
String topic = validateTopicName(topicName);
3076+
getAdmin().topics().getMessageIdByOffset(topic, offset);
3077+
}
3078+
}
30613079
}

0 commit comments

Comments
 (0)