yuruguo commented on a change in pull request #13445: URL: https://github.com/apache/pulsar/pull/13445#discussion_r774457255
########## File path: pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java ########## @@ -118,6 +124,104 @@ void run() throws PulsarAdminException { } } + @Parameters(commandDescription = "Get the backlog quota policies for a topic") + private class GetBacklogQuotaMap extends CliCommand { + @Parameter(description = "persistent://tenant/namespace/topic", required = true) + private java.util.List<String> params; + + @Parameter(names = {"-ap", "--applied"}, description = "Get the applied policy of the topic") + private boolean applied = false; + + @Parameter(names = { "--global", "-g" }, description = "Whether to get this policy globally. " + + "If set to true, broker returned global topic policies", arity = 0) + private boolean isGlobal = false; + + @Override + void run() throws PulsarAdminException { + String persistentTopic = validatePersistentTopic(params); + print(getTopicPolicies(isGlobal).getBacklogQuotaMap(persistentTopic, applied)); + } + } + + @Parameters(commandDescription = "Set a backlog quota policy for a topic") + private class SetBacklogQuota extends CliCommand { + @Parameter(description = "persistent://tenant/namespace/topic", required = true) + private java.util.List<String> params; + + @Parameter(names = { "-l", "--limit" }, description = "Size limit (eg: 10M, 16G)") + private String limitStr = "-1"; + + @Parameter(names = { "-lt", "--limitTime" }, description = "Time limit in second, non-positive number for disabling time limit.") + private int limitTime = -1; + + @Parameter(names = { "-p", "--policy" }, description = "Retention policy to enforce when the limit is reached. " + + "Valid options are: [producer_request_hold, producer_exception, consumer_backlog_eviction]", required = true) + private String policyStr; + + @Parameter(names = {"-t", "--type"}, description = "Backlog quota type to set. Valid options are: " + + "destination_storage and message_age. " + + "destination_storage limits backlog by size (in bytes). " + + "message_age limits backlog by time, that is, message timestamp (broker or publish timestamp). " + + "You can set size or time to control the backlog, or combine them together to control the backlog. ") + private String backlogQuotaTypeStr = BacklogQuota.BacklogQuotaType.destination_storage.name(); Review comment: `String backlogQuotaTypeStr = BacklogQuota.BacklogQuotaType.destination_storage.name()` -> `BacklogQuota.BacklogQuotaType backlogQuotaType = BacklogQuota.BacklogQuotaType.destination_storage` It can avoid the conversion of the following string to enum and give a prompt directly when backlogQuotaType is illegal -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org