-
Notifications
You must be signed in to change notification settings - Fork 521
[client] Add validation for client.scanner.log.max-poll-records and client.connect-timeout #3069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,4 +225,22 @@ private static void validMinValue(ConfigOption<Integer> option, int value, int m | |
| option.key(), minValue)); | ||
| } | ||
| } | ||
|
|
||
| public static void validateClientConfigs(Configuration conf) { | ||
| int maxPollRecords = conf.getInt(ConfigOptions.CLIENT_SCANNER_LOG_MAX_POLL_RECORDS); | ||
| if (maxPollRecords <= 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we use validMinValue?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, thanks! Switched to validMinValue |
||
| throw new IllegalConfigurationException( | ||
| String.format( | ||
| "Invalid configuration for %s, it must be greater than 0.", | ||
| ConfigOptions.CLIENT_SCANNER_LOG_MAX_POLL_RECORDS.key())); | ||
| } | ||
|
|
||
| long connectTimeoutMs = conf.get(ConfigOptions.CLIENT_CONNECT_TIMEOUT).toMillis(); | ||
| if (connectTimeoutMs <= 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mb we can have validMinDuration(conf, option, minMillis) helper to match the existing pattern?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a validMinDuration helper |
||
| throw new IllegalConfigurationException( | ||
| String.format( | ||
| "Invalid configuration for %s, it must be greater than 0.", | ||
| ConfigOptions.CLIENT_CONNECT_TIMEOUT.key())); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,4 +175,27 @@ void testValidateTabletConfigs() { | |
| .hasMessageContaining(ConfigOptions.TABLET_SERVER_ID.key()) | ||
| .hasMessageContaining("it must be greater than or equal 0"); | ||
| } | ||
|
|
||
| @Test | ||
| void testValidateClientConfigs() { | ||
| // valid defaults should pass | ||
| Configuration validConf = new Configuration(); | ||
| FlussConfigUtils.validateClientConfigs(validConf); | ||
|
|
||
| // max-poll-records = 0 should fail | ||
| Configuration zeroPollConf = new Configuration(); | ||
| zeroPollConf.set(ConfigOptions.CLIENT_SCANNER_LOG_MAX_POLL_RECORDS, 0); | ||
| assertThatThrownBy(() -> FlussConfigUtils.validateClientConfigs(zeroPollConf)) | ||
| .isInstanceOf(IllegalConfigurationException.class) | ||
| .hasMessageContaining(ConfigOptions.CLIENT_SCANNER_LOG_MAX_POLL_RECORDS.key()) | ||
| .hasMessageContaining("must be greater than 0"); | ||
|
|
||
| // connect-timeout = 0 should fail | ||
| Configuration zeroTimeoutConf = new Configuration(); | ||
| zeroTimeoutConf.set(ConfigOptions.CLIENT_CONNECT_TIMEOUT, java.time.Duration.ZERO); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: why fully qualified name?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replaced with import |
||
| assertThatThrownBy(() -> FlussConfigUtils.validateClientConfigs(zeroTimeoutConf)) | ||
| .isInstanceOf(IllegalConfigurationException.class) | ||
| .hasMessageContaining(ConfigOptions.CLIENT_CONNECT_TIMEOUT.key()) | ||
| .hasMessageContaining("must be greater than 0"); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we move
FlussConfigUtils.validateClientConfigs(conf)to the very first line of the constructor, beforeFileSystem.initialize(...)andsetupClientMetricsConfiguration()?Right now a bad config still initializes the filesystem and sets up metrics before failing, while fail-fast is cheaper and avoids partial side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to validate at the beginning of the constructor