Skip to content

Commit

Permalink
[improve][admin][branch-3.0] Expose the offload threshold in seconds …
Browse files Browse the repository at this point in the history
…to the admin (apache#22169)

(cherry picked from commit 21660bd)
  • Loading branch information
zymap authored and mukesh-ctds committed Apr 19, 2024
1 parent 00366f2 commit 02c916b
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -1961,7 +1961,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));
}
}

Expand All @@ -1979,11 +1980,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).")
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, timeInSeconds);
}
}

Expand Down

0 comments on commit 02c916b

Please sign in to comment.