Skip to content

Commit 5fc8f5a

Browse files
committed
tweaks
1 parent 057ad43 commit 5fc8f5a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ public class S3PerProjectClientManager implements ClusterStateListener {
4545
private final Settings nodeS3Settings;
4646
private final Function<S3ClientSettings, AmazonS3Reference> clientBuilder;
4747
private final Executor executor;
48-
// A map of projectId to clients holder. Adding to and removing from the map happen only in the cluster state listener thread.
48+
// A map of projectId to clients holder. Adding to and removing from the map happen only in the applier thread.
4949
private final Map<ProjectId, ClientsHolder> projectClientsHolders;
50-
// Listener for tracking ongoing async closing of obsolete clients. Updated only in the cluster state listener thread.
50+
// Listener for tracking ongoing async closing of obsolete clients. Updated only in the applier thread.
5151
private volatile SubscribableListener<Void> clientsCloseListener = null;
5252

5353
S3PerProjectClientManager(Settings settings, Function<S3ClientSettings, AmazonS3Reference> clientBuilder, Executor executor) {
5454
this.nodeS3Settings = Settings.builder()
55-
.put(settings.getByPrefix(S3_SETTING_PREFIX), false) // not use any cluster scoped secrets
55+
.put(settings.getByPrefix(S3_SETTING_PREFIX), false) // not rely on any cluster scoped secrets
5656
.normalizePrefix(S3_SETTING_PREFIX)
5757
.build();
5858
this.clientBuilder = clientBuilder;
@@ -72,7 +72,7 @@ public void clusterChanged(ClusterChangedEvent event) {
7272
final List<ClientsHolder> clientsHoldersToClose = new ArrayList<>();
7373
for (var project : currentProjects.values()) {
7474
final ProjectSecrets projectSecrets = project.custom(ProjectSecrets.TYPE);
75-
// Project secrets can be null when node restarts. It may not have s3 credentials if s3 is not used.
75+
// Project secrets can be null when node restarts. It may not have any s3 credentials if s3 is not in use.
7676
if (projectSecrets == null || projectSecrets.getSettingNames().stream().noneMatch(key -> key.startsWith("s3."))) {
7777
// Most likely there won't be any existing client, but attempt to remove it anyway just in case
7878
final ClientsHolder removed = projectClientsHolders.remove(project.id());
@@ -126,7 +126,7 @@ public void clusterChanged(ClusterChangedEvent event) {
126126
clientsHoldersToClose.add(removed);
127127
}
128128
}
129-
// Close stale clients asynchronously without blocking the cluster state thread
129+
// Close stale clients asynchronously without blocking the applier thread
130130
if (clientsHoldersToClose.isEmpty() == false) {
131131
final var currentClientsCloseListener = new SubscribableListener<Void>();
132132
final var previousClientsCloseListener = clientsCloseListener;
@@ -182,7 +182,7 @@ public void close() {
182182
currentClientsCloseListener.addListener(ActionListener.running(latch::countDown));
183183
try {
184184
if (latch.await(1, TimeUnit.MINUTES) == false) {
185-
logger.warn("async closing of s3 clients timed out");
185+
logger.warn("Waiting for async closing of s3 clients timed out");
186186
}
187187
} catch (InterruptedException e) {
188188
Thread.currentThread().interrupt();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ public AmazonS3Reference client(@Nullable ProjectId projectId, RepositoryMetadat
227227
}
228228
}
229229

230+
// visible for tests
230231
protected AmazonS3Reference buildClientReference(final S3ClientSettings clientSettings) {
231232
final SdkHttpClient httpClient = buildHttpClient(clientSettings, getCustomDnsResolver());
232233
Releasable toRelease = httpClient::close;

server/src/main/java/org/elasticsearch/common/settings/ProjectSecrets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public SecureSettings getSettings() {
5757
}
5858

5959
public Set<String> getSettingNames() {
60-
return settings.getSettingNames();
60+
return Collections.unmodifiableSet(settings.getSettingNames());
6161
}
6262

6363
@Override

0 commit comments

Comments
 (0)