Skip to content

Commit

Permalink
Update settings filter and remove component settings from AbstractCom…
Browse files Browse the repository at this point in the history
…ponent

Update settings filter to match elastic/elasticsearch#9748
Remove component settings from AbstractComponent as seen in elastic/elasticsearch#9919

Closes elastic#71.
Closes elastic#72.
  • Loading branch information
dadoonet committed Apr 16, 2015
1 parent b7c4408 commit cd7b8d4
Show file tree
Hide file tree
Showing 22 changed files with 300 additions and 288 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ How to start (short story)
Azure credential API settings
-----------------------------

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

* `keystore.path`: /path/to/keystore
* `keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`.
* `keystore.password`: your_password for the keystore
* `subscription.id`: your_azure_subscription_id
* `cloud.service.name`: your_azure_cloud_service_name
* `cloud.azure.management.keystore.path`: /path/to/keystore
* `cloud.azure.management.keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`.
* `cloud.azure.management.keystore.password`: your_password for the keystore
* `cloud.azure.management.subscription.id`: your_azure_subscription_id
* `cloud.azure.management.cloud.service.name`: your_azure_cloud_service_name

Note that in previous versions, it was:

Expand All @@ -86,16 +86,16 @@ cloud:
Advanced settings
-----------------

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

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

For example:

Expand Down Expand Up @@ -476,10 +476,10 @@ Example using Java:

```java
client.admin().cluster().preparePutRepository("my_backup3")
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
.put(AzureStorageService.Fields.CONTAINER, "backup_container")
.put(AzureStorageService.Fields.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
).get();
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
.put(Storage.CONTAINER, "backup_container")
.put(Storage.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
).get();
```

Repository validation rules
Expand Down
75 changes: 35 additions & 40 deletions src/main/java/org/elasticsearch/cloud/azure/AzureModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
package org.elasticsearch.cloud.azure;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl;
import org.elasticsearch.cloud.azure.management.AzureComputeService;
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
import org.elasticsearch.cloud.azure.management.AzureComputeServiceImpl;
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Inject;
Expand Down Expand Up @@ -63,15 +66,15 @@ protected void configure() {
if (isDiscoveryReady(settings, logger)) {
logger.debug("starting azure discovery service");
bind(AzureComputeService.class)
.to(settings.getAsClass("cloud.azure.api.impl", AzureComputeServiceImpl.class))
.to(settings.getAsClass(Management.API_IMPLEMENTATION, AzureComputeServiceImpl.class))
.asEagerSingleton();
}

// If we have settings for azure repository, let's start the azure storage service
if (isSnapshotReady(settings, logger)) {
logger.debug("starting azure repository service");
bind(AzureStorageService.class)
.to(settings.getAsClass("repositories.azure.api.impl", AzureStorageServiceImpl.class))
.to(settings.getAsClass(Storage.API_IMPLEMENTATION, AzureStorageServiceImpl.class))
.asEagerSingleton();
}
}
Expand Down Expand Up @@ -102,22 +105,22 @@ public static boolean isDiscoveryReady(Settings settings, ESLogger logger) {
}

if ( // We check new parameters
(isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID) ||
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME) ||
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH) ||
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD))
(isPropertyMissing(settings, Management.SUBSCRIPTION_ID) ||
isPropertyMissing(settings, Management.SERVICE_NAME) ||
isPropertyMissing(settings, Management.KEYSTORE_PATH) ||
isPropertyMissing(settings, Management.KEYSTORE_PASSWORD))
// We check deprecated
&& (isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED) ||
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED) ||
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED) ||
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED))
&& (isPropertyMissing(settings, Management.SUBSCRIPTION_ID_DEPRECATED) ||
isPropertyMissing(settings, Management.SERVICE_NAME_DEPRECATED) ||
isPropertyMissing(settings, Management.KEYSTORE_DEPRECATED) ||
isPropertyMissing(settings, Management.PASSWORD_DEPRECATED))
) {
logger.debug("one or more azure discovery settings are missing. " +
"Check elasticsearch.yml file and `cloud.azure.management`. Should have [{}], [{}], [{}] and [{}].",
AzureComputeService.Fields.SUBSCRIPTION_ID,
AzureComputeService.Fields.SERVICE_NAME,
AzureComputeService.Fields.KEYSTORE_PATH,
AzureComputeService.Fields.KEYSTORE_PASSWORD);
"Check elasticsearch.yml file. Should have [{}], [{}], [{}] and [{}].",
Management.SUBSCRIPTION_ID,
Management.SERVICE_NAME,
Management.KEYSTORE_PATH,
Management.KEYSTORE_PASSWORD);
return false;
}

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

