Skip to content

Commit

Permalink
Update the pulsar admin cli java doc to support set/get/remove dedupl…
Browse files Browse the repository at this point in the history
…ication on topic level (apache#7938)

Fixes apache#7920

### Motivation
set/get/remove deduplication policy is on topic level. But the pulsar admin cli java doc is not supported accordingly.
  • Loading branch information
315157973 authored Sep 3, 2020
1 parent 5432e86 commit 1030fbe
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,15 @@ public void topics() throws Exception {
cmdTopics.run(split("peek-messages persistent://myprop/clust/ns1/ds1 -s sub1 -n 3"));
verify(mockTopics).peekMessages("persistent://myprop/clust/ns1/ds1", "sub1", 3);

cmdTopics.run(split("enable-deduplication persistent://myprop/clust/ns1/ds1"));
verify(mockTopics).enableDeduplication("persistent://myprop/clust/ns1/ds1", true);

cmdTopics.run(split("disable-deduplication persistent://myprop/clust/ns1/ds1"));
verify(mockTopics).enableDeduplication("persistent://myprop/clust/ns1/ds1", false);

cmdTopics.run(split("get-deduplication-enabled persistent://myprop/clust/ns1/ds1"));
verify(mockTopics).getDeduplicationEnabled("persistent://myprop/clust/ns1/ds1");

cmdTopics.run(split("get-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1"));
verify(mockTopics).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1");
cmdTopics.run(split("remove-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public CmdTopics(PulsarAdmin admin) {
jcommander.addCommand("get-retention", new GetRetention());
jcommander.addCommand("set-retention", new SetRetention());
jcommander.addCommand("remove-retention", new RemoveRetention());

jcommander.addCommand("enable-deduplication", new EnableDeduplication());
jcommander.addCommand("disable-deduplication", new DisableDeduplication());
jcommander.addCommand("get-deduplication-enabled", new GetDeduplicationEnabled());

jcommander.addCommand("get-delayed-delivery", new GetDelayedDelivery());
jcommander.addCommand("set-delayed-delivery", new SetDelayedDelivery());
jcommander.addCommand("remove-delayed-delivery", new RemoveDelayedDelivery());
Expand Down Expand Up @@ -1061,6 +1066,42 @@ void run() throws PulsarAdminException {
}
}

@Parameters(commandDescription = "Enable the deduplication policy for a topic")
private class EnableDeduplication extends CliCommand {
@Parameter(description = "persistent://tenant/namespace/topic", required = true)
private java.util.List<String> params;

@Override
void run() throws PulsarAdminException {
String persistentTopic = validatePersistentTopic(params);
admin.topics().enableDeduplication(persistentTopic, true);
}
}

@Parameters(commandDescription = "Disable the deduplication policy for a topic")
private class DisableDeduplication extends CliCommand {
@Parameter(description = "persistent://tenant/namespace/topic", required = true)
private java.util.List<String> params;

@Override
void run() throws PulsarAdminException {
String persistentTopic = validatePersistentTopic(params);
admin.topics().enableDeduplication(persistentTopic, false);
}
}

@Parameters(commandDescription = "Get the deduplication policy for a topic")
private class GetDeduplicationEnabled extends CliCommand {
@Parameter(description = "persistent://tenant/namespace/topic", required = true)
private java.util.List<String> params;

@Override
void run() throws PulsarAdminException {
String persistentTopic = validatePersistentTopic(params);
print(admin.topics().getDeduplicationEnabled(persistentTopic));
}
}

@Parameters(commandDescription = "Remove the retention policy for a topic")
private class RemoveRetention extends CliCommand {
@Parameter(description = "persistent://tenant/namespace/topic", required = true)
Expand Down

0 comments on commit 1030fbe

Please sign in to comment.