Skip to content

Commit 268881e

Browse files
authored
Remove node settings from blob store repositories (#45991)
This commit starts from the simple premise that the use of node settings in blob store repositories is a mistake. Here we see that the node settings are used to get default settings for store and restore throttle rates. Yet, since there are not any node settings registered to this effect, there can never be a default setting to fall back to there, and so we always end up falling back to the default rate. Since this was the only use of node settings in blob store repository, we move them. From this, several places fall out where we were chaining settings through only to get them to the blob store repository, so we clean these up as well. That leaves us with the changeset in this commit.
1 parent 3eae13f commit 268881e

File tree

17 files changed

+53
-51
lines changed

17 files changed

+53
-51
lines changed

modules/repository-url/src/main/java/org/elasticsearch/repositories/url/URLRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class URLRepository extends BlobStoreRepository {
8282
*/
8383
public URLRepository(RepositoryMetaData metadata, Environment environment,
8484
NamedXContentRegistry namedXContentRegistry, ThreadPool threadPool) {
85-
super(metadata, environment.settings(), namedXContentRegistry, threadPool, BlobPath.cleanPath());
85+
super(metadata, namedXContentRegistry, threadPool, BlobPath.cleanPath());
8686

8787
if (URL_SETTING.exists(metadata.settings()) == false && REPOSITORIES_URL_SETTING.exists(environment.settings()) == false) {
8888
throw new RepositoryException(metadata.name(), "missing url");

plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepository.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.elasticsearch.common.settings.Setting.Property;
3232
import org.elasticsearch.common.unit.ByteSizeValue;
3333
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
34-
import org.elasticsearch.env.Environment;
3534
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
3635
import org.elasticsearch.threadpool.ThreadPool;
3736

@@ -76,9 +75,12 @@ public static final class Repository {
7675
private final AzureStorageService storageService;
7776
private final boolean readonly;
7877

79-
public AzureRepository(RepositoryMetaData metadata, Environment environment, NamedXContentRegistry namedXContentRegistry,
80-
AzureStorageService storageService, ThreadPool threadPool) {
81-
super(metadata, environment.settings(), namedXContentRegistry, threadPool, buildBasePath(metadata));
78+
public AzureRepository(
79+
final RepositoryMetaData metadata,
80+
final NamedXContentRegistry namedXContentRegistry,
81+
final AzureStorageService storageService,
82+
final ThreadPool threadPool) {
83+
super(metadata, namedXContentRegistry, threadPool, buildBasePath(metadata));
8284
this.chunkSize = Repository.CHUNK_SIZE_SETTING.get(metadata.settings());
8385
this.storageService = storageService;
8486

plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepositoryPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public AzureRepositoryPlugin(Settings settings) {
5757
public Map<String, Repository.Factory> getRepositories(Environment env, NamedXContentRegistry namedXContentRegistry,
5858
ThreadPool threadPool) {
5959
return Collections.singletonMap(AzureRepository.TYPE,
60-
(metadata) -> new AzureRepository(metadata, env, namedXContentRegistry, azureStoreService, threadPool));
60+
(metadata) -> new AzureRepository(metadata, namedXContentRegistry, azureStoreService, threadPool));
6161
}
6262

6363
@Override

plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureRepositorySettingsTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.elasticsearch.common.unit.ByteSizeValue;
2727
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
2828
import org.elasticsearch.env.Environment;
29-
import org.elasticsearch.env.TestEnvironment;
3029
import org.elasticsearch.test.ESTestCase;
3130
import org.elasticsearch.threadpool.ThreadPool;
3231

@@ -43,7 +42,7 @@ private AzureRepository azureRepository(Settings settings) {
4342
.put(settings)
4443
.build();
4544
final AzureRepository azureRepository = new AzureRepository(new RepositoryMetaData("foo", "azure", internalSettings),
46-
TestEnvironment.newEnvironment(internalSettings), NamedXContentRegistry.EMPTY, mock(AzureStorageService.class),
45+
NamedXContentRegistry.EMPTY, mock(AzureStorageService.class),
4746
mock(ThreadPool.class));
4847
assertThat(azureRepository.getBlobStore(), is(nullValue()));
4948
return azureRepository;

plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStoragePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected GoogleCloudStorageService createStorageService() {
5454
public Map<String, Repository.Factory> getRepositories(Environment env, NamedXContentRegistry namedXContentRegistry,
5555
ThreadPool threadPool) {
5656
return Collections.singletonMap(GoogleCloudStorageRepository.TYPE,
57-
metadata -> new GoogleCloudStorageRepository(metadata, env, namedXContentRegistry, this.storageService, threadPool));
57+
metadata -> new GoogleCloudStorageRepository(metadata, namedXContentRegistry, this.storageService, threadPool));
5858
}
5959

6060
@Override

plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageRepository.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.elasticsearch.common.unit.ByteSizeUnit;
2929
import org.elasticsearch.common.unit.ByteSizeValue;
3030
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
31-
import org.elasticsearch.env.Environment;
3231
import org.elasticsearch.repositories.RepositoryException;
3332
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
3433
import org.elasticsearch.threadpool.ThreadPool;
@@ -61,10 +60,12 @@ class GoogleCloudStorageRepository extends BlobStoreRepository {
6160
private final String bucket;
6261
private final String clientName;
6362

64-
GoogleCloudStorageRepository(RepositoryMetaData metadata, Environment environment,
65-
NamedXContentRegistry namedXContentRegistry,
66-
GoogleCloudStorageService storageService, ThreadPool threadPool) {
67-
super(metadata, environment.settings(), namedXContentRegistry, threadPool, buildBasePath(metadata));
63+
GoogleCloudStorageRepository(
64+
final RepositoryMetaData metadata,
65+
final NamedXContentRegistry namedXContentRegistry,
66+
final GoogleCloudStorageService storageService,
67+
final ThreadPool threadPool) {
68+
super(metadata, namedXContentRegistry, threadPool, buildBasePath(metadata));
6869
this.storageService = storageService;
6970

7071
this.chunkSize = getSetting(CHUNK_SIZE, metadata);

plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public final class HdfsRepository extends BlobStoreRepository {
6868

6969
public HdfsRepository(RepositoryMetaData metadata, Environment environment,
7070
NamedXContentRegistry namedXContentRegistry, ThreadPool threadPool) {
71-
super(metadata, environment.settings(), namedXContentRegistry, threadPool, BlobPath.cleanPath());
71+
super(metadata, namedXContentRegistry, threadPool, BlobPath.cleanPath());
7272

7373
this.environment = environment;
7474
this.chunkSize = metadata.settings().getAsBytesSize("chunk_size", null);

plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.elasticsearch.common.settings.SecureSetting;
3030
import org.elasticsearch.common.settings.SecureString;
3131
import org.elasticsearch.common.settings.Setting;
32-
import org.elasticsearch.common.settings.Settings;
3332
import org.elasticsearch.common.unit.ByteSizeUnit;
3433
import org.elasticsearch.common.unit.ByteSizeValue;
3534
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@@ -159,11 +158,12 @@ class S3Repository extends BlobStoreRepository {
159158
/**
160159
* Constructs an s3 backed repository
161160
*/
162-
S3Repository(final RepositoryMetaData metadata,
163-
final Settings settings,
164-
final NamedXContentRegistry namedXContentRegistry,
165-
final S3Service service, final ThreadPool threadPool) {
166-
super(metadata, settings, namedXContentRegistry, threadPool, buildBasePath(metadata));
161+
S3Repository(
162+
final RepositoryMetaData metadata,
163+
final NamedXContentRegistry namedXContentRegistry,
164+
final S3Service service,
165+
final ThreadPool threadPool) {
166+
super(metadata, namedXContentRegistry, threadPool, buildBasePath(metadata));
167167
this.service = service;
168168

169169
// Parse and validate the user's S3 Storage Class setting

plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3RepositoryPlugin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ public S3RepositoryPlugin(final Settings settings) {
7676
}
7777

7878
// proxy method for testing
79-
protected S3Repository createRepository(final RepositoryMetaData metadata,
80-
final Settings settings,
81-
final NamedXContentRegistry registry, final ThreadPool threadPool) {
82-
return new S3Repository(metadata, settings, registry, service, threadPool);
79+
protected S3Repository createRepository(
80+
final RepositoryMetaData metadata,
81+
final NamedXContentRegistry registry,
82+
final ThreadPool threadPool) {
83+
return new S3Repository(metadata, registry, service, threadPool);
8384
}
8485

8586
@Override
8687
public Map<String, Repository.Factory> getRepositories(final Environment env, final NamedXContentRegistry registry,
8788
final ThreadPool threadPool) {
88-
return Collections.singletonMap(S3Repository.TYPE,
89-
metadata -> createRepository(metadata, env.settings(), registry, threadPool));
89+
return Collections.singletonMap(S3Repository.TYPE, metadata -> createRepository(metadata, registry, threadPool));
9090
}
9191

9292
@Override

plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ public ProxyS3RepositoryPlugin(Settings settings) {
270270
}
271271

272272
@Override
273-
protected S3Repository createRepository(RepositoryMetaData metadata, Settings settings,
273+
protected S3Repository createRepository(RepositoryMetaData metadata,
274274
NamedXContentRegistry registry, ThreadPool threadPool) {
275-
return new S3Repository(metadata, settings, registry, service, threadPool) {
275+
return new S3Repository(metadata, registry, service, threadPool) {
276276
@Override
277277
protected void assertSnapshotOrGenericThread() {
278278
// eliminate thread name check as we create repo manually on test/main threads

0 commit comments

Comments
 (0)