|
@@ -79,17 +79,27 @@ public class AzureRepository extends BlobStoreRepository {
|
|
|
public static final Setting<Boolean> READONLY_SETTING = Setting.boolSetting("readonly", false, Property.NodeScope);
|
|
|
}
|
|
|
|
|
|
- private final BlobPath basePath;
|
|
|
private final ByteSizeValue chunkSize;
|
|
|
private final AzureStorageService storageService;
|
|
|
private final boolean readonly;
|
|
|
|
|
|
public AzureRepository(RepositoryMetaData metadata, Environment environment, NamedXContentRegistry namedXContentRegistry,
|
|
|
AzureStorageService storageService, ThreadPool threadPool) {
|
|
|
- super(metadata, environment.settings(), namedXContentRegistry, threadPool);
|
|
|
+ super(metadata, environment.settings(), namedXContentRegistry, threadPool, buildBasePath(metadata));
|
|
|
this.chunkSize = Repository.CHUNK_SIZE_SETTING.get(metadata.settings());
|
|
|
this.storageService = storageService;
|
|
|
|
|
|
+ // 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
|
|
|
+ final LocationMode locationMode = Repository.LOCATION_MODE_SETTING.get(metadata.settings());
|
|
|
+ if (Repository.READONLY_SETTING.exists(metadata.settings())) {
|
|
|
+ this.readonly = Repository.READONLY_SETTING.get(metadata.settings());
|
|
|
+ } else {
|
|
|
+ this.readonly = locationMode == LocationMode.SECONDARY_ONLY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static BlobPath buildBasePath(RepositoryMetaData metadata) {
|
|
|
final String basePath = Strings.trimLeadingCharacter(Repository.BASE_PATH_SETTING.get(metadata.settings()), '/');
|
|
|
if (Strings.hasLength(basePath)) {
|
|
|
// Remove starting / if any
|
|
@@ -97,18 +107,9 @@ public class AzureRepository extends BlobStoreRepository {
|
|
|
for(final String elem : basePath.split("/")) {
|
|
|
path = path.add(elem);
|
|
|
}
|
|
|
- this.basePath = path;
|
|
|
- } else {
|
|
|
- this.basePath = BlobPath.cleanPath();
|
|
|
- }
|
|
|
-
|
|
|
- // 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
|
|
|
- final LocationMode locationMode = Repository.LOCATION_MODE_SETTING.get(metadata.settings());
|
|
|
- if (Repository.READONLY_SETTING.exists(metadata.settings())) {
|
|
|
- this.readonly = Repository.READONLY_SETTING.get(metadata.settings());
|
|
|
+ return path;
|
|
|
} else {
|
|
|
- this.readonly = locationMode == LocationMode.SECONDARY_ONLY;
|
|
|
+ return BlobPath.cleanPath();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -123,15 +124,10 @@ public class AzureRepository extends BlobStoreRepository {
|
|
|
|
|
|
logger.debug(() -> new ParameterizedMessage(
|
|
|
"using container [{}], chunk_size [{}], compress [{}], base_path [{}]",
|
|
|
- blobStore, chunkSize, isCompress(), basePath));
|
|
|
+ blobStore, chunkSize, isCompress(), basePath()));
|
|
|
return blobStore;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected BlobPath basePath() {
|
|
|
- return basePath;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
protected ByteSizeValue chunkSize() {
|
|
|
return chunkSize;
|