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.
This commit is contained in:
parent
943a016bb2
commit
3d64605075
|
@ -84,7 +84,7 @@ public class URLRepository extends BlobStoreRepository {
|
|||
*/
|
||||
public URLRepository(RepositoryMetaData metadata, Environment environment,
|
||||
NamedXContentRegistry namedXContentRegistry, ThreadPool threadPool) {
|
||||
super(metadata, environment.settings(), false, namedXContentRegistry, threadPool);
|
||||
super(metadata, false, namedXContentRegistry, threadPool);
|
||||
|
||||
if (URL_SETTING.exists(metadata.settings()) == false && REPOSITORIES_URL_SETTING.exists(environment.settings()) == false) {
|
||||
throw new RepositoryException(metadata.name(), "missing url");
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.common.settings.Setting;
|
|||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
||||
|
@ -78,9 +77,12 @@ public class AzureRepository extends BlobStoreRepository {
|
|||
private final AzureStorageService storageService;
|
||||
private final boolean readonly;
|
||||
|
||||
public AzureRepository(RepositoryMetaData metadata, Environment environment, NamedXContentRegistry namedXContentRegistry,
|
||||
AzureStorageService storageService, ThreadPool threadPool) {
|
||||
super(metadata, environment.settings(), Repository.COMPRESS_SETTING.get(metadata.settings()), namedXContentRegistry, threadPool);
|
||||
public AzureRepository(
|
||||
final RepositoryMetaData metadata,
|
||||
final NamedXContentRegistry namedXContentRegistry,
|
||||
final AzureStorageService storageService,
|
||||
final ThreadPool threadPool) {
|
||||
super(metadata, Repository.COMPRESS_SETTING.get(metadata.settings()), namedXContentRegistry, threadPool);
|
||||
this.chunkSize = Repository.CHUNK_SIZE_SETTING.get(metadata.settings());
|
||||
this.storageService = storageService;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class AzureRepositoryPlugin extends Plugin implements RepositoryPlugin, R
|
|||
public Map<String, Repository.Factory> getRepositories(Environment env, NamedXContentRegistry namedXContentRegistry,
|
||||
ThreadPool threadPool) {
|
||||
return Collections.singletonMap(AzureRepository.TYPE,
|
||||
(metadata) -> new AzureRepository(metadata, env, namedXContentRegistry, azureStoreService, threadPool));
|
||||
(metadata) -> new AzureRepository(metadata, namedXContentRegistry, azureStoreService, threadPool));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
|
|||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.env.TestEnvironment;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
||||
|
@ -43,7 +42,7 @@ public class AzureRepositorySettingsTests extends ESTestCase {
|
|||
.put(settings)
|
||||
.build();
|
||||
final AzureRepository azureRepository = new AzureRepository(new RepositoryMetaData("foo", "azure", internalSettings),
|
||||
TestEnvironment.newEnvironment(internalSettings), NamedXContentRegistry.EMPTY, mock(AzureStorageService.class),
|
||||
NamedXContentRegistry.EMPTY, mock(AzureStorageService.class),
|
||||
mock(ThreadPool.class));
|
||||
assertThat(azureRepository.getBlobStore(), is(nullValue()));
|
||||
return azureRepository;
|
||||
|
|
|
@ -54,7 +54,7 @@ public class GoogleCloudStoragePlugin extends Plugin implements RepositoryPlugin
|
|||
public Map<String, Repository.Factory> getRepositories(Environment env, NamedXContentRegistry namedXContentRegistry,
|
||||
ThreadPool threadPool) {
|
||||
return Collections.singletonMap(GoogleCloudStorageRepository.TYPE,
|
||||
metadata -> new GoogleCloudStorageRepository(metadata, env, namedXContentRegistry, this.storageService, threadPool));
|
||||
metadata -> new GoogleCloudStorageRepository(metadata, namedXContentRegistry, this.storageService, threadPool));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Setting;
|
|||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.repositories.RepositoryException;
|
||||
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -65,10 +64,12 @@ class GoogleCloudStorageRepository extends BlobStoreRepository {
|
|||
private final String bucket;
|
||||
private final String clientName;
|
||||
|
||||
GoogleCloudStorageRepository(RepositoryMetaData metadata, Environment environment,
|
||||
NamedXContentRegistry namedXContentRegistry,
|
||||
GoogleCloudStorageService storageService, ThreadPool threadPool) {
|
||||
super(metadata, environment.settings(), getSetting(COMPRESS, metadata), namedXContentRegistry, threadPool);
|
||||
GoogleCloudStorageRepository(
|
||||
final RepositoryMetaData metadata,
|
||||
final NamedXContentRegistry namedXContentRegistry,
|
||||
final GoogleCloudStorageService storageService,
|
||||
final ThreadPool threadPool) {
|
||||
super(metadata, getSetting(COMPRESS, metadata), namedXContentRegistry, threadPool);
|
||||
this.storageService = storageService;
|
||||
|
||||
String basePath = BASE_PATH.get(metadata.settings());
|
||||
|
|
|
@ -67,9 +67,12 @@ public final class HdfsRepository extends BlobStoreRepository {
|
|||
// TODO: why 100KB?
|
||||
private static final ByteSizeValue DEFAULT_BUFFER_SIZE = new ByteSizeValue(100, ByteSizeUnit.KB);
|
||||
|
||||
public HdfsRepository(RepositoryMetaData metadata, Environment environment,
|
||||
NamedXContentRegistry namedXContentRegistry, ThreadPool threadPool) {
|
||||
super(metadata, environment.settings(), metadata.settings().getAsBoolean("compress", false), namedXContentRegistry, threadPool);
|
||||
public HdfsRepository(
|
||||
final RepositoryMetaData metadata,
|
||||
final Environment environment,
|
||||
final NamedXContentRegistry namedXContentRegistry,
|
||||
final ThreadPool threadPool) {
|
||||
super(metadata, metadata.settings().getAsBoolean("compress", false), namedXContentRegistry, threadPool);
|
||||
|
||||
this.environment = environment;
|
||||
this.chunkSize = metadata.settings().getAsBytesSize("chunk_size", null);
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.logging.DeprecationLogger;
|
|||
import org.elasticsearch.common.settings.SecureSetting;
|
||||
import org.elasticsearch.common.settings.SecureString;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
|
@ -169,11 +168,12 @@ class S3Repository extends BlobStoreRepository {
|
|||
/**
|
||||
* Constructs an s3 backed repository
|
||||
*/
|
||||
S3Repository(final RepositoryMetaData metadata,
|
||||
final Settings settings,
|
||||
final NamedXContentRegistry namedXContentRegistry,
|
||||
final S3Service service, final ThreadPool threadPool) {
|
||||
super(metadata, settings, COMPRESS_SETTING.get(metadata.settings()), namedXContentRegistry, threadPool);
|
||||
S3Repository(
|
||||
final RepositoryMetaData metadata,
|
||||
final NamedXContentRegistry namedXContentRegistry,
|
||||
final S3Service service,
|
||||
final ThreadPool threadPool) {
|
||||
super(metadata, COMPRESS_SETTING.get(metadata.settings()), namedXContentRegistry, threadPool);
|
||||
this.service = service;
|
||||
|
||||
this.repositoryMetaData = metadata;
|
||||
|
|
|
@ -76,17 +76,17 @@ public class S3RepositoryPlugin extends Plugin implements RepositoryPlugin, Relo
|
|||
}
|
||||
|
||||
// proxy method for testing
|
||||
protected S3Repository createRepository(final RepositoryMetaData metadata,
|
||||
final Settings settings,
|
||||
final NamedXContentRegistry registry, final ThreadPool threadPool) {
|
||||
return new S3Repository(metadata, settings, registry, service, threadPool);
|
||||
protected S3Repository createRepository(
|
||||
final RepositoryMetaData metadata,
|
||||
final NamedXContentRegistry registry,
|
||||
final ThreadPool threadPool) {
|
||||
return new S3Repository(metadata, registry, service, threadPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Repository.Factory> getRepositories(final Environment env, final NamedXContentRegistry registry,
|
||||
final ThreadPool threadPool) {
|
||||
return Collections.singletonMap(S3Repository.TYPE,
|
||||
metadata -> createRepository(metadata, env.settings(), registry, threadPool));
|
||||
return Collections.singletonMap(S3Repository.TYPE, metadata -> createRepository(metadata, registry, threadPool));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -270,9 +270,9 @@ public class RepositoryCredentialsTests extends ESSingleNodeTestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected S3Repository createRepository(RepositoryMetaData metadata, Settings settings,
|
||||
protected S3Repository createRepository(RepositoryMetaData metadata,
|
||||
NamedXContentRegistry registry, ThreadPool threadPool) {
|
||||
return new S3Repository(metadata, settings, registry, service, threadPool) {
|
||||
return new S3Repository(metadata, registry, service, threadPool) {
|
||||
@Override
|
||||
protected void assertSnapshotOrGenericThread() {
|
||||
// eliminate thread name check as we create repo manually on test/main threads
|
||||
|
|
|
@ -103,7 +103,7 @@ public class S3BlobStoreRepositoryTests extends ESBlobStoreRepositoryIntegTestCa
|
|||
public Map<String, Repository.Factory> getRepositories(final Environment env, final NamedXContentRegistry registry,
|
||||
final ThreadPool threadPool) {
|
||||
return Collections.singletonMap(S3Repository.TYPE,
|
||||
metadata -> new S3Repository(metadata, env.settings(), registry, new S3Service() {
|
||||
metadata -> new S3Repository(metadata, registry, new S3Service() {
|
||||
@Override
|
||||
AmazonS3 buildClient(S3ClientSettings clientSettings) {
|
||||
return new MockAmazonS3(blobs, bucket, serverSideEncryption, cannedACL, storageClass);
|
||||
|
|
|
@ -120,7 +120,7 @@ public class S3RepositoryTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private S3Repository createS3Repo(RepositoryMetaData metadata) {
|
||||
return new S3Repository(metadata, Settings.EMPTY, NamedXContentRegistry.EMPTY, new DummyS3Service(), mock(ThreadPool.class)) {
|
||||
return new S3Repository(metadata, NamedXContentRegistry.EMPTY, new DummyS3Service(), mock(ThreadPool.class)) {
|
||||
@Override
|
||||
protected void assertSnapshotOrGenericThread() {
|
||||
// eliminate thread name check as we create repo manually on test/main threads
|
||||
|
|
|
@ -196,8 +196,6 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
|
||||
private static final String DATA_BLOB_PREFIX = "__";
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
private final boolean compress;
|
||||
|
||||
private final RateLimiter snapshotRateLimiter;
|
||||
|
@ -229,12 +227,13 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
/**
|
||||
* Constructs new BlobStoreRepository
|
||||
* @param metadata The metadata for this repository including name and settings
|
||||
* @param settings Settings for the node this repository object is created on
|
||||
* @param threadPool Threadpool to run long running repository manipulations on asynchronously
|
||||
*/
|
||||
protected BlobStoreRepository(RepositoryMetaData metadata, Settings settings, boolean compress,
|
||||
NamedXContentRegistry namedXContentRegistry, ThreadPool threadPool) {
|
||||
this.settings = settings;
|
||||
protected BlobStoreRepository(
|
||||
final RepositoryMetaData metadata,
|
||||
final boolean compress,
|
||||
final NamedXContentRegistry namedXContentRegistry,
|
||||
final ThreadPool threadPool) {
|
||||
this.compress = compress;
|
||||
this.metadata = metadata;
|
||||
this.namedXContentRegistry = namedXContentRegistry;
|
||||
|
@ -704,8 +703,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
* @return rate limiter or null of no throttling is needed
|
||||
*/
|
||||
private RateLimiter getRateLimiter(Settings repositorySettings, String setting, ByteSizeValue defaultRate) {
|
||||
ByteSizeValue maxSnapshotBytesPerSec = repositorySettings.getAsBytesSize(setting,
|
||||
settings.getAsBytesSize(setting, defaultRate));
|
||||
ByteSizeValue maxSnapshotBytesPerSec = repositorySettings.getAsBytesSize(setting, defaultRate);
|
||||
if (maxSnapshotBytesPerSec.getBytes() <= 0) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class FsRepository extends BlobStoreRepository {
|
|||
*/
|
||||
public FsRepository(RepositoryMetaData metadata, Environment environment, NamedXContentRegistry namedXContentRegistry,
|
||||
ThreadPool threadPool) {
|
||||
super(metadata, environment.settings(), calculateCompress(metadata, environment), namedXContentRegistry, threadPool);
|
||||
super(metadata, calculateCompress(metadata, environment), namedXContentRegistry, threadPool);
|
||||
this.environment = environment;
|
||||
String location = REPOSITORIES_LOCATION_SETTING.get(metadata.settings());
|
||||
if (location.isEmpty()) {
|
||||
|
|
|
@ -1064,7 +1064,7 @@ public class SnapshotResiliencyTests extends ESTestCase {
|
|||
} else {
|
||||
return metaData -> {
|
||||
final Repository repository = new MockEventuallyConsistentRepository(
|
||||
metaData, environment, xContentRegistry(), deterministicTaskQueue.getThreadPool(), blobStoreContext);
|
||||
metaData, xContentRegistry(), deterministicTaskQueue.getThreadPool(), blobStoreContext);
|
||||
repository.start();
|
||||
return repository;
|
||||
};
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
|||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
|
||||
import org.elasticsearch.snapshots.SnapshotInfo;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -68,9 +67,12 @@ public class MockEventuallyConsistentRepository extends BlobStoreRepository {
|
|||
|
||||
private final NamedXContentRegistry namedXContentRegistry;
|
||||
|
||||
public MockEventuallyConsistentRepository(RepositoryMetaData metadata, Environment environment,
|
||||
NamedXContentRegistry namedXContentRegistry, ThreadPool threadPool, Context context) {
|
||||
super(metadata, environment.settings(), false, namedXContentRegistry, threadPool);
|
||||
public MockEventuallyConsistentRepository(
|
||||
RepositoryMetaData metadata,
|
||||
NamedXContentRegistry namedXContentRegistry,
|
||||
ThreadPool threadPool,
|
||||
Context context) {
|
||||
super(metadata,false, namedXContentRegistry, threadPool);
|
||||
this.context = context;
|
||||
this.namedXContentRegistry = namedXContentRegistry;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MockEventuallyConsistentRepositoryTests extends ESTestCase {
|
|||
public void testReadAfterWriteConsistently() throws IOException {
|
||||
MockEventuallyConsistentRepository.Context blobStoreContext = new MockEventuallyConsistentRepository.Context();
|
||||
try (BlobStoreRepository repository = new MockEventuallyConsistentRepository(
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY), environment,
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY),
|
||||
xContentRegistry(), mock(ThreadPool.class), blobStoreContext)) {
|
||||
repository.start();
|
||||
final BlobContainer blobContainer = repository.blobStore().blobContainer(repository.basePath());
|
||||
|
@ -82,7 +82,7 @@ public class MockEventuallyConsistentRepositoryTests extends ESTestCase {
|
|||
public void testReadAfterWriteAfterReadThrows() throws IOException {
|
||||
MockEventuallyConsistentRepository.Context blobStoreContext = new MockEventuallyConsistentRepository.Context();
|
||||
try (BlobStoreRepository repository = new MockEventuallyConsistentRepository(
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY), environment,
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY),
|
||||
xContentRegistry(), mock(ThreadPool.class), blobStoreContext)) {
|
||||
repository.start();
|
||||
final BlobContainer blobContainer = repository.blobStore().blobContainer(repository.basePath());
|
||||
|
@ -98,7 +98,7 @@ public class MockEventuallyConsistentRepositoryTests extends ESTestCase {
|
|||
public void testReadAfterDeleteAfterWriteThrows() throws IOException {
|
||||
MockEventuallyConsistentRepository.Context blobStoreContext = new MockEventuallyConsistentRepository.Context();
|
||||
try (BlobStoreRepository repository = new MockEventuallyConsistentRepository(
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY), environment,
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY),
|
||||
xContentRegistry(), mock(ThreadPool.class), blobStoreContext)) {
|
||||
repository.start();
|
||||
final BlobContainer blobContainer = repository.blobStore().blobContainer(repository.basePath());
|
||||
|
@ -116,7 +116,7 @@ public class MockEventuallyConsistentRepositoryTests extends ESTestCase {
|
|||
public void testOverwriteRandomBlobFails() throws IOException {
|
||||
MockEventuallyConsistentRepository.Context blobStoreContext = new MockEventuallyConsistentRepository.Context();
|
||||
try (BlobStoreRepository repository = new MockEventuallyConsistentRepository(
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY), environment,
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY),
|
||||
xContentRegistry(), mock(ThreadPool.class), blobStoreContext)) {
|
||||
repository.start();
|
||||
final BlobContainer container = repository.blobStore().blobContainer(repository.basePath());
|
||||
|
@ -133,7 +133,7 @@ public class MockEventuallyConsistentRepositoryTests extends ESTestCase {
|
|||
public void testOverwriteShardSnapBlobFails() throws IOException {
|
||||
MockEventuallyConsistentRepository.Context blobStoreContext = new MockEventuallyConsistentRepository.Context();
|
||||
try (BlobStoreRepository repository = new MockEventuallyConsistentRepository(
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY), environment,
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY),
|
||||
xContentRegistry(), mock(ThreadPool.class), blobStoreContext)) {
|
||||
repository.start();
|
||||
final BlobContainer container =
|
||||
|
@ -151,7 +151,7 @@ public class MockEventuallyConsistentRepositoryTests extends ESTestCase {
|
|||
public void testOverwriteSnapshotInfoBlob() {
|
||||
MockEventuallyConsistentRepository.Context blobStoreContext = new MockEventuallyConsistentRepository.Context();
|
||||
try (BlobStoreRepository repository = new MockEventuallyConsistentRepository(
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY), environment,
|
||||
new RepositoryMetaData("testRepo", "mockEventuallyConsistent", Settings.EMPTY),
|
||||
xContentRegistry(), mock(ThreadPool.class), blobStoreContext)) {
|
||||
repository.start();
|
||||
|
||||
|
|
Loading…
Reference in New Issue