Skip to content

Commit 6f867d1

Browse files
committed
Update settings filter and remove component settings from AbstractComponent
Update settings filter to match elastic/elasticsearch#9748 Remove component settings from AbstractComponent as seen in elastic/elasticsearch#9919 Closes #71. Closes #72. (cherry picked from commit cd7b8d4)
1 parent fd55784 commit 6f867d1

18 files changed

+218
-229
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ How to start (short story)
4242
Azure credential API settings
4343
-----------------------------
4444

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

47-
* `keystore.path`: /path/to/keystore
48-
* `keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`.
49-
* `keystore.password`: your_password for the keystore
50-
* `subscription.id`: your_azure_subscription_id
51-
* `cloud.service.name`: your_azure_cloud_service_name
47+
* `cloud.azure.management.keystore.path`: /path/to/keystore
48+
* `cloud.azure.management.keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`.
49+
* `cloud.azure.management.keystore.password`: your_password for the keystore
50+
* `cloud.azure.management.subscription.id`: your_azure_subscription_id
51+
* `cloud.azure.management.cloud.service.name`: your_azure_cloud_service_name
5252

5353
Note that in previous versions, it was:
5454

@@ -64,16 +64,16 @@ cloud:
6464
Advanced settings
6565
-----------------
6666

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

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

7878
For example:
7979

@@ -454,10 +454,10 @@ Example using Java:
454454

455455
```java
456456
client.admin().cluster().preparePutRepository("my_backup3")
457-
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
458-
.put(AzureStorageService.Fields.CONTAINER, "backup_container")
459-
.put(AzureStorageService.Fields.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
460-
).get();
457+
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
458+
.put(Storage.CONTAINER, "backup_container")
459+
.put(Storage.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
460+
).get();
461461
```
462462

463463
Repository validation rules

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

Lines changed: 35 additions & 40 deletions
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

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,38 @@
1919

2020
package org.elasticsearch.cloud.azure;
2121

22-
import org.elasticsearch.cloud.azure.management.AzureComputeService;
23-
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
2422
import org.elasticsearch.common.settings.ImmutableSettings;
2523
import org.elasticsearch.common.settings.SettingsFilter;
2624

25+
import static org.elasticsearch.cloud.azure.management.AzureComputeService.Management.*;
26+
import static org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage.*;
27+
2728
/**
2829
* Filtering cloud.azure.* settings
2930
*/
3031
public class AzureSettingsFilter implements SettingsFilter.Filter {
3132

3233
@Override
3334
public void filter(ImmutableSettings.Builder settings) {
34-
// Cloud global settings
35-
settings.remove("cloud.azure." + AzureComputeService.Fields.REFRESH);
36-
37-
// Cloud management API settings
38-
settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH);
39-
settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD);
40-
settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_TYPE);
41-
settings.remove("cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID);
42-
settings.remove("cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME);
35+
// Cloud management API settings we need to hide
36+
settings.remove(KEYSTORE_PATH);
37+
settings.remove(KEYSTORE_PASSWORD);
38+
settings.remove(KEYSTORE_TYPE);
39+
settings.remove(SUBSCRIPTION_ID);
4340

44-
// Deprecated Cloud management API settings
41+
// Deprecated Cloud management API settings we need to hide
4542
// TODO Remove in 3.0.0
46-
settings.remove("cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED);
47-
settings.remove("cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED);
48-
settings.remove("cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED);
49-
settings.remove("cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED);
43+
settings.remove(KEYSTORE_DEPRECATED);
44+
settings.remove(PASSWORD_DEPRECATED);
45+
settings.remove(SUBSCRIPTION_ID_DEPRECATED);
5046

51-
// Cloud storage API settings
52-
settings.remove("cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT);
53-
settings.remove("cloud.azure.storage." + AzureStorageService.Fields.KEY);
47+
// Cloud storage API settings needed to be hidden
48+
settings.remove(ACCOUNT);
49+
settings.remove(KEY);
5450

55-
// Deprecated Cloud storage API settings
51+
// Deprecated Cloud storage API settings needed to be hidden
5652
// TODO Remove in 3.0.0
57-
settings.remove("cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED);
58-
settings.remove("cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED);
53+
settings.remove(ACCOUNT_DEPRECATED);
54+
settings.remove(KEY_DEPRECATED);
5955
}
6056
}

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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 27 additions & 20 deletions
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)