diff --git a/docs/plugins/repository-azure.asciidoc b/docs/plugins/repository-azure.asciidoc index e6d8c682ba7..a6efd674615 100644 --- a/docs/plugins/repository-azure.asciidoc +++ b/docs/plugins/repository-azure.asciidoc @@ -185,22 +185,6 @@ client.admin().cluster().preparePutRepository("my_backup_java1") ).get(); ---- -[[repository-azure-global-settings]] -===== Global repositories settings - -All those repository settings can also be defined globally in `elasticsearch.yml` file using prefix -`repositories.azure.`. For example: - -[source,yaml] ----- -repositories.azure: - container: backup-container - base_path: backups - chunk_size: 32m - compress": true ----- - - [[repository-azure-validation]] ===== Repository validation rules diff --git a/docs/reference/migration/migrate_6_0/plugins.asciidoc b/docs/reference/migration/migrate_6_0/plugins.asciidoc index be650a71bd0..d2032d683b5 100644 --- a/docs/reference/migration/migrate_6_0/plugins.asciidoc +++ b/docs/reference/migration/migrate_6_0/plugins.asciidoc @@ -25,3 +25,11 @@ the region of the configured bucket. * The container an azure repository is configured with will no longer be created automatically. It must exist before the azure repository is created. + +* Global repositories settings you are able to set in elasticsearch config file under `repositories.azure` +name space have been removed. This includes `repositories.azure.account`, `repositories.azure.container`, +`repositories.azure.base_path`, `repositories.azure.location_mode`, `repositories.azure.chunk_size` and +`repositories.azure.compress`. +You must set those settings per repository instead. Respectively `account`, `container`, `base_path`, +`location_mode`, `chunk_size` and `compress`. +See {plugins}/repository-azure-usage.html#repository-azure-repository-settings[Azure Repository settings]. diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java index 73b0f07835c..0f32180860c 100644 --- a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java +++ b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java @@ -39,7 +39,6 @@ import java.net.URISyntaxException; import java.util.Locale; import java.util.Map; -import static org.elasticsearch.cloud.azure.storage.AzureStorageSettings.getValue; import static org.elasticsearch.repositories.azure.AzureRepository.Repository; public class AzureBlobStore extends AbstractComponent implements BlobStore { @@ -55,11 +54,11 @@ public class AzureBlobStore extends AbstractComponent implements BlobStore { AzureStorageService client) throws URISyntaxException, StorageException { super(settings); this.client = client; - this.container = getValue(metadata.settings(), settings, Repository.CONTAINER_SETTING, Storage.CONTAINER_SETTING); + this.container = Repository.CONTAINER_SETTING.get(metadata.settings()); this.repositoryName = metadata.name(); - this.accountName = getValue(metadata.settings(), settings, Repository.ACCOUNT_SETTING, Storage.ACCOUNT_SETTING); + this.accountName = Repository.ACCOUNT_SETTING.get(metadata.settings()); - String modeStr = getValue(metadata.settings(), settings, Repository.LOCATION_MODE_SETTING, Storage.LOCATION_MODE_SETTING); + String modeStr = Repository.LOCATION_MODE_SETTING.get(metadata.settings()); if (Strings.hasLength(modeStr)) { this.locMode = LocationMode.valueOf(modeStr.toUpperCase(Locale.ROOT)); } else { diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java index 6343541aed3..5b6575a4d14 100644 --- a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java +++ b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java @@ -21,7 +21,6 @@ package org.elasticsearch.cloud.azure.storage; import com.microsoft.azure.storage.LocationMode; import com.microsoft.azure.storage.StorageException; - import org.elasticsearch.common.blobstore.BlobMetaData; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -35,7 +34,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URISyntaxException; import java.util.Map; -import java.util.function.Function; /** * Azure Storage Service interface @@ -53,18 +51,6 @@ public interface AzureStorageService { public static final Setting TIMEOUT_SETTING = Setting.timeSetting("cloud.azure.storage.timeout", TimeValue.timeValueMinutes(-1), Property.NodeScope); - public static final Setting ACCOUNT_SETTING = - Setting.simpleString("repositories.azure.account", Property.NodeScope, Property.Filtered); - public static final Setting CONTAINER_SETTING = - new Setting<>("repositories.azure.container", "elasticsearch-snapshots", Function.identity(), Property.NodeScope); - public static final Setting BASE_PATH_SETTING = - Setting.simpleString("repositories.azure.base_path", Property.NodeScope); - public static final Setting LOCATION_MODE_SETTING = - Setting.simpleString("repositories.azure.location_mode", Property.NodeScope); - public static final Setting CHUNK_SIZE_SETTING = - Setting.byteSizeSetting("repositories.azure.chunk_size", MAX_CHUNK_SIZE, MIN_CHUNK_SIZE, MAX_CHUNK_SIZE, Property.NodeScope); - public static final Setting COMPRESS_SETTING = - Setting.boolSetting("repositories.azure.compress", false, Property.NodeScope); } boolean doesContainerExist(String account, LocationMode mode, String container); diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java index 5e0de46f65a..705e035895b 100644 --- a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java +++ b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java @@ -25,14 +25,12 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsException; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.node.Node; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.function.Function; public final class AzureStorageSettings { private static final Setting TIMEOUT_SETTING = Setting.affixKeySetting(Storage.PREFIX, "timeout", @@ -161,25 +159,4 @@ public final class AzureStorageSettings { } return Collections.unmodifiableMap(secondaries); } - - public static T getValue(Settings repositorySettings, - Settings globalSettings, - Setting repositorySetting, - Setting repositoriesSetting) { - if (repositorySetting.exists(repositorySettings)) { - return repositorySetting.get(repositorySettings); - } else { - return repositoriesSetting.get(globalSettings); - } - } - - public static Setting getEffectiveSetting(Settings repositorySettings, - Setting repositorySetting, - Setting repositoriesSetting) { - if (repositorySetting.exists(repositorySettings)) { - return repositorySetting; - } else { - return repositoriesSetting; - } - } } diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/plugin/repository/azure/AzureRepositoryPlugin.java b/plugins/repository-azure/src/main/java/org/elasticsearch/plugin/repository/azure/AzureRepositoryPlugin.java index f8953833074..bfed1fc254d 100644 --- a/plugins/repository-azure/src/main/java/org/elasticsearch/plugin/repository/azure/AzureRepositoryPlugin.java +++ b/plugins/repository-azure/src/main/java/org/elasticsearch/plugin/repository/azure/AzureRepositoryPlugin.java @@ -53,13 +53,7 @@ public class AzureRepositoryPlugin extends Plugin implements RepositoryPlugin { @Override public List> getSettings() { - return Arrays.asList(AzureStorageService.Storage.STORAGE_ACCOUNTS, - AzureStorageService.Storage.ACCOUNT_SETTING, - AzureStorageService.Storage.COMPRESS_SETTING, - AzureStorageService.Storage.CONTAINER_SETTING, - AzureStorageService.Storage.BASE_PATH_SETTING, - AzureStorageService.Storage.CHUNK_SIZE_SETTING, - AzureStorageService.Storage.LOCATION_MODE_SETTING); + return Collections.singletonList(AzureStorageService.Storage.STORAGE_ACCOUNTS); } @Override diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepository.java b/plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepository.java index 50d087e713d..2b99e6a6f8e 100644 --- a/plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepository.java +++ b/plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepository.java @@ -23,7 +23,6 @@ import com.microsoft.azure.storage.LocationMode; import com.microsoft.azure.storage.StorageException; import org.elasticsearch.cloud.azure.blobstore.AzureBlobStore; import org.elasticsearch.cloud.azure.storage.AzureStorageService; -import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.RepositoryMetaData; import org.elasticsearch.common.Strings; @@ -46,7 +45,6 @@ import java.util.function.Function; import static org.elasticsearch.cloud.azure.storage.AzureStorageService.MAX_CHUNK_SIZE; import static org.elasticsearch.cloud.azure.storage.AzureStorageService.MIN_CHUNK_SIZE; -import static org.elasticsearch.cloud.azure.storage.AzureStorageSettings.getValue; /** * Azure file system implementation of the BlobStoreRepository @@ -86,10 +84,10 @@ public class AzureRepository extends BlobStoreRepository { super(metadata, environment.settings(), namedXContentRegistry); blobStore = new AzureBlobStore(metadata, environment.settings(), storageService); - String container = getValue(metadata.settings(), settings, Repository.CONTAINER_SETTING, Storage.CONTAINER_SETTING); - this.chunkSize = getValue(metadata.settings(), settings, Repository.CHUNK_SIZE_SETTING, Storage.CHUNK_SIZE_SETTING); - this.compress = getValue(metadata.settings(), settings, Repository.COMPRESS_SETTING, Storage.COMPRESS_SETTING); - String modeStr = getValue(metadata.settings(), settings, Repository.LOCATION_MODE_SETTING, Storage.LOCATION_MODE_SETTING); + String container = Repository.CONTAINER_SETTING.get(metadata.settings()); + this.chunkSize = Repository.CHUNK_SIZE_SETTING.get(metadata.settings()); + this.compress = Repository.COMPRESS_SETTING.get(metadata.settings()); + String modeStr = Repository.LOCATION_MODE_SETTING.get(metadata.settings()); Boolean forcedReadonly = metadata.settings().getAsBoolean("readonly", null); // If the user explicitly did not define a readonly value, we set it by ourselves depending on the location mode setting. // For secondary_only setting, the repository should be read only @@ -104,7 +102,7 @@ public class AzureRepository extends BlobStoreRepository { readonly = forcedReadonly; } - String basePath = getValue(metadata.settings(), settings, Repository.BASE_PATH_SETTING, Storage.BASE_PATH_SETTING); + String basePath = Repository.BASE_PATH_SETTING.get(metadata.settings()); if (Strings.hasLength(basePath)) { // Remove starting / if any