Skip to content

Commit c1b8ca0

Browse files
committed
Cosmetic fixes to repository-s3
Relates AWS SDK v2 uprgade, this commit just pulls out some bits that can go in first.
1 parent 0d23976 commit c1b8ca0

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3ClientSettings.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,28 @@ final class S3ClientSettings {
121121
static final Setting.AffixSetting<TimeValue> READ_TIMEOUT_SETTING = Setting.affixKeySetting(
122122
PREFIX,
123123
"read_timeout",
124-
key -> Setting.timeSetting(key, TimeValue.timeValueMillis(ClientConfiguration.DEFAULT_SOCKET_TIMEOUT), Property.NodeScope)
124+
key -> Setting.timeSetting(key, Defaults.READ_TIMEOUT, Property.NodeScope)
125125
);
126126

127127
/** The maximum number of concurrent connections to use. */
128128
static final Setting.AffixSetting<Integer> MAX_CONNECTIONS_SETTING = Setting.affixKeySetting(
129129
PREFIX,
130130
"max_connections",
131-
key -> Setting.intSetting(key, ClientConfiguration.DEFAULT_MAX_CONNECTIONS, 1, Property.NodeScope)
131+
key -> Setting.intSetting(key, Defaults.MAX_CONNECTIONS, 1, Property.NodeScope)
132132
);
133133

134134
/** The number of retries to use when an s3 request fails. */
135135
static final Setting.AffixSetting<Integer> MAX_RETRIES_SETTING = Setting.affixKeySetting(
136136
PREFIX,
137137
"max_retries",
138-
key -> Setting.intSetting(key, ClientConfiguration.DEFAULT_RETRY_POLICY.getMaxErrorRetry(), 0, Property.NodeScope)
138+
key -> Setting.intSetting(key, Defaults.RETRY_COUNT, 0, Property.NodeScope)
139139
);
140140

141141
/** Whether retries should be throttled (ie use backoff). */
142142
static final Setting.AffixSetting<Boolean> USE_THROTTLE_RETRIES_SETTING = Setting.affixKeySetting(
143143
PREFIX,
144144
"use_throttle_retries",
145-
key -> Setting.boolSetting(key, ClientConfiguration.DEFAULT_THROTTLE_RETRIES, Property.NodeScope)
145+
key -> Setting.boolSetting(key, Defaults.THROTTLE_RETRIES, Property.NodeScope)
146146
);
147147

148148
/** Whether the s3 client should use path style access. */
@@ -335,7 +335,7 @@ S3ClientSettings refine(Settings repositorySettings) {
335335

336336
/**
337337
* Load all client settings from the given settings.
338-
*
338+
* <p>
339339
* Note this will always at least return a client named "default".
340340
*/
341341
static Map<String, S3ClientSettings> load(Settings settings) {
@@ -501,4 +501,11 @@ private static <T> T getRepoSettingOrDefault(Setting.AffixSetting<T> setting, Se
501501
}
502502
return defaultValue;
503503
}
504+
505+
static final class Defaults {
506+
static final TimeValue READ_TIMEOUT = TimeValue.timeValueMillis(ClientConfiguration.DEFAULT_SOCKET_TIMEOUT);
507+
static final int MAX_CONNECTIONS = ClientConfiguration.DEFAULT_MAX_CONNECTIONS;
508+
static final int RETRY_COUNT = ClientConfiguration.DEFAULT_RETRY_POLICY.getMaxErrorRetry();
509+
static final boolean THROTTLE_RETRIES = ClientConfiguration.DEFAULT_THROTTLE_RETRIES;
510+
}
504511
}

modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Service.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ class S3Service implements Closeable {
115115

116116
/**
117117
* Refreshes the settings for the AmazonS3 clients and clears the cache of
118-
* existing clients. New clients will be build using these new settings. Old
119-
* clients are usable until released. On release they will be destroyed instead
118+
* existing clients. New clients will be built using these new settings. Old
119+
* clients are usable until released. On release, they will be destroyed instead
120120
* of being returned to the cache.
121121
*/
122122
public synchronized void refreshAndClearCache(Map<String, S3ClientSettings> clientsSettings) {
@@ -126,7 +126,7 @@ public synchronized void refreshAndClearCache(Map<String, S3ClientSettings> clie
126126
this.staticClientSettings = Maps.ofEntries(clientsSettings.entrySet());
127127
derivedClientSettings = emptyMap();
128128
assert this.staticClientSettings.containsKey("default") : "always at least have 'default'";
129-
// clients are built lazily by {@link client}
129+
/* clients are built lazily by {@link #client} */
130130
}
131131

132132
/**
@@ -341,7 +341,8 @@ public void refresh() {
341341
* <ul>
342342
* <li>Reads the location of the web identity token not from AWS_WEB_IDENTITY_TOKEN_FILE, but from a symlink
343343
* in the plugin directory, so we don't need to create a hardcoded read file permission for the plugin.</li>
344-
* <li>Supports customization of the STS endpoint via a system property, so we can test it against a test fixture.</li>
344+
* <li>Supports customization of the STS (Security Token Service) endpoint via a system property, so we can
345+
* test it against a test fixture.</li>
345346
* <li>Supports gracefully shutting down the provider and the STS client.</li>
346347
* </ul>
347348
*/
@@ -384,7 +385,7 @@ static class CustomWebIdentityTokenCredentialsProvider implements AWSCredentials
384385
if (roleArn == null) {
385386
LOGGER.warn(
386387
"Unable to use a web identity token for authentication. The AWS_WEB_IDENTITY_TOKEN_FILE environment "
387-
+ "variable is set, but either AWS_ROLE_ARN is missing"
388+
+ "variable is set, but AWS_ROLE_ARN is missing"
388389
);
389390
return;
390391
}

0 commit comments

Comments
 (0)