Skip to content

Commit cd7b8d4

Browse files
committed
Update settings filter and remove component settings from AbstractComponent
Update settings filter to match #9748 Remove component settings from AbstractComponent as seen in #9919 Closes #71. Closes #72.
1 parent b7c4408 commit cd7b8d4

22 files changed

+300
-288
lines changed

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ How to start (short story)
6464
Azure credential API settings
6565
-----------------------------
6666

67-
The following are a list of settings (prefixed with `cloud.azure.management`) that can further control the discovery:
67+
The following are a list of settings that can further control the credential API:
6868

69-
* `keystore.path`: /path/to/keystore
70-
* `keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`.
71-
* `keystore.password`: your_password for the keystore
72-
* `subscription.id`: your_azure_subscription_id
73-
* `cloud.service.name`: your_azure_cloud_service_name
69+
* `cloud.azure.management.keystore.path`: /path/to/keystore
70+
* `cloud.azure.management.keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`.
71+
* `cloud.azure.management.keystore.password`: your_password for the keystore
72+
* `cloud.azure.management.subscription.id`: your_azure_subscription_id
73+
* `cloud.azure.management.cloud.service.name`: your_azure_cloud_service_name
7474

7575
Note that in previous versions, it was:
7676

@@ -86,16 +86,16 @@ cloud:
8686
Advanced settings
8787
-----------------
8888

89-
The following are a list of settings (prefixed with `discovery.azure`) that can further control the discovery:
89+
The following are a list of settings that can further control the discovery:
9090

91-
* `host.type`: either `public_ip` or `private_ip` (default). Azure discovery will use the one you set to ping
91+
* `discovery.azure.host.type`: either `public_ip` or `private_ip` (default). Azure discovery will use the one you set to ping
9292
other nodes. This feature was not documented before but was existing under `cloud.azure.host_type`.
93-
* `endpoint.name`: when using `public_ip` this setting is used to identify the endpoint name used to forward requests
93+
* `discovery.azure.endpoint.name`: when using `public_ip` this setting is used to identify the endpoint name used to forward requests
9494
to elasticsearch (aka transport port name). Defaults to `elasticsearch`. In Azure management console, you could define
9595
an endpoint `elasticsearch` forwarding for example requests on public IP on port 8100 to the virtual machine on port 9300.
9696
This feature was not documented before but was existing under `cloud.azure.port_name`.
97-
* `deployment.name`: deployment name if any. Defaults to the value set with `cloud.azure.management.cloud.service.name`.
98-
* `deployment.slot`: either `staging` or `production` (default).
97+
* `discovery.azure.deployment.name`: deployment name if any. Defaults to the value set with `cloud.azure.management.cloud.service.name`.
98+
* `discovery.azure.deployment.slot`: either `staging` or `production` (default).
9999

100100
For example:
101101

@@ -476,10 +476,10 @@ Example using Java:
476476

477477
```java
478478
client.admin().cluster().preparePutRepository("my_backup3")
479-
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
480-
.put(AzureStorageService.Fields.CONTAINER, "backup_container")
481-
.put(AzureStorageService.Fields.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
482-
).get();
479+
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
480+
.put(Storage.CONTAINER, "backup_container")
481+
.put(Storage.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
482+
).get();
483483
```
484484

485485
Repository validation rules

src/main/java/org/elasticsearch/cloud/azure/AzureModule.java

+35-40
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020
package org.elasticsearch.cloud.azure;
2121

2222
import org.elasticsearch.ElasticsearchException;
23-
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
24-
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl;
2523
import org.elasticsearch.cloud.azure.management.AzureComputeService;
24+
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
25+
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
2626
import org.elasticsearch.cloud.azure.management.AzureComputeServiceImpl;
27+
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
28+
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
29+
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl;
2730
import org.elasticsearch.common.Strings;
2831
import org.elasticsearch.common.inject.AbstractModule;
2932
import org.elasticsearch.common.inject.Inject;
@@ -63,15 +66,15 @@ protected void configure() {
6366
if (isDiscoveryReady(settings, logger)) {
6467
logger.debug("starting azure discovery service");
6568
bind(AzureComputeService.class)
66-
.to(settings.getAsClass("cloud.azure.api.impl", AzureComputeServiceImpl.class))
69+
.to(settings.getAsClass(Management.API_IMPLEMENTATION, AzureComputeServiceImpl.class))
6770
.asEagerSingleton();
6871
}
6972

7073
// If we have settings for azure repository, let's start the azure storage service
7174
if (isSnapshotReady(settings, logger)) {
7275
logger.debug("starting azure repository service");
7376
bind(AzureStorageService.class)
74-
.to(settings.getAsClass("repositories.azure.api.impl", AzureStorageServiceImpl.class))
77+
.to(settings.getAsClass(Storage.API_IMPLEMENTATION, AzureStorageServiceImpl.class))
7578
.asEagerSingleton();
7679
}
7780
}
@@ -102,22 +105,22 @@ public static boolean isDiscoveryReady(Settings settings, ESLogger logger) {
102105
}
103106

