Skip to content

Commit

Permalink
feat: limit the min of --backlog-duration
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yu <[email protected]>
  • Loading branch information
Chillax-0v0 committed Nov 6, 2024
1 parent 234d132 commit bd1802a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import static net.sourceforge.argparse4j.impl.Arguments.storeTrue;
import static org.apache.kafka.tools.automq.perf.PerfConfig.IntegerArgumentType.nonNegativeInteger;
import static org.apache.kafka.tools.automq.perf.PerfConfig.IntegerArgumentType.notLessThan;
import static org.apache.kafka.tools.automq.perf.PerfConfig.IntegerArgumentType.positiveInteger;

public class PerfConfig {
Expand Down Expand Up @@ -204,7 +205,7 @@ public static ArgumentParser parser() {
.help("The send rate in messages per second during catchup. If not set, the send rate will be used.");
parser.addArgument("-b", "--backlog-duration")
.setDefault(0)
.type(nonNegativeInteger())
.type(notLessThan(300))
.dest("backlogDurationSeconds")
.metavar("BACKLOG_DURATION_SECONDS")
.help("The backlog duration in seconds, and zero means no backlog. Should not be less than GROUPS_PER_TOPIC * GROUP_START_DELAY_SECONDS.");
Expand Down Expand Up @@ -316,6 +317,10 @@ public static IntegerArgumentType nonNegativeInteger() {
public static IntegerArgumentType positiveInteger() {
return new IntegerArgumentType(value -> value <= 0 ? "expected a positive integer, but got " + value : null);
}

public static IntegerArgumentType notLessThan(int min) {
return new IntegerArgumentType(value -> value < min ? "expected an integer not less than " + min + ", but got " + value : null);
}
}

@FunctionalInterface
Expand Down

0 comments on commit bd1802a

Please sign in to comment.