Skip to content

Commit

Permalink
Remove deprecated settings
Browse files Browse the repository at this point in the history
#61 and #62 renamed settings by deprecating old ones and creating new ones.
In version 3.0.0, we can remove old settings.

That said, we should not remove it from master doc before 2.6.0 is released.

Closes #70.
  • Loading branch information
dadoonet committed Apr 16, 2015
1 parent cd7b8d4 commit 7ba6595
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 128 deletions.
55 changes: 7 additions & 48 deletions src/main/java/org/elasticsearch/cloud/azure/AzureModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.elasticsearch.ElasticsearchException;
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;
Expand Down Expand Up @@ -104,17 +103,11 @@ public static boolean isDiscoveryReady(Settings settings, ESLogger logger) {
return false;
}

if ( // We check new parameters
(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, Management.SUBSCRIPTION_ID_DEPRECATED) ||
isPropertyMissing(settings, Management.SERVICE_NAME_DEPRECATED) ||
isPropertyMissing(settings, Management.KEYSTORE_DEPRECATED) ||
isPropertyMissing(settings, Management.PASSWORD_DEPRECATED))
) {
if (isPropertyMissing(settings, Management.SUBSCRIPTION_ID) ||
isPropertyMissing(settings, Management.SERVICE_NAME) ||
isPropertyMissing(settings, Management.KEYSTORE_PATH) ||
isPropertyMissing(settings, Management.KEYSTORE_PASSWORD)
) {
logger.debug("one or more azure discovery settings are missing. " +
"Check elasticsearch.yml file. Should have [{}], [{}], [{}] and [{}].",
Management.SUBSCRIPTION_ID,
Expand All @@ -140,10 +133,8 @@ public static boolean isSnapshotReady(Settings settings, ESLogger logger) {
return false;
}

if ((isPropertyMissing(settings, Storage.ACCOUNT) ||
isPropertyMissing(settings, Storage.KEY)) &&
(isPropertyMissing(settings, Storage.ACCOUNT_DEPRECATED) ||
isPropertyMissing(settings, Storage.KEY_DEPRECATED))) {
if (isPropertyMissing(settings, Storage.ACCOUNT) ||
isPropertyMissing(settings, Storage.KEY)) {
logger.debug("azure repository is not set using [{}] and [{}] properties",
Storage.ACCOUNT,
Storage.KEY);
Expand All @@ -155,38 +146,6 @@ public static boolean isSnapshotReady(Settings settings, ESLogger logger) {
return true;
}

/**
* Check if we are using any deprecated settings
*/
public static void checkDeprecatedSettings(Settings settings, String oldParameter, String newParameter, ESLogger logger) {
if (!isPropertyMissing(settings, oldParameter)) {
logger.warn("using deprecated [{}]. Please change it to [{}] property.",
oldParameter,
newParameter);
}
}

/**
* Check all deprecated settings
* @param settings
* @param logger
*/
public static void checkDeprecated(Settings settings, ESLogger logger) {
// Cloud services are disabled
if (isCloudReady(settings)) {
checkDeprecatedSettings(settings, Storage.ACCOUNT_DEPRECATED, Storage.ACCOUNT, logger);
checkDeprecatedSettings(settings, Storage.KEY_DEPRECATED, Storage.KEY, logger);

// TODO Remove in 3.0.0
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);
}
}

public static boolean isPropertyMissing(Settings settings, String name) throws ElasticsearchException {
if (!Strings.hasText(settings.get(name))) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
public interface AzureComputeService {

static public final class Management {
// Deprecated azure management cloud settings
@Deprecated
public static final String SUBSCRIPTION_ID_DEPRECATED = "cloud.azure.subscription_id";
@Deprecated
public static final String SERVICE_NAME_DEPRECATED = "cloud.azure.service_name";
@Deprecated
public static final String KEYSTORE_DEPRECATED = "cloud.azure.keystore";
@Deprecated
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 = "cloud.azure.management.subscription.id";
Expand All @@ -49,14 +39,6 @@ static public final class Management {
}

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 REFRESH = "discovery.azure.refresh_interval";

public static final String HOST_TYPE = "discovery.azure.host.type";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ static final class Azure {
@Inject
public AzureComputeServiceImpl(Settings settings) {
super(settings);
String subscriptionId = settings.get(SUBSCRIPTION_ID, settings.get(SUBSCRIPTION_ID_DEPRECATED));
String subscriptionId = settings.get(SUBSCRIPTION_ID);

serviceName = settings.get(Management.SERVICE_NAME, settings.get(Management.SERVICE_NAME_DEPRECATED));
String keystorePath = settings.get(KEYSTORE_PATH, settings.get(KEYSTORE_DEPRECATED));
String keystorePassword = settings.get(KEYSTORE_PASSWORD, settings.get(PASSWORD_DEPRECATED));
serviceName = settings.get(Management.SERVICE_NAME);
String keystorePath = settings.get(KEYSTORE_PATH);
String keystorePassword = settings.get(KEYSTORE_PASSWORD);
String strKeyStoreType = settings.get(KEYSTORE_TYPE, KeyStoreType.pkcs12.name());
KeyStoreType tmpKeyStoreType = KeyStoreType.pkcs12;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,5 @@ protected AzureComputeSettingsFilter(Settings settings, SettingsFilter settingsF
settingsFilter.addFilter(KEYSTORE_PASSWORD);
settingsFilter.addFilter(KEYSTORE_TYPE);
settingsFilter.addFilter(SUBSCRIPTION_ID);

// Deprecated Cloud management API settings we need to hide
// TODO Remove in 3.0.0
settingsFilter.addFilter(KEYSTORE_DEPRECATED);
settingsFilter.addFilter(PASSWORD_DEPRECATED);
settingsFilter.addFilter(SUBSCRIPTION_ID_DEPRECATED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
*/
public interface AzureStorageService {
static public final class Storage {
@Deprecated
public static final String ACCOUNT_DEPRECATED = "cloud.azure.storage_account";
@Deprecated
public static final String KEY_DEPRECATED = "cloud.azure.storage_key";

public static final String API_IMPLEMENTATION = "cloud.azure.storage.api.impl";
public static final String ACCOUNT = "cloud.azure.storage.account";
public static final String KEY = "cloud.azure.storage.key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
public AzureStorageServiceImpl(Settings settings) {
super(settings);
// We try to load storage API settings from `cloud.azure.`
account = settings.get(ACCOUNT, settings.get(ACCOUNT_DEPRECATED));
key = settings.get(KEY, settings.get(KEY_DEPRECATED));
account = settings.get(ACCOUNT);
key = settings.get(KEY);
blob = "http://" + account + ".blob.core.windows.net/";

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,5 @@ protected AzureStorageSettingsFilter(Settings settings, SettingsFilter settingsF
// Cloud storage API settings needed to be hidden
settingsFilter.addFilter(ACCOUNT);
settingsFilter.addFilter(KEY);

// Deprecated Cloud storage API settings needed to be hidden
// TODO Remove in 3.0.0
settingsFilter.addFilter(ACCOUNT_DEPRECATED);
settingsFilter.addFilter(KEY_DEPRECATED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.elasticsearch.cloud.azure.AzureServiceRemoteException;
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.cluster.node.DiscoveryNode;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.component.AbstractComponent;
Expand Down Expand Up @@ -112,33 +111,21 @@ public AzureUnicastHostsProvider(Settings settings, AzureComputeService azureCom
this.networkService = networkService;
this.version = version;

this.refreshInterval = settings.getAsTime(Discovery.REFRESH, settings.getAsTime(Discovery.REFRESH_DEPRECATED,
TimeValue.timeValueSeconds(0)));
this.refreshInterval = settings.getAsTime(Discovery.REFRESH, TimeValue.timeValueSeconds(0));

String strHostType = settings.get(Discovery.HOST_TYPE, settings.get(Discovery.HOST_TYPE_DEPRECATED,
HostType.PRIVATE_IP.name())).toUpperCase();
String strHostType = settings.get(Discovery.HOST_TYPE, HostType.PRIVATE_IP.name()).toUpperCase();
HostType tmpHostType = HostType.fromString(strHostType);
if (tmpHostType == null) {
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Discovery.HOST_TYPE,
strHostType, HostType.PRIVATE_IP.name().toLowerCase());
tmpHostType = HostType.PRIVATE_IP;
}
this.hostType = tmpHostType;

// TODO Remove in 3.0.0
String portName = settings.get(Discovery.PORT_NAME_DEPRECATED);
if (portName != null) {
logger.warn("setting [{}] has been deprecated. please replace with [{}].", Discovery.PORT_NAME_DEPRECATED,
Discovery.ENDPOINT_NAME);
this.publicEndpointName = portName;
} else {
this.publicEndpointName = settings.get(Discovery.ENDPOINT_NAME, "elasticsearch");
}
this.publicEndpointName = settings.get(Discovery.ENDPOINT_NAME, "elasticsearch");

// Deployment name could be set with discovery.azure.deployment.name
// Default to cloud.azure.management.cloud.service.name
this.deploymentName = settings.get(Discovery.DEPLOYMENT_NAME,
settings.get(Management.SERVICE_NAME, settings.get(Management.SERVICE_NAME_DEPRECATED)));
this.deploymentName = settings.get(Discovery.DEPLOYMENT_NAME);

// Reading deployment_slot
String strDeployment = settings.get(Discovery.DEPLOYMENT_SLOT, Deployment.PRODUCTION.deployment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import java.util.Collection;

import static org.elasticsearch.cloud.azure.AzureModule.checkDeprecated;
import static org.elasticsearch.cloud.azure.AzureModule.isSnapshotReady;

/**
Expand All @@ -46,7 +45,6 @@ public class CloudAzurePlugin extends AbstractPlugin {
public CloudAzurePlugin(Settings settings) {
this.settings = settings;
logger.trace("starting azure plugin...");
checkDeprecated(settings, logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,11 @@ protected Settings settingsBuilder() {
.put("node.mode", "network");

// We add a fake subscription_id to start mock compute service
if (rarely()) {
// We use sometime deprecated settings in tests
builder.put(Management.SUBSCRIPTION_ID_DEPRECATED, "fake")
.put(Discovery.REFRESH_DEPRECATED, "5s")
.put(Management.KEYSTORE_DEPRECATED, "dummy")
.put(Management.PASSWORD_DEPRECATED, "dummy")
.put(Management.SERVICE_NAME_DEPRECATED, "dummy");
} else {
builder.put(Management.SUBSCRIPTION_ID, "fake")
.put(Discovery.REFRESH, "5s")
.put(Management.KEYSTORE_PATH, "dummy")
.put(Management.KEYSTORE_PASSWORD, "dummy")
.put(Management.SERVICE_NAME, "dummy");
}
builder.put(Management.SUBSCRIPTION_ID, "fake")
.put(Discovery.REFRESH, "5s")
.put(Management.KEYSTORE_PATH, "dummy")
.put(Management.KEYSTORE_PASSWORD, "dummy")
.put(Management.SERVICE_NAME, "dummy");

return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,8 @@ protected Settings nodeSettings(int nodeOrdinal) {
.put(Storage.CONTAINER, "snapshots");

// We use sometime deprecated settings in tests
if (rarely()) {
builder.put(Storage.ACCOUNT_DEPRECATED, "mock_azure_account")
.put(Storage.KEY_DEPRECATED, "mock_azure_key");
} else {
builder.put(Storage.ACCOUNT, "mock_azure_account")
.put(Storage.KEY, "mock_azure_key");
}
builder.put(Storage.ACCOUNT, "mock_azure_account")
.put(Storage.KEY, "mock_azure_key");

return builder.build();
}
Expand Down

0 comments on commit 7ba6595

Please sign in to comment.