Skip to content

Commit

Permalink
Fix changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JooHyukKim committed Jul 4, 2023
1 parent 4924135 commit 90e51ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1252,14 +1252,12 @@ private class SetBacklogQuota extends CliCommand {
private java.util.List<String> params;

@Parameter(names = { "-l", "--limit" }, description = "Size limit (eg: 10M, 16G)",
required = true,
converter = ByteUnitLongConverter.class)
private Long limit;

@Parameter(names = { "-lt", "--limitTime" },
description = "Time limit in second (or minutes, hours, days, weeks eg: 100m, 3h, 2d, 5w), "
+ "non-positive number for disabling time limit.",
required = true,
converter = TimeUnitToSecondsConverter.class,
validateValueWith = PositiveValueValidator.class)
private Long limitTimeInSec;
Expand Down Expand Up @@ -1300,9 +1298,15 @@ void run() throws PulsarAdminException {
BacklogQuota.Builder builder = BacklogQuota.builder().retentionPolicy(policy);
if (backlogQuotaType == BacklogQuota.BacklogQuotaType.destination_storage) {
// set quota by storage size
if (limit == null) {
throw new ParameterException("Quota type of 'destination_storage' needs a size limit");
}
builder.limitSize(limit);
} else {
// set quota by time
if (limitTimeInSec == null) {
throw new ParameterException("Quota type of 'message_age' needs a time limit");
}
builder.limitTime(limitTimeInSec.intValue());
}
getAdmin().namespaces().setBacklogQuota(namespace, builder.build(), backlogQuotaType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Long convert(String argStr) {
Long parseBytes(String argStr) {
emptyCheck(getOptionName(), argStr);
long valueInBytes = ByteUnitUtil.validateSizeString(argStr);
maxValueCheck(getOptionName(), valueInBytes, Integer.MAX_VALUE);
maxValueCheck(getOptionName(), valueInBytes, Long.MAX_VALUE);
positiveCheck(getOptionName(), valueInBytes);
return valueInBytes;
}
Expand Down

0 comments on commit 90e51ed

Please sign in to comment.