Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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);
// 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) {
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) {
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);
assertThatThrownBy(() -> FlussConfigUtils.validateClientConfigs(zeroTimeoutConf))
.isInstanceOf(IllegalConfigurationException.class)
.hasMessageContaining(ConfigOptions.CLIENT_CONNECT_TIMEOUT.key())
.hasMessageContaining("must be greater than 0");
}
}
Loading