Skip to content

[client] Add validation for client.scanner.log.max-poll-records and client.connect-timeout#3069

Open
Prajwal-banakar wants to merge 1 commit intoapache:mainfrom
Prajwal-banakar:client-Add-validation
Open

[client] Add validation for client.scanner.log.max-poll-records and client.connect-timeout#3069
Prajwal-banakar wants to merge 1 commit intoapache:mainfrom
Prajwal-banakar:client-Add-validation

Conversation

@Prajwal-banakar
Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #3068

Add client config validation for client.scanner.log.max-poll-records and client.connect-timeout during FlussConnection initialization. Setting either of these to 0 or negative makes no practical sense — poll() would return nothing and TCP connect would time out immediately.

Brief change log

  • Added validateClientConfigs() in FlussConfigUtils covering client.scanner.log.max-poll-records (must be > 0) and client.connect-timeout (must be > 0)
  • Called validateClientConfigs() in FlussConnection constructor
  • Added unit tests in FlussConfigUtilsTest

Tests

Existing FlussConfigUtilsTest extended with testValidateClientConfigs() covering default validity and each invalid case.

API and Format

NO

Documentation

NO

@Prajwal-banakar
Copy link
Copy Markdown
Contributor Author

cc @fresh-borzoni @LiebingYu

Copy link
Copy Markdown
Contributor

@fresh-borzoni fresh-borzoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Prajwal-banakar Ty for the PR, left some comments, PTAL


public static void validateClientConfigs(Configuration conf) {
int maxPollRecords = conf.getInt(ConfigOptions.CLIENT_SCANNER_LOG_MAX_POLL_RECORDS);
if (maxPollRecords <= 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we use validMinValue?

}

long connectTimeoutMs = conf.get(ConfigOptions.CLIENT_CONNECT_TIMEOUT).toMillis();
if (connectTimeoutMs <= 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Configuration.fromMap(
extractPrefix(new HashMap<>(conf.toMap()), CLIENT_PREFIX + "fs.")),
null);
FlussConfigUtils.validateClientConfigs(conf);
Copy link
Copy Markdown
Contributor

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, before FileSystem.initialize(...) and setupClientMetricsConfiguration()?

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.


// connect-timeout = 0 should fail
Configuration zeroTimeoutConf = new Configuration();
zeroTimeoutConf.set(ConfigOptions.CLIENT_CONNECT_TIMEOUT, java.time.Duration.ZERO);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why fully qualified name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[client] Add validation for client.scanner.log.max-poll-records and client.connect-timeout config options

2 participants