From ac0092369a05bc452155c8300c6cb29e8e7b8f64 Mon Sep 17 00:00:00 2001 From: Yong Zhang Date: Fri, 23 Feb 2024 20:23:38 +0800 Subject: [PATCH 1/2] [improve][admin] Expose the offload threshold in seconds to the amdin (#22101) (cherry picked from commit 48c7e322fecfbcee0df758bdaf7e9b4263f2835e) --- .../org/apache/pulsar/admin/cli/CmdNamespaces.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java index 998591f8177d1..28e8fb8d5f5b2 100644 --- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java +++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java @@ -1962,7 +1962,8 @@ private class GetOffloadThreshold extends CliCommand { @Override void run() throws PulsarAdminException { String namespace = validateNamespace(params); - print(getAdmin().namespaces().getOffloadThreshold(namespace)); + print("offloadThresholdInBytes: " + getAdmin().namespaces().getOffloadThreshold(namespace)); + print("offloadThresholdInSeconds: " + getAdmin().namespaces().getOffloadThresholdInSeconds(namespace)); } } @@ -1980,11 +1981,18 @@ private class SetOffloadThreshold extends CliCommand { required = true) private String thresholdStr = "-1"; + @Parameter(names = {"--time", "-t"}, + description = "Maximum number of seconds stored on the pulsar cluster for a topic" + + " before the broker will start offloading to longterm storage (eg: 10m, 5h, 3d, 2w).", + converter = TimeUnitToSecondsConverter.class) + private Long thresholdInSeconds = -1L; + @Override void run() throws PulsarAdminException { String namespace = validateNamespace(params); long threshold = validateSizeString(thresholdStr); getAdmin().namespaces().setOffloadThreshold(namespace, threshold); + getAdmin().namespaces().setOffloadThresholdInSeconds(namespace, thresholdInSeconds); } } From 9c68e80a2457584296483e8fcfb0ca3616c59362 Mon Sep 17 00:00:00 2001 From: zymap Date: Fri, 1 Mar 2024 10:03:49 +0800 Subject: [PATCH 2/2] [imporve][admin][branch-3.0]Port the change 22101 to branch-3.0 --- .../java/org/apache/pulsar/admin/cli/CmdNamespaces.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java index 28e8fb8d5f5b2..9c32041a36503 100644 --- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java +++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java @@ -1983,16 +1983,16 @@ private class SetOffloadThreshold extends CliCommand { @Parameter(names = {"--time", "-t"}, description = "Maximum number of seconds stored on the pulsar cluster for a topic" - + " before the broker will start offloading to longterm storage (eg: 10m, 5h, 3d, 2w).", - converter = TimeUnitToSecondsConverter.class) - private Long thresholdInSeconds = -1L; + + " before the broker will start offloading to longterm storage (eg: 10m, 5h, 3d, 2w).") + private String thresholdInSeconds = "-1"; @Override void run() throws PulsarAdminException { String namespace = validateNamespace(params); long threshold = validateSizeString(thresholdStr); + long timeInSeconds = RelativeTimeUtil.parseRelativeTimeInSeconds(thresholdInSeconds); getAdmin().namespaces().setOffloadThreshold(namespace, threshold); - getAdmin().namespaces().setOffloadThresholdInSeconds(namespace, thresholdInSeconds); + getAdmin().namespaces().setOffloadThresholdInSeconds(namespace, timeInSeconds); } }