Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.fluss.cluster.ServerNode;
import org.apache.fluss.config.ConfigOptions;
import org.apache.fluss.config.Configuration;
import org.apache.fluss.config.FlussConfigUtils;
import org.apache.fluss.exception.FlussRuntimeException;
import org.apache.fluss.fs.FileSystem;
import org.apache.fluss.metadata.TablePath;
Expand Down Expand Up @@ -76,6 +77,7 @@ public final class FlussConnection implements Connection {
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.

Copy link
Copy Markdown
Contributor Author

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

// for client metrics.
setupClientMetricsConfiguration();
String clientId = conf.getString(ConfigOptions.CLIENT_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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?

Copy link
Copy Markdown
Contributor Author

@Prajwal-banakar Prajwal-banakar Apr 17, 2026

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Up @@ -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);
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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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");
}
}
Loading