if ((isPropertyMissing(settings, "cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT) ||
isPropertyMissing(settings, "cloud.azure.storage." + AzureStorageService.Fields.KEY)) &&
(isPropertyMissing(settings, "cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED) ||
isPropertyMissing(settings, "cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED))) {
logger.debug("azure repository is not set [using cloud.azure.storage.{}] and [cloud.azure.storage.{}] properties",
AzureStorageService.Fields.ACCOUNT,
AzureStorageService.Fields.KEY);
if ((isPropertyMissing(settings, Storage.ACCOUNT) ||
isPropertyMissing(settings, Storage.KEY)) &&
(isPropertyMissing(settings, Storage.ACCOUNT_DEPRECATED) ||
isPropertyMissing(settings, Storage.KEY_DEPRECATED))) {
logger.debug("azure repository is not set using [{}] and [{}] properties",
Storage.ACCOUNT,
Storage.KEY);
return false;
}

Expand Down Expand Up @@ -171,24 +174,16 @@ public static void checkDeprecatedSettings(Settings settings, String oldParamete
public static void checkDeprecated(Settings settings, ESLogger logger) {
// Cloud services are disabled
if (isCloudReady(settings)) {
checkDeprecatedSettings(settings, "cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED,
"cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT, logger);
checkDeprecatedSettings(settings, "cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED,
"cloud.azure.storage." + AzureStorageService.Fields.KEY, logger);
checkDeprecatedSettings(settings, Storage.ACCOUNT_DEPRECATED, Storage.ACCOUNT, logger);
checkDeprecatedSettings(settings, Storage.KEY_DEPRECATED, Storage.KEY, logger);

// TODO Remove in 3.0.0
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED,
"cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH, logger);
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED,
"cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD, logger);
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED,
"cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME, logger);
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED,
"cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID, logger);
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.HOST_TYPE_DEPRECATED,
"discovery.azure." + AzureComputeService.Fields.HOST_TYPE, logger);
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.PORT_NAME_DEPRECATED,
"discovery.azure." + AzureComputeService.Fields.ENDPOINT_NAME, logger);
checkDeprecatedSettings(settings, Management.KEYSTORE_DEPRECATED, Management.KEYSTORE_PATH, logger);
checkDeprecatedSettings(settings, Management.PASSWORD_DEPRECATED, Management.KEYSTORE_PASSWORD, logger);
checkDeprecatedSettings(settings, Management.SERVICE_NAME_DEPRECATED, Management.SERVICE_NAME, logger);
checkDeprecatedSettings(settings, Management.SUBSCRIPTION_ID_DEPRECATED, Management.SUBSCRIPTION_ID, logger);
checkDeprecatedSettings(settings, Discovery.HOST_TYPE_DEPRECATED, Discovery.HOST_TYPE, logger);
checkDeprecatedSettings(settings, Discovery.PORT_NAME_DEPRECATED, Discovery.ENDPOINT_NAME, logger);
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.repositories.RepositoryName;
import org.elasticsearch.repositories.RepositorySettings;
import org.elasticsearch.repositories.azure.AzureRepository;

import java.net.URISyntaxException;

import static org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage.CONTAINER;
import static org.elasticsearch.repositories.azure.AzureRepository.CONTAINER_DEFAULT;

/**
*
*/
Expand All @@ -48,8 +50,7 @@ public AzureBlobStore(RepositoryName name, Settings settings, RepositorySettings
AzureStorageService client) throws URISyntaxException, StorageException {
super(settings);
this.client = client;
this.container = repositorySettings.settings().get(AzureStorageService.Fields.CONTAINER,
componentSettings.get(AzureStorageService.Fields.CONTAINER, AzureRepository.CONTAINER_DEFAULT));
this.container = repositorySettings.settings().get("container", settings.get(CONTAINER, CONTAINER_DEFAULT));
this.repositoryName = name.getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,43 @@
*/
public interface AzureComputeService {

static public final class Fields {
static public final class Management {
// Deprecated azure management cloud settings
@Deprecated
public static final String SUBSCRIPTION_ID_DEPRECATED = "subscription_id";
public static final String SUBSCRIPTION_ID_DEPRECATED = "cloud.azure.subscription_id";
@Deprecated
public static final String SERVICE_NAME_DEPRECATED = "service_name";
public static final String SERVICE_NAME_DEPRECATED = "cloud.azure.service_name";
@Deprecated
public static final String KEYSTORE_DEPRECATED = "keystore";
public static final String KEYSTORE_DEPRECATED = "cloud.azure.keystore";
@Deprecated
public static final String PASSWORD_DEPRECATED = "password";
@Deprecated
public static final String PORT_NAME_DEPRECATED = "port_name";
@Deprecated
public static final String HOST_TYPE_DEPRECATED = "host_type";
public static final String PASSWORD_DEPRECATED = "cloud.azure.password";

public static final String API_IMPLEMENTATION = "cloud.azure.management.api.impl";

public static final String SUBSCRIPTION_ID = "subscription.id";
public static final String SERVICE_NAME = "cloud.service.name";
public static final String SUBSCRIPTION_ID = "cloud.azure.management.subscription.id";
public static final String SERVICE_NAME = "cloud.azure.management.cloud.service.name";

// Keystore settings
public static final String KEYSTORE_PATH = "keystore.path";
public static final String KEYSTORE_PASSWORD = "keystore.password";
public static final String KEYSTORE_TYPE = "keystore.type";
public static final String KEYSTORE_PATH = "cloud.azure.management.keystore.path";
public static final String KEYSTORE_PASSWORD = "cloud.azure.management.keystore.password";
public static final String KEYSTORE_TYPE = "cloud.azure.management.keystore.type";
}

public static final String REFRESH = "refresh_interval";
static public final class Discovery {
// Deprecated azure discovery cloud settings
@Deprecated
public static final String PORT_NAME_DEPRECATED = "cloud.azure.port_name";
@Deprecated
public static final String HOST_TYPE_DEPRECATED = "cloud.azure.host_type";
@Deprecated
public static final String REFRESH_DEPRECATED = "cloud.azure.refresh_interval";

public static final String HOST_TYPE = "host.type";
public static final String ENDPOINT_NAME = "endpoint.name";
public static final String DEPLOYMENT_NAME = "deployment.name";
public static final String DEPLOYMENT_SLOT = "deployment.slot";
}
public static final String REFRESH = "discovery.azure.refresh_interval";

public static final String HOST_TYPE = "discovery.azure.host.type";
public static final String ENDPOINT_NAME = "discovery.azure.endpoint.name";
public static final String DEPLOYMENT_NAME = "discovery.azure.deployment.name";
public static final String DEPLOYMENT_SLOT = "discovery.azure.deployment.slot";
}
public HostedServiceGetDetailedResponse getServiceDetails();
}
Loading

0 comments on commit cd7b8d4

Please sign in to comment.