From c76bb1e86c247006481bae13b8ac24628957834a Mon Sep 17 00:00:00 2001 From: zymap Date: Fri, 23 Feb 2024 10:20:47 +0800 Subject: [PATCH] [improve][admin] Expose the offload threshold in seconds to the amdin --- ### Motivation We have two configurations to trigger the offload automatically, time and bytes. We only expose the bytes in the admin but didn't expose the time in the admin. When we want to disable it, we need to set both of them to the -1. But we didn't expose the time settings, the offload will never be disabled. --- .../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 4394fc0002780..6614e44b9a8c7 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 @@ -1941,7 +1941,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)); } } @@ -1960,10 +1961,17 @@ private class SetOffloadThreshold extends CliCommand { converter = ByteUnitToLongConverter.class) private Long threshold = -1L; + @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); getAdmin().namespaces().setOffloadThreshold(namespace, threshold); + getAdmin().namespaces().setOffloadThresholdInSeconds(namespace, thresholdInSeconds); } }