104107
if ( // We check new parameters
105-
(isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID) ||
106-
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME) ||
107-
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH) ||
108-
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD))
108+
(isPropertyMissing(settings, Management.SUBSCRIPTION_ID) ||
109+
isPropertyMissing(settings, Management.SERVICE_NAME) ||
110+
isPropertyMissing(settings, Management.KEYSTORE_PATH) ||
111+
isPropertyMissing(settings, Management.KEYSTORE_PASSWORD))
109112
// We check deprecated
110-
&& (isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED) ||
111-
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED) ||
112-
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED) ||
113-
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED))
113+
&& (isPropertyMissing(settings, Management.SUBSCRIPTION_ID_DEPRECATED) ||
114+
isPropertyMissing(settings, Management.SERVICE_NAME_DEPRECATED) ||
115+
isPropertyMissing(settings, Management.KEYSTORE_DEPRECATED) ||
116+
isPropertyMissing(settings, Management.PASSWORD_DEPRECATED))
114117
) {
115118
logger.debug("one or more azure discovery settings are missing. " +
116-
"Check elasticsearch.yml file and `cloud.azure.management`. Should have [{}], [{}], [{}] and [{}].",
117-
AzureComputeService.Fields.SUBSCRIPTION_ID,
118-
AzureComputeService.Fields.SERVICE_NAME,
119-
AzureComputeService.Fields.KEYSTORE_PATH,
120-
AzureComputeService.Fields.KEYSTORE_PASSWORD);
119+
"Check elasticsearch.yml file. Should have [{}], [{}], [{}] and [{}].",
120+
Management.SUBSCRIPTION_ID,
121+
Management.SERVICE_NAME,
122+
Management.KEYSTORE_PATH,
123+
Management.KEYSTORE_PASSWORD);
121124
return false;
122125
}
123126

@@ -137,13 +140,13 @@ public static boolean isSnapshotReady(Settings settings, ESLogger logger) {
137140
return false;
138141
}
139142

