Skip to content
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

Adding configurable connection count setting for S3 Sync Client #12028

Merged
merged 3 commits into from
Jan 29, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- GHA to verify checklist items completion in PR descriptions ([#10800](https://github.com/opensearch-project/OpenSearch/pull/10800))
- Allow to pass the list settings through environment variables (like [], ["a", "b", "c"], ...) ([#10625](https://github.com/opensearch-project/OpenSearch/pull/10625))
- [Admission Control] Integrate CPU AC with ResourceUsageCollector and add CPU AC stats to nodes/stats ([#10887](https://github.com/opensearch-project/OpenSearch/pull/10887))
- [S3 Repository] Add setting to control connection count for sync client
gbbafna marked this conversation as resolved.
Show resolved Hide resolved

### Dependencies
- Bump `log4j-core` from 2.18.0 to 2.19.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ final class S3ClientSettings {
key -> Setting.intSetting(key, 500, Property.NodeScope)
);

static final Setting.AffixSetting<Integer> MAX_SYNC_CONNECTIONS_SETTING = Setting.affixKeySetting(
gbbafna marked this conversation as resolved.
Show resolved Hide resolved
PREFIX,
"max_sync_connections",
key -> Setting.intSetting(key, 100, Property.NodeScope)
);

/** Connection acquisition timeout for new connections to S3. */
static final Setting.AffixSetting<TimeValue> CONNECTION_ACQUISITION_TIMEOUT = Setting.affixKeySetting(
PREFIX,
Expand Down Expand Up @@ -284,9 +290,12 @@ final class S3ClientSettings {
/** The connection TTL for the s3 client */
final int connectionTTLMillis;

/** The max number of connections for the s3 client */
/** The max number of connections for the s3 async client */
final int maxConnections;

/** The max number of connections for the s3 sync client */
final int maxSyncConnections;

/** The connnection acquisition timeout for the s3 async client */
final int connectionAcquisitionTimeoutMillis;

Expand Down Expand Up @@ -318,6 +327,7 @@ private S3ClientSettings(
int connectionTimeoutMillis,
int connectionTTLMillis,
int maxConnections,
int maxSyncConnections,
int connectionAcquisitionTimeoutMillis,
int maxRetries,
boolean throttleRetries,
Expand All @@ -336,6 +346,7 @@ private S3ClientSettings(
this.connectionTimeoutMillis = connectionTimeoutMillis;
this.connectionTTLMillis = connectionTTLMillis;
this.maxConnections = maxConnections;
this.maxSyncConnections = maxSyncConnections;
this.connectionAcquisitionTimeoutMillis = connectionAcquisitionTimeoutMillis;
this.maxRetries = maxRetries;
this.throttleRetries = throttleRetries;
Expand Down Expand Up @@ -386,6 +397,9 @@ S3ClientSettings refine(Settings repositorySettings) {
).millis()
);
final int newMaxConnections = Math.toIntExact(getRepoSettingOrDefault(MAX_CONNECTIONS_SETTING, normalizedSettings, maxConnections));
final int newMaxSyncConnections = Math.toIntExact(
getRepoSettingOrDefault(MAX_SYNC_CONNECTIONS_SETTING, normalizedSettings, maxConnections)
);
final int newMaxRetries = getRepoSettingOrDefault(MAX_RETRIES_SETTING, normalizedSettings, maxRetries);
final boolean newThrottleRetries = getRepoSettingOrDefault(USE_THROTTLE_RETRIES_SETTING, normalizedSettings, throttleRetries);
final boolean newPathStyleAccess = getRepoSettingOrDefault(USE_PATH_STYLE_ACCESS, normalizedSettings, pathStyleAccess);
Expand Down Expand Up @@ -433,6 +447,7 @@ S3ClientSettings refine(Settings repositorySettings) {
newConnectionTimeoutMillis,
newConnectionTTLMillis,
newMaxConnections,
newMaxSyncConnections,
newConnectionAcquisitionTimeoutMillis,
newMaxRetries,
newThrottleRetries,
Expand Down Expand Up @@ -563,6 +578,7 @@ static S3ClientSettings getClientSettings(final Settings settings, final String
Math.toIntExact(getConfigValue(settings, clientName, CONNECTION_TIMEOUT_SETTING).millis()),
Math.toIntExact(getConfigValue(settings, clientName, CONNECTION_TTL_SETTING).millis()),
Math.toIntExact(getConfigValue(settings, clientName, MAX_CONNECTIONS_SETTING)),
Math.toIntExact(getConfigValue(settings, clientName, MAX_SYNC_CONNECTIONS_SETTING)),
Math.toIntExact(getConfigValue(settings, clientName, CONNECTION_ACQUISITION_TIMEOUT).millis()),
getConfigValue(settings, clientName, MAX_RETRIES_SETTING),
getConfigValue(settings, clientName, USE_THROTTLE_RETRIES_SETTING),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ protected PasswordAuthentication getPasswordAuthentication() {
}

clientBuilder.socketTimeout(Duration.ofMillis(clientSettings.readTimeoutMillis));
clientBuilder.maxConnections(clientSettings.maxSyncConnections);
clientBuilder.connectionAcquisitionTimeout(Duration.ofMillis(clientSettings.connectionAcquisitionTimeoutMillis));
gbbafna marked this conversation as resolved.
Show resolved Hide resolved

return clientBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void testThereIsADefaultClientByDefault() {
assertThat(defaultSettings.connectionTimeoutMillis, is(10 * 1000));
assertThat(defaultSettings.connectionTTLMillis, is(5 * 1000));
assertThat(defaultSettings.maxConnections, is(500));
assertThat(defaultSettings.maxSyncConnections, is(100));
gbbafna marked this conversation as resolved.
Show resolved Hide resolved
assertThat(defaultSettings.maxRetries, is(3));
assertThat(defaultSettings.throttleRetries, is(true));
}
Expand Down
Loading