You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2020/09/03 14:36:53 UTC
[pulsar] branch master updated: Update the pulsar admin cli java
doc to support set/get/remove deduplication on topic level (#7938)
This is an automated email from the ASF dual-hosted git repository.
penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 1030fbe Update the pulsar admin cli java doc to support set/get/remove deduplication on topic level (#7938)
1030fbe is described below
commit 1030fbe85c2c5d490634b426e8994f3e1917928c
Author: feynmanlin <fe...@tencent.com>
AuthorDate: Thu Sep 3 22:36:37 2020 +0800
Update the pulsar admin cli java doc to support set/get/remove deduplication on topic level (#7938)
Fixes #7920
### Motivation
set/get/remove deduplication policy is on topic level. But the pulsar admin cli java doc is not supported accordingly.
---
.../pulsar/admin/cli/PulsarAdminToolTest.java | 9 +++++
.../org/apache/pulsar/admin/cli/CmdTopics.java | 41 ++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
index c684329..c0f0ad5 100644
--- a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
+++ b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
@@ -726,6 +726,15 @@ public class PulsarAdminToolTest {
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"));
diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
index 313bbe2..52241ed 100644
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
+++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
@@ -115,6 +115,11 @@ public class CmdTopics extends CmdBase {
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());
@@ -1061,6 +1066,42 @@ public class CmdTopics extends CmdBase {
}
}
+ @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)