140-
if ((isPropertyMissing(settings, "cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT) ||
141-
isPropertyMissing(settings, "cloud.azure.storage." + AzureStorageService.Fields.KEY)) &&
142-
(isPropertyMissing(settings, "cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED) ||
143-
isPropertyMissing(settings, "cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED))) {
144-
logger.debug("azure repository is not set [using cloud.azure.storage.{}] and [cloud.azure.storage.{}] properties",
145-
AzureStorageService.Fields.ACCOUNT,
146-
AzureStorageService.Fields.KEY);
143+
if ((isPropertyMissing(settings, Storage.ACCOUNT) ||
144+
isPropertyMissing(settings, Storage.KEY)) &&
145+
(isPropertyMissing(settings, Storage.ACCOUNT_DEPRECATED) ||
146+
isPropertyMissing(settings, Storage.KEY_DEPRECATED))) {
147+
logger.debug("azure repository is not set using [{}] and [{}] properties",
148+
Storage.ACCOUNT,
149+
Storage.KEY);
147150
return false;
148151
}
149152

@@ -171,24 +174,16 @@ public static void checkDeprecatedSettings(Settings settings, String oldParamete
171174
public static void checkDeprecated(Settings settings, ESLogger logger) {
172175
// Cloud services are disabled
173176
if (isCloudReady(settings)) {
174-
checkDeprecatedSettings(settings, "cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED,
175-
"cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT, logger);
176-
checkDeprecatedSettings(settings, "cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED,
177-
"cloud.azure.storage." + AzureStorageService.Fields.KEY, logger);
177+
checkDeprecatedSettings(settings, Storage.ACCOUNT_DEPRECATED, Storage.ACCOUNT, logger);
178+
checkDeprecatedSettings(settings, Storage.KEY_DEPRECATED, Storage.KEY, logger);
178179

179180
// TODO Remove in 3.0.0
180-
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED,
181-
"cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH, logger);
182-
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED,
183-
"cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD, logger);
184-
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED,
185-
"cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME, logger);
186-
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED,
187-
"cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID, logger);
188-
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.HOST_TYPE_DEPRECATED,
189-
"discovery.azure." + AzureComputeService.Fields.HOST_TYPE, logger);
190-
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.PORT_NAME_DEPRECATED,
191-
"discovery.azure." + AzureComputeService.Fields.ENDPOINT_NAME, logger);
181+
checkDeprecatedSettings(settings, Management.KEYSTORE_DEPRECATED, Management.KEYSTORE_PATH, logger);
182+
checkDeprecatedSettings(settings, Management.PASSWORD_DEPRECATED, Management.KEYSTORE_PASSWORD, logger);
183+
checkDeprecatedSettings(settings, Management.SERVICE_NAME_DEPRECATED, Management.SERVICE_NAME, logger);
184+
checkDeprecatedSettings(settings, Management.SUBSCRIPTION_ID_DEPRECATED, Management.SUBSCRIPTION_ID, logger);
185+
checkDeprecatedSettings(settings, Discovery.HOST_TYPE_DEPRECATED, Discovery.HOST_TYPE, logger);
186+
checkDeprecatedSettings(settings, Discovery.PORT_NAME_DEPRECATED, Discovery.ENDPOINT_NAME, logger);
192187
}
193188
}
194189

src/main/java/org/elasticsearch/cloud/azure/AzureSettingsFilter.java

-60
This file was deleted.

src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
import org.elasticsearch.common.settings.Settings;
3030
import org.elasticsearch.repositories.RepositoryName;
3131
import org.elasticsearch.repositories.RepositorySettings;
32-
import org.elasticsearch.repositories.azure.AzureRepository;
3332

3433
import java.net.URISyntaxException;
3534

35+
import static org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage.CONTAINER;
36+
import static org.elasticsearch.repositories.azure.AzureRepository.CONTAINER_DEFAULT;
37+
3638
/**
3739
*
3840
*/
@@ -48,8 +50,7 @@ public AzureBlobStore(RepositoryName name, Settings settings, RepositorySettings
4850
AzureStorageService client) throws URISyntaxException, StorageException {
4951
super(settings);
5052
this.client = client;
51-
this.container = repositorySettings.settings().get(AzureStorageService.Fields.CONTAINER,
52-
componentSettings.get(AzureStorageService.Fields.CONTAINER, AzureRepository.CONTAINER_DEFAULT));
53+
this.container = repositorySettings.settings().get("container", settings.get(CONTAINER, CONTAINER_DEFAULT));
5354
this.repositoryName = name.getName();
5455
}
5556

src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeService.java

+27-20
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,43 @@
2626
*/
2727
public interface AzureComputeService {
2828

29-
static public final class Fields {
29+
static public final class Management {
3030
// Deprecated azure management cloud settings
3131
@Deprecated
32-
public static final String SUBSCRIPTION_ID_DEPRECATED = "subscription_id";
32+
public static final String SUBSCRIPTION_ID_DEPRECATED = "cloud.azure.subscription_id";
3333
@Deprecated
34-
public static final String SERVICE_NAME_DEPRECATED = "service_name";
34+
public static final String SERVICE_NAME_DEPRECATED = "cloud.azure.service_name";
3535
@Deprecated
36-
public static final String KEYSTORE_DEPRECATED = "keystore";
36+
public static final String KEYSTORE_DEPRECATED = "cloud.azure.keystore";
3737
@Deprecated
38-
public static final String PASSWORD_DEPRECATED = "password";
39-
@Deprecated
40-
public static final String PORT_NAME_DEPRECATED = "port_name";
41-
@Deprecated
42-
public static final String HOST_TYPE_DEPRECATED = "host_type";
38+
public static final String PASSWORD_DEPRECATED = "cloud.azure.password";
39+
40+
public static final String API_IMPLEMENTATION = "cloud.azure.management.api.impl";
4341

44-
public static final String SUBSCRIPTION_ID = "subscription.id";
45-
public static final String SERVICE_NAME = "cloud.service.name";
42+
public static final String SUBSCRIPTION_ID = "cloud.azure.management.subscription.id";
43+
public static final String SERVICE_NAME = "cloud.azure.management.cloud.service.name";
4644

4745
// Keystore settings
48-
public static final String KEYSTORE_PATH = "keystore.path";
49-
public static final String KEYSTORE_PASSWORD = "keystore.password";
50-
public static final String KEYSTORE_TYPE = "keystore.type";
46+
public static final String KEYSTORE_PATH = "cloud.azure.management.keystore.path";
47+
public static final String KEYSTORE_PASSWORD = "cloud.azure.management.keystore.password";
48+
public static final String KEYSTORE_TYPE = "cloud.azure.management.keystore.type";
49+
}
5150

52-
public static final String REFRESH = "refresh_interval";
51+
static public final class Discovery {
52+
// Deprecated azure discovery cloud settings
53+
@Deprecated
54+
public static final String PORT_NAME_DEPRECATED = "cloud.azure.port_name";
55+
@Deprecated
56+
public static final String HOST_TYPE_DEPRECATED = "cloud.azure.host_type";
57+
@Deprecated
58+
public static final String REFRESH_DEPRECATED = "cloud.azure.refresh_interval";
5359

54-
public static final String HOST_TYPE = "host.type";
55-
public static final String ENDPOINT_NAME = "endpoint.name";
56-
public static final String DEPLOYMENT_NAME = "deployment.name";
57-
public static final String DEPLOYMENT_SLOT = "deployment.slot";
58-
}
60+
public static final String REFRESH = "discovery.azure.refresh_interval";
5961

62+
public static final String HOST_TYPE = "discovery.azure.host.type";
63+
public static final String ENDPOINT_NAME = "discovery.azure.endpoint.name";
64+
public static final String DEPLOYMENT_NAME = "discovery.azure.deployment.name";
65+
public static final String DEPLOYMENT_SLOT = "discovery.azure.deployment.slot";
66+
}
6067
public HostedServiceGetDetailedResponse getServiceDetails();
6168
}

0 commit comments

Comments
 